Is it possible to return a boolean value if there is a GameObject in DontDestroyOnLoad and if so how? [ANSWERED]

So im creating a game and i have a glitch where it spawns new GameObjects while there are GameObjects im using in a DontDestroyOnLoad state.
I thought of an solution and i want to check if there is a GameObject in DontDestroyOnLoad and if so i do not need to spawn new GameObjects.
Even a answer with only one word is apreciated :slight_smile: Thanks beforehand!!

I would make a wrapper for GameObject.DontDestroyOnLoad and then have it make a list of the object that you pass it.

public class DontDestroyOnLoadWrapper
{
    public static List<GameObject> list = new List<GameObject>();

    public static bool ContainsObjectType(GameObject obj){
        /// Some how check against the prefab or something that the gmae object you are spawning
    }

    public static void AddObject(GameObject obj)
    {
        if (!list.Contains(obj))
        {
            list.Add(obj);
            GameObject.DontDestroyOnLoad(obj);
        }
    }
}

Or make it a singleton like

public class DontDestroyObject : MonoBehaviour
{
    public static DontDestroyObject Instance;

    void Start()
    {
        if (Instance != null)
           GameObject.Destroy(gameObject);
        else
        {
            Instance = this;
            GameObject.DontDestroyOnLoad(gameObject);
        }
    }
}