Question by 
               potato_dev · Jun 04, 2020 at 06:43 PM · 
                inspectoreditor-scriptinginheritancecustom editorpopup  
              
 
              Popup to choose which child class I want in Custom Editor Inspector
Hello, I have something like this:
and then a ScritableObject:[Serializable] public class Shape{ }[Serializable] public class Circle : Shape { public float radius; }[Serializable] public class Rectangle : Shape { public float width; public float height; }
[CreateAssetMenu]
public class MyScriptable : ScriptableObject{
  public Shape[] shapes;
}
[CustomEditor(typeof(MyScriptable))]
public class MyEditor : Editor {
    SerializedProperty shapes;
    void OnEnable() {
        shapes = serializedObject.FindProperty("shapes");
    }
    public override void OnInspectorGUI() {
        serializedObject.Update();
        EditorGUILayout.PropertyField(shapes);
        serializedObject.ApplyModifiedProperties();
    }
}
 and to show the popup I did this: 
               [CustomPropertyDrawer(typeof(Shape))]
public class ShapeDrawer : PropertyDrawer {
  string[] options = {"Circle", "Rectangle"};
  private int index = 0;
  public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) {
    index = EditorGUI.Popup(position, index, options);
  }
}
 Does anyone know how to make this?
 Does anyone know how to make this? 
                
               
                 
                スクリーンショット-2020-06-04-午後34048.png 
                (50.0 kB) 
               
 
              
               Comment
              
 
               
              Your answer
 
 
             Follow this Question
Related Questions
Custom Editor List with child classes 1 Answer
How to edit array/list property with custom PropertyDrawer? 3 Answers
How to add Texture2D to Popup/Dropdown 0 Answers
Custom Editor Handle Changes Not Persisting in Play Mode. 1 Answer
Update gameObject's children properties from CustomEditor class 1 Answer
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                