Inheritance: MonoBehaviour
コード例 #1
0
    void Awake()
    {
        if (Instance != null && Instance != this) {
            Destroy(gameObject);
            return;
        }

        Instance = this;

        DontDestroyOnLoad (gameObject);
    }
コード例 #2
0
 private void Start()
 {
     if (Instance == null)
     {
         Instance = this;
     }
     else if (Instance != this)
     {
         Destroy(gameObject);
     }
     DontDestroyOnLoad(gameObject);
 }
コード例 #3
0
 void Awake()
 {
     if (!instance)
     {
         instance = this;
     }
     else
     {
         Destroy(this.gameObject);
     }
     DontDestroyOnLoad(this.gameObject);
 }
コード例 #4
0
 private void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
     else
     {
         Destroy(gameObject);
     }
     DontDestroyOnLoad(gameObject);
 }
コード例 #5
0
 void Awake()
 {
     if (Instance == null)
     {
         Instance = this;
     }
     else
     {
         Destroy(this.gameObject);
         return;
     }
 }
コード例 #6
0
 private void Awake()
 {
     if (_instance != null && _instance != this)
     {
         Destroy(this.gameObject);
     }
     else
     {
         _instance = this;
         DontDestroyOnLoad(gameObject);
     }
 }
コード例 #7
0
 void Awake()
 {
     DontDestroyOnLoad(this);
     if (multitonInstance == null)
     {
         multitonInstance = this;
     }
     else
     {
         Destroy(gameObject);
     }
 }
コード例 #8
0
 void Awake()
 {
     if (Instance) // PRevents creation of camera clones when loading new level
     {
         Destroy(gameObject);
     }
     else
     {
         DontDestroyOnLoad(gameObject);
         Instance = this;
     }
 }
コード例 #9
0
 private void Awake()
 {
     if (Instance == null)
     {
         Instance = this;
         DontDestroyOnLoad(this);
     }
     else
     {
         Destroy(gameObject);
     }
 }
コード例 #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.
     }
 }
コード例 #11
0
 void Awake()
 {
     if (Instance == null)
     {
         DontDestroyOnLoad(gameObject);
         Instance = this;
     }
     else if (Instance != this)
     {
         Destroy(gameObject);
     }
 }
コード例 #12
0
 private void Awake()
 {
     DontDestroyOnLoad(this);
     if (dontDestroy == null)
     {
         dontDestroy = this;
     }
     else
     {
         Destroy(this.gameObject);
     }
 }
コード例 #13
0
 public void SetSingleton()
 {
     if (instance == null)
     {
         instance = this;
         DontDestroyOnLoad(this);
     }
     else if (instance != this)
     {
         DestroyImmediate(gameObject);
     }
 }
コード例 #14
0
 void Start()
 {
     if (instance == null)
     {
         instance = this;
         DontDestroyOnLoad(gameObject);
     }
     else
     {
         Destroy(gameObject);
     }
 }
コード例 #15
0
 void Awake()
 {
     if (instance != null)
     {
         Destroy(gameObject);
     }
     else
     {
         instance = this;
         GameObject.DontDestroyOnLoad(gameObject);
     }
 }
コード例 #16
0
 void Start()
 {
     if(Instance != null)
     {
         GameObject.Destroy(gameObject);
     }
     else
     {
         DontDestroyOnLoad(gameObject);
         Instance = this;
     }
 }
コード例 #17
0
 void Awake()
 {
     if (Instance)
     {
         DestroyImmediate(gameObject);
     }
     else
     {
         DontDestroyOnLoad(gameObject);
         Instance = this;
     }
 }
コード例 #18
0
 private void Awake()
 {
     if (instanceRef == null)
     {
         instanceRef = this;
         DontDestroyOnLoad(gameObject);
     }
     else if (instanceRef != this)
     {
         Destroy(gameObject);
     }
 }
コード例 #19
0
 // Start is called before the first frame update
 void Start()
 {
     DontDestroyOnLoad(this);
     if (obj == null)
     {
         obj = GetComponent <DontDestroyOnLoad>();
     }
     else
     {
         Destroy(gameObject);
     }
 }
コード例 #20
0
ファイル: DontDestroyOnLoad.cs プロジェクト: pgod/Cube-Escape
 void Awake()
 {
     if (instance != null && instance != this)
     {
         Destroy(this.gameObject);
         return;
     }
     else
     {
         instance = this;
     }
     DontDestroyOnLoad(this.gameObject);
 }
コード例 #21
0
    void Awake()
    {
        DontDestroyOnLoad(this);

        if (dontDestroyOnLoad == null)
        {
            dontDestroyOnLoad = this;
        }
        else
        {
            Destroy(gameObject);
        }
    }
コード例 #22
0
    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);
    }
コード例 #23
0
ファイル: DontDestroyOnLoad.cs プロジェクト: MikiMina0/TestRS
 // Use this for initialization
 void Awake()
 {
     if (control == null)
     {
         DontDestroyOnLoad(gameObject);
         control = this;
     }
     else if (control != null)
     {
         Destroy(gameObject);
     }
     DontDestroyChildOnLoad(this.gameObject);
 }
コード例 #24
0
 private void Awake()
 {
     if (instance != null)
     {
         Destroy(this.gameObject);
     }
     else
     {
         instance = this;
         transform.SetParent(null);
         DontDestroyOnLoad(gameObject);
     }
 }
コード例 #25
0
 protected override void OnAwake()
 {
     if (_instance == null)
     {
         DontDestroyOnLoad(gameObject);
         _instance = this;
     }
     if (_instance == this)
     {
         return;
     }
     Destroy(gameObject);
 }
コード例 #26
0
    void Awake()
    {
        DontDestroyOnLoad(this);

        if (gameComponent == null)
        {
            gameComponent = this;
        }
        else
        {
            DestroyImmediate(this);
        }
    }
コード例 #27
0
 // 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);
     }
 }
コード例 #28
0
 void Awake()
 {
     if (!created)
     {
         DontDestroyOnLoad(this.gameObject);
         created   = true;
         thisAudio = this;
     }
     else
     {
         Destroy(this.gameObject);
         thisAudio.Start();
     }
 }
コード例 #29
0
    // 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);
    }
コード例 #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);
 }
コード例 #31
0
 void Awake()
 {
     if (_instance == null)
     {
         _instance = this;
         DontDestroyOnLoad(this);
     }
     else
     {
         if (this != _instance)
         {
             Destroy(this.gameObject);
         }
     }
 }
コード例 #32
0
    private void Awake()
    {
        if (instance != null && instance != this)
        {
            Destroy(this.gameObject);
            return;
        }
        else
        {
            instance = this;
        }
        DontDestroyOnLoad(this.gameObject);

        audioSource = GetComponent <AudioSource>();
    }