Exemple #1
0
 void Awake()
 {
     if (self != null && this != self)
     {
         Destroy(this.gameObject);
         return;
     }
     else
     {
         self = this;
         DontDestroyOnLoad(gameObject);
     }
 }
Exemple #2
0
    // Start is called before the first frame update
    void Start()
    {
        DontDestroyOnLoad(this);

        if (obj == null)
        {
            obj = this;
            DontDestroyOnLoad(this);
        }
        else
        {
            Object.Destroy(gameObject);
        }
    }