- Home /
How can I draw the default widget for a field in a CustomEditor?
Hi all
I'm writing a CustomEditor script for a class that looks something like:
public class MyClass : MonoBehaviour
{
public List<SerializableObject> classContents;
}
In my CustomEditor I want to loop over the contents of the list and draw the default widget for each item.
I know that I can write custom PropertyDrawers for my SerializableObject, but since I am already taking over the OnInspectorGUI event these drawers will not be created.
Is this possible?
Thanks, Ves
Answer by VesuvianPrime · Dec 12, 2014 at 02:05 AM
Since writing this question I've learned how and why to use SerializedPropertys. Simply drawing a PropertyField for each list element is sufficient.
Answer by MakeCodeNow · May 08, 2014 at 12:48 AM
Just call DrawDefaultInspector() whenever you want from within your custom editor, either before or after or intermixed with your custom code.
Your answer
![](https://koobas.hobune.stream/wayback/20220613144450im_/https://answers.unity.com/themes/thub/images/avi.jpg)