Serialization Placeholder Value for Different Fields?
I started learning about Serialization just recently, and I noticed that in Unity's scripts, you have the capability to select multiple objects with similar scripts and edit those fields simultaneously. When both fields are the same, the value is retained, but if all objects have different values for a specific field, it shows a placeholder value like "--" or something like that.
I would like to figure out how to do this with my own script so that my multi-object editing functionality works perfectly. I'm still trying it out on something simple, so here's a sample of my string code:
if (!scriptNoteProp.hasMultipleDifferentValues) { scriptNoteProp.stringValue = EditorGUILayout.TextField("Script Note", scriptNoteProp.stringValue); }
else { scriptNoteProp.stringValue = EditorGUILayout.TextField("Script Note", "?????"); }
If two objects share the same text field but with different text, selecting both objects displays the placeholder value, but when only one object is selected afterwards, it retains the placeholder value rather than revert back to their original values.
Is there some way for me to achieve this result? Any advice would be greatly appreciated.
Answer by Gamer91112 · Oct 13, 2015 at 02:05 AM
This question has been released for a while now and I'm surprised nobody was able to help me out here... I was able to figure it out myself. I had to use the property field method rather than the text field method and it would be able to support multi-object editing.