Understanding that using Editor.targets
is becoming more and more difficult as a result of Editor.SetDirty()
becoming more or less unusable, I’m looking to the “correct” solution to the following problem.
I create a component (ExampleComponent) with an integer variable (exampleInt). I want to create a CustomEditor that has displays a button that increases the exampleInt by one on a per-object basis. (Essentially ++exampleInt.)
What I don’t understand is how to do this correctly using the “new and improved” Editor.serializedObject. As I understand it, SerializedObject.targetObjects returns a read-only list of the target objects, and thus is not intended to be edited? And as far as I can tell there’s no way of getting/setting the individual values of SerializedProperty either?