- Home /
Changing isExpanded property from another Editor
What I want to do
I have an Editor for the component Foo, FooEditor and Another component Bar which also has the editor BarEditor.
Bar has a Field named value, that is serialized. The Field itself does not matter because the BarEditor actually just changes SerializedProperty value.isExpanded. That works fine so far.
Now FooEditor should also have a button that can change the isExpanded state of value from the Bar instance attached to the same object.
The Setup
As far as I know, I can get and modify the SerializedProperty of value from the Bar instance with
SerializedObject barObject = new SerializedObject(bar) // Got bar with GetComponent
barObject.Update();
SerializedProperty value = barObject.FindProperty("value");
value.isExpanded = !value.isExpanded
barObject.ApplyModifiedProperties();
The Problem
This approach works perfect for everything but isExpanded. I can modify e.g. value.boolvalue and it works. However, isExpanded does not, the changed value is not memorized. I guess it has something to do with the special treatment of this value. Though, the special behaviour of isExpanded is exactly what I need.
Maybe somebody has an idea?
Your answer
Follow this Question
Related Questions
Call a function of a custom class through a SerializedProperty 0 Answers
Using SerializedProperty on custom classes? 2 Answers
Set SerializedProperty of custom type to null 1 Answer
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers