Exemple #1
0
    private void Awake()
    {
        DontDestroyOnLoader other = FindObjectOfType <DontDestroyOnLoader>();

        if (other.gameObject != gameObject)
        {
            Destroy(other.gameObject);
        }
    }
Exemple #2
0
 void Start()
 {
     DontDestroyOnLoad(gameObject);
     if (isSingleton)
     {
         if (thisSingleObject == null)
         {
             thisSingleObject = this;
         }
         else if (thisSingleObject != this)
         {
             Destroy(this);
         }
     }
 }