DoNotDestroy object - How to create it no matter which scene loads first?

I’m using a gameobject which calls DoNotDestroyOnLoad to store data needed by multiple scenes, and as long as I create the object in the first scene, everything works as expected. The problem is that during development when I’m loading other scenes, the object doesnt exist yet.

If I include the same object in every scene that just means that I start building up a list of them as none of them are destroyed on scene transitions. I’d like to have some means of checking to see if the object exists, creating it once in the first scene that loads, and then just using that one without creating others in all other scenes. I havent had any luck getting that to work, but I’m sure there must be a way. Help?

Thank you!

Answered my own question, putting this in the intended global class and then including an object with that script in every scene works:

private static Global g;

    void Awake()
    {
        DontDestroyOnLoad(this);

        if (g == null)
            g = this;
        else
            Destroy(gameObject);
    }