- Home /
Displaying System.objects not serialized by Unity in a Custom Editor
I have a collection of objects (not ultimately derived from UnityEngine.Object) that are Serializable (though not serialized by Unity) that I'm trying to draw in a Custom Editor. Is there a way to access the editor code (property drawers, custom inspectors, etc) for objects that are not serialized by Unity? We have MonoBehaviour wrappers for these objects and when we use them they display nicely, and I want to be able to display them in the same manner when they're not serialized out by being wrapped in a UnityEngine.Object (e.g when they're held in a list in a manager class that is not a MonoBehaviour or ScriptableObject).
Ideally, I'd love something that works similar to UnityEditor.Editor.CreateEditor(UnityEngine.Object) but works for System.objects that are serializable.
I tried a couple hacks, such as creating a generic container derived from UnityEngine.Object to hold my object (which failed I assume because it reads as null and the internet says you shouldn't derive directly from that class for several reasons), and instantiating a ScriptableObject container (which failed because you can't instantiate a ScriptableObject with a generic Type created via MakeGenericType, same with MonoBehaviours).
Any help greatly appreciated!
Alternatively, in case I can't sort that out, I'm just building a method that just uses FieldInfo of the object to construct its editor field - but I'm having to do a very large if/else where I draw the correct field based on the FieldType. If there's a more efficient way of doing this that anyone knows about, that might also work out fine? Though I don't think I'll get any of the benefits of custom property drawers or odin inspector attributes this way.
Your answer
![](https://koobas.hobune.stream/wayback/20220612212559im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Saving editor-only variables 0 Answers
'Unsupported type' error in custom editor script 4 Answers
Why is my unity editor script not saving changes to the actual script? 0 Answers
Large serializable field in a MonoBehaviour causing poor performance in Inspector 1 Answer
Why doesn't my ScriptableObject save using a custom EditorWindow? 3 Answers