- Home /
Get SerializedProperty from outside class for use in popup (PropertyDrawer)
I'm having fun using the new PropertyDrawer for Unity 4 to make custom editors, but I have hit a snag.
Right now my popup dropdown list is displaying a test array of strings and it works great. But I want my popup list to display strings found in an array not contained in the class I am editing.
To ask it another way, how can I get strings from a different part of my project to populate my popup list with?
Answer by SmooveB · Dec 05, 2012 at 05:44 PM
Ok, found a simple solution, but it won't work in all circumstances. When using a PropertyDrawer, the OnGUI function gives you a SerializedProperty that is your class. In this case, the strings I was looking for are in the same script as the class. This means I was able to use the SerializedProperty.serializedObject to get a serialized object of the entire script and thereby the strings.
I would still like to know how to get Objects to use as SerializedObjects arbitrarily, so I will leave this question unanswered for a bit.
Your answer
Follow this Question
Related Questions
Draw custom Property Field in Custom Editor 1 Answer
Applying a PropertyDrawer to elements of a List<> 1 Answer
How do you actually use CanEditMultipleObjects 1 Answer
Error when trying to Serialize a field that is in a class 0 Answers
Drawing InputAction Property Drawer in a custom editor? 1 Answer