Statics in Custom Editor

Hi Guys,

I’m trying to create a Dungeon Builder which will be in it’s own window and display a list of available assets to place in the scene, as this is going to have to be available in each scene I’m hoping to make it static and retain the GameObjects placed in which are available (depending on the scene being create), obviously there will be a lot of other stuff going on too so it’ll make sense to be able to specify these and not just use different folder.

At the moment I can’t even get the list of strings to remain in between running and closing or reopening the editor. I’ve attempted using Serializable, SerializeField, and a few other combinations all with now luck thus far.

Is this the right way to go about what I’m trying to achieve and how should I go about it or is there something else I’m missing which will solve this for me?

Thanks in advance!

Statics don’t serialize in Unity. You will have to use ScriptableObjects (or alternatively MonoBehaviours, depending on what you’re trying to achieve).

Have a MonoBehaviour (which is on a gameobject saved in the scene) reference a ScriptableObject and operate on the ScriptableObject. Then everything should serialize. If you need this behavior to be different (maybe different assets shown in different scenes…) then create a separate GO in each scene, otherwise it would be wiser to make a prefab which you assign to each scene.