Inheritance: MonoBehaviour
Esempio n. 1
0
    void Awake()
    {
        if (Instance != null && Instance != this) {
            Destroy(gameObject);
            return;
        }

        Instance = this;

        DontDestroyOnLoad (gameObject);
    }
Esempio n. 2
0
 private void Start()
 {
     if (Instance == null)
     {
         Instance = this;
     }
     else if (Instance != this)
     {
         Destroy(gameObject);
     }
     DontDestroyOnLoad(gameObject);
 }
 void Awake()
 {
     if (!instance)
     {
         instance = this;
     }
     else
     {
         Destroy(this.gameObject);
     }
     DontDestroyOnLoad(this.gameObject);
 }
Esempio n. 4
0
 private void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
     else
     {
         Destroy(gameObject);
     }
     DontDestroyOnLoad(gameObject);
 }
Esempio n. 5
0
 void Awake()
 {
     if (Instance == null)
     {
         Instance = this;
     }
     else
     {
         Destroy(this.gameObject);
         return;
     }
 }
 private void Awake()
 {
     if (_instance != null && _instance != this)
     {
         Destroy(this.gameObject);
     }
     else
     {
         _instance = this;
         DontDestroyOnLoad(gameObject);
     }
 }
 void Awake()
 {
     DontDestroyOnLoad(this);
     if (multitonInstance == null)
     {
         multitonInstance = this;
     }
     else
     {
         Destroy(gameObject);
     }
 }
Esempio n. 8
0
 void Awake()
 {
     if (Instance) // PRevents creation of camera clones when loading new level
     {
         Destroy(gameObject);
     }
     else
     {
         DontDestroyOnLoad(gameObject);
         Instance = this;
     }
 }
 private void Awake()
 {
     if (Instance == null)
     {
         Instance = this;
         DontDestroyOnLoad(this);
     }
     else
     {
         Destroy(gameObject);
     }
 }
Esempio n. 10
0
 void Awake()
 {
     if (instance == null)
     {
         instance = this; // In first scene, make us the singleton.
         DontDestroyOnLoad(gameObject);
     }
     else if (instance != this)
     {
         Destroy(gameObject); // On reload, singleton already set, so destroy duplicate.
     }
 }
Esempio n. 11
0
 void Awake()
 {
     if (Instance == null)
     {
         DontDestroyOnLoad(gameObject);
         Instance = this;
     }
     else if (Instance != this)
     {
         Destroy(gameObject);
     }
 }
Esempio n. 12
0
 private void Awake()
 {
     DontDestroyOnLoad(this);
     if (dontDestroy == null)
     {
         dontDestroy = this;
     }
     else
     {
         Destroy(this.gameObject);
     }
 }
Esempio n. 13
0
 public void SetSingleton()
 {
     if (instance == null)
     {
         instance = this;
         DontDestroyOnLoad(this);
     }
     else if (instance != this)
     {
         DestroyImmediate(gameObject);
     }
 }
Esempio n. 14
0
 void Start()
 {
     if (instance == null)
     {
         instance = this;
         DontDestroyOnLoad(gameObject);
     }
     else
     {
         Destroy(gameObject);
     }
 }
 void Awake()
 {
     if (instance != null)
     {
         Destroy(gameObject);
     }
     else
     {
         instance = this;
         GameObject.DontDestroyOnLoad(gameObject);
     }
 }
 void Start()
 {
     if(Instance != null)
     {
         GameObject.Destroy(gameObject);
     }
     else
     {
         DontDestroyOnLoad(gameObject);
         Instance = this;
     }
 }
Esempio n. 17
0
 void Awake()
 {
     if (Instance)
     {
         DestroyImmediate(gameObject);
     }
     else
     {
         DontDestroyOnLoad(gameObject);
         Instance = this;
     }
 }
 private void Awake()
 {
     if (instanceRef == null)
     {
         instanceRef = this;
         DontDestroyOnLoad(gameObject);
     }
     else if (instanceRef != this)
     {
         Destroy(gameObject);
     }
 }
Esempio n. 19
0
 // Start is called before the first frame update
 void Start()
 {
     DontDestroyOnLoad(this);
     if (obj == null)
     {
         obj = GetComponent <DontDestroyOnLoad>();
     }
     else
     {
         Destroy(gameObject);
     }
 }
Esempio n. 20
0
 void Awake()
 {
     if (instance != null && instance != this)
     {
         Destroy(this.gameObject);
         return;
     }
     else
     {
         instance = this;
     }
     DontDestroyOnLoad(this.gameObject);
 }
Esempio n. 21
0
    void Awake()
    {
        DontDestroyOnLoad(this);

        if (dontDestroyOnLoad == null)
        {
            dontDestroyOnLoad = this;
        }
        else
        {
            Destroy(gameObject);
        }
    }
    private void Awake()
    {
        if (Instance != null)
        {
            Debug.Log($"There were multiple Instances of {this} in the scene. Deleting {name}");

            Destroy(gameObject);
            return;
        }

        Instance = this;
        DontDestroyOnLoad(this);
    }
Esempio n. 23
0
 // Use this for initialization
 void Awake()
 {
     if (control == null)
     {
         DontDestroyOnLoad(gameObject);
         control = this;
     }
     else if (control != null)
     {
         Destroy(gameObject);
     }
     DontDestroyChildOnLoad(this.gameObject);
 }
Esempio n. 24
0
 private void Awake()
 {
     if (instance != null)
     {
         Destroy(this.gameObject);
     }
     else
     {
         instance = this;
         transform.SetParent(null);
         DontDestroyOnLoad(gameObject);
     }
 }
Esempio n. 25
0
 protected override void OnAwake()
 {
     if (_instance == null)
     {
         DontDestroyOnLoad(gameObject);
         _instance = this;
     }
     if (_instance == this)
     {
         return;
     }
     Destroy(gameObject);
 }
Esempio n. 26
0
    void Awake()
    {
        DontDestroyOnLoad(this);

        if (gameComponent == null)
        {
            gameComponent = this;
        }
        else
        {
            DestroyImmediate(this);
        }
    }
 // Start is called before the first frame update
 private void Awake()
 {
     if (estadoJuego == null)
     {
         estadoJuego = this;
         DontDestroyOnLoad(gameObject);
         PlayGamesPlatform.Activate();
         PlayGamesPlatform.DebugLogEnabled = false; //OJO desactivar al finalizar
     }
     else if (estadoJuego != this)
     {
         Destroy(gameObject);
     }
 }
Esempio n. 28
0
 void Awake()
 {
     if (!created)
     {
         DontDestroyOnLoad(this.gameObject);
         created   = true;
         thisAudio = this;
     }
     else
     {
         Destroy(this.gameObject);
         thisAudio.Start();
     }
 }
    // Use this for initialization
    void Awake()
    {
        if (instance != null)
        {
            Debug.LogError("Erreur : Il y a plus d'un script DontDestroyOnLoad dans la scène.");
            Destroy(gameObject);
        }
        else
        {
            instance = this;
        }


        DontDestroyOnLoad(gameObject);
    }
Esempio n. 30
0
 //------------------------------------
 private void Awake()
 {
     //para que no haya mas de un audio manager en la escena
     if (instance == null)
     {
         instance = this;
     }
     else
     {
         Destroy(gameObject);
         return;
     }
     //-----------------------------------------------------
     DontDestroyOnLoad(gameObject);
 }
Esempio n. 31
0
 void Awake()
 {
     if (_instance == null)
     {
         _instance = this;
         DontDestroyOnLoad(this);
     }
     else
     {
         if (this != _instance)
         {
             Destroy(this.gameObject);
         }
     }
 }
Esempio n. 32
0
    private void Awake()
    {
        if (instance != null && instance != this)
        {
            Destroy(this.gameObject);
            return;
        }
        else
        {
            instance = this;
        }
        DontDestroyOnLoad(this.gameObject);

        audioSource = GetComponent <AudioSource>();
    }