How to make drop down list of classes in an array of classes (in the inspector)
I want to make a drop-down list in the inspector (like the ones used for enums) where you can pick if an SO will contain certain classes, this is what I have:
^The array I'm trying to show in the inspector
^The parent Class and the classes I want to be able to choose from in the inspector
^How it shows up in the inspector
The question is, how can I make that everytime I create a new SkillType in the array from the inspector, I can choose from a dropdown list which one of the child classes will it be?
Update: Tried using [Context$$anonymous$$enu] attribute to add them to the array (tried lists too) using a function but still didn't work (note that I added public variable inside the child classes to see if it works or not)
Unity **does not** serialize arrays of polymorphic types. This is the main reason you won't see any other drawers than OfThisBaseType[]. Because, behind the scenes, your array/list is being serialized and then deserialized in the background (homogenized as a result) by Inspector when editing prefab or scene. This can be solved tho implementing ISerializationCallbackReceiver and/or writing property drawers;
Then, to generate drop-down menus you may want to use NaughtyAttributes (free) OR Odin Inspector (paid)
Your answer
Follow this Question
Related Questions
Popup to choose which child class I want in Custom Editor Inspector 0 Answers
Reference mono script by parent class for ducktyping 0 Answers
Custom attributes: how does the attribute class relate to the custom type? 1 Answer
Custom Editor Inspector member class with inheritance, values resets after starting Play Mode 1 Answer