How do I hook up persistent editor extension data to the editor startup?

I want to create a simple editor extension. I consists of only of a few buttons in the Window tab via the [MenuAttribute(string itemName)]. The buttons should be “check-able”, representing boolean data. It works - that is not the problem. But how do I save that data on a per project basis (I could figure out a way, but maybe there is some pre-built functionality for this) and more importantly: How do I set those values visually based on the saved data on editor startup?

Usually you create a ScriptableObject asset in the project and use that to store/retrieve your data.

1 Like

OK cool that solves the “per project data” issue - thanks.

But I still don’t know how I can cause my data being loaded when the editor is started :frowning:

No one? I cannot find any documentation on this and I’ve tried a lot of approaches…

Not sure what you didn’t get about the Scriptable Object part. The Scriptable Object is is where you store your data, as the data will persist through editor sessions, and even between entering/exiting playmode. There’s a number of ways you get the data out, such as using Unity’s EDITOR ONLY Scriptable Object singleton class: Unity - Scripting API: ScriptableSingleton<T0>

The problem for me is not saving the data (I can think of numerous ways of doing it by hand), the problem is retrieving it at editor startup.
So let’s just assume that my IQ’s at about 60 for a second and given that premise, post a script that…

  1. Has a MenuItem “MyMenu” with a sub-item “MyBool” that’s check-able
  2. The sub-item should be set to true at editor start-up (I actually don’t want to save any state to disk, I want to read out a file and based on the content of it, set the check-able sub-menu to true or false - a simple function that set’s it to true should be enough to make me get it)

I’ve tried the SriptableSingleton using its’ Awake method but nothing’s happened. Do I need to create some kind of special asset instance in the project’s folder first or not? …If the SO approach is even appropriate.

7540079--931376--5ozu8i.jpg