How to store data for a custom "Manager"

I’d like to make a custom Manager. By that I mean just like there’s an InputManager and a PhysicsManager I want MyCustomManager.

Specifically, just like say PhysicsManager I want to be able to pick something from the menus and have an Inspector panel show up.

I think I know how to do that. Make a custom EditorWindow, give it a MenuItem attribute. Call GetWindow etc.

The part I’m lost on is where do I store my data to show in the inspector? Just like the PhysicsManager the data is not part of any GameObject placed by the user. Just like the PhysicsManger it’s also not EditorPrefs data. I apparently can’t store it on the EditorWindow because it will get released anytime the window closes.

So, where do I put data like that. Do I make an edtior only HideInHierarchy GameObject and put components on it? Where in my code do I make this GameObject? I can’t make it on the EditorWindow because nothing there gets called until the window is opened but the Manager’s data needs to be available regardless. In other words, something in my custom code needs to make this GameObject if it doesn’t already exist.

Assuming I make the GameObject somewhere how do I find it? Do I give it some crazy name like “$$$MyCustomGameObjectToStoreMyDataMadeByMe$$$$” hoping it will never clash with a user’s object so that I can then GameObject.Find(…) it? Or is there some other way of doing what I want here?

You want a ScriptableObject instead of a GameObject. Drop it in a resources folder in your package directory. Then you can access it with Resources.Load whenever you like.

This is only one possible solution. There are others.