Beispiel #1
0
 protected void OnDestroy()
 {
     if (instance == this)
     {
         instance = null;
     }
 }
Beispiel #2
0
    protected void Awake()
    {
        if (instance != null)
        {
            //NOTE: In a build, this will be called for every scene change.
            //      In the editor, the scene postprocessor will only run for
            //      for the currently loaded level (and reloading it will
            //      lose the preprocessing, it seems), so it will never get
            //      here.
            Debug.Log("MainCaller already exists");

            Destroy(gameObject);
            return;
        }

        DontDestroyOnLoad(gameObject);

        instance = this;
    }