c# - CustomPropertyDrawer in unity3d for inherited classes -


I'm trying to do something that I think is relatively simple, but maybe I'm away from the base. I do not know. I have a class that comes from ScriptableObject, such as:

  using UnityEngine; Class Automobile: Scriptable Object {{SerializedField} Personal Int _baseCost = 0; Public integer BaseCost {{return returned _baseCost;} set {_baseCost = value;}} // more areas and arguments zero onValidate () {BaseCost = _baseCost; }}  

So I have a class that inherits from automobile, like this:

  public class car: automobile {}  

This class is really empty, later logic can be added, now I just keep cars separate from trucks, motorcycles, and who knows what else I will think. I used it to create a bunch of asset files for cars separately from Unity Wiki. All the \ resources are located under the \ cars \ folder so I can load them on the runtime

I'm a player class that includes an array of cars (and trucks, but for brevity, Excluding)

  Using Unity Engine; Public class player: Monobehavier {[SerializeField] Private car [] _cars; Public cars [] cars {receive {_cars; } Set {_cars = value; }} Zero start () {// array cars = Resources.LoadAll & load all cars in LT; Cars & gt; ("Car")}}  

To make this all closed cap, and to really explain, the issue I'm having is a custom for every item I get from the automobile class. Want to make property drawer So I created a script like this in the editor folder:

  using UniDieter; Using Unity Engine; [CustomPropertyDrawer], public class AutomobileDrawer: PropertyDrawer {public override zero onGUI (Rect status, SerializedProperty property, GUIContent label) {editorGUI.BeginProperty (status, label, property); Position = EditorGUI.PrefixLabel (position, GUIUtility.GetControlID (FocusType.Passive), label); Var indent = EditorGUI.indentLevel; EditorGUI.indentLevel = 0; Reset basilicate = new rack (position x, position. Y, 200, position.height); Reset bascity = new racket (position .x + 35, position.a, 15, position .high); EditorGUI.LabelField (baseville, "Base cost"); // This is my error line EditorGUI.PropertyField (BaseV, property.FindPropertyRelative ("_ baseCost"), GUIContent.none); EditorGUI.indentLevel = Indent; EditorGUI.EndProperty (); //base.OnGUI (side, property, label); }  

The issue I am facing is that FindPropertyRelative always gives blank. I'm almost 100% confident that due to heritage level I need to make a path (when I move on trucks, as the path is probably different), but I do not know what she should do. Any suggestions?

EDIT: I forgot to mention that the onvalidate function has been used in the automobile classroom. I added it to the code.

It looks like this class which is well with scriptable object propertyreaders I was able to work properly in the property by removing heritage from my automobile class, and simply by applying the [serializable] attribute to class declaration, I was able to work properly.

I hope that I am wrong about this, as I have some sections that I need to leave inherit from script worthy and hopefully someone sees it I can and will correct me, but until that time, this is my solution.


Comments

Popular posts from this blog

sqlite3 - UPDATE a table from the SELECT of another one -

c# - Showing a SelectedItem's Property -

javascript - Render HTML after each iteration in loop -