How to save editor window values after code compile or editor window close?

306 Views Asked by At

I am using Unity UI Toolkit to create an editor window, the problem is when I make a change in the code and unity recompile it, I lose every thing (values) in the editor window. I am using a listview of objectfields and vector3 and toggle elements. How do I save elements values between compiles (or when I close and reopen the editor window)?

1

There are 1 best solutions below

0
Christian Hörath On

The easiest way to store your data inside the editor is to use EditorPrefs.

You can also use ScriptableObjects or Json files like it is shown here.

EditorPrefs are just to store data locally for your editor preferences and are not avaiable at runtime. In the case you need access at runtime you need to go with one of the other two options.