Custom inspector doesnt hold local static data after play/run the game...

Im getting very miserable times trying to make a custom inspector for an array of arrays (both of my custom class types)

I need to have some constant data that dont change unless the user change the array size manually…
For example, I have an array of booleans that I use to check witch array is collapsed or not…I only change it if use changes the array size…After hiting play all that is lost

Anyway, how can I make the inspector hold all the data ALWAYS? I dont want put edit/auxiliary variables in the inspected object you know…

Did you make the arrays serializable? That means your class types needs to be serializable as well. For C# that means, you need to use [System.Serializable].
Further, do you use something like EditorUtility.SetDirty?

I think you didnt understand exactly, or I didnt what you mean…
Im noting talking about the inspected data, Im talking about the data I create at the custom inspector, solely as auxiliary variables for using on the GUI…
Does that makes more sense now?

You will always loose this kind of data, except if you store it explicitely somehow. There are a lot of possible solutions for that problem.
You created a custom inspector for a certain class. Does each instance of that class need its own “auxiliary” inspector data or do all instances share it?

Each new “component”(thats what you mean by instance ?) of this class type needs its own…The collapsed example is good, its an array of booleans that tells if the arrays(random number) are expanded or hidden( with foldout editor gui)…

Im current using static variables to do this, and at Enable() I recreate the arrays and set everything to false, if I dont I will get access violation because the array is lost after play but inspector will try iterate trough it…

If you want to have the booleans in each component and they should not be lost at all, you need to have them in the component’s script, even if it is not a very elegant solution. As that would increase the runtime memory usage, you could use Platform Dependent Compilation. Meaning you would need #if UNITY_EDITOR around your booleans. Unfortunately I had some issues with that in the past and the bug I found doesn’t seem to be fixed (yet).

Thanks for the tip! ( I forgot this thread )