public void Start()
 {
     if (instance != null)
     {
         Destroy(this.gameObject);
         return;
     }
     instance = this;
     GameObject.DontDestroyOnLoad(this.gameObject);
     if (music.isPlaying)
     {
         return;
     }
     music.Play();
 }
Ejemplo n.º 2
0
    // Use this for initialization
    void Awake()
    {
        DontDestroyOnLoad(this);

        if (MusicInstance == null)
        {
            MusicInstance = this;
            Debug.Log("Background music instance set");
        }
        else
        {
            Debug.Log("destroyed");
            Destroy(this.gameObject);
            return;
        }
    }
    private void Awake()
    {
        #region Make Singleton
        //Check if instance already exists
        if (instance == null)
        {
            //if not, set instance to this
            instance = this;
        }

        //If instance already exists and it's not this:
        else if (instance != this)
        {
            //Then destroy this. This enforces our singleton pattern, meaning there can only ever be one instance of a GameManager.
            Destroy(gameObject);
        }

        //Sets this to not be destroyed when reloading scene
        DontDestroyOnLoad(gameObject);
        #endregion
    }
 void Start()
 {
     spawnPoint = GameObject.Find("SpawnPointHolder").GetComponent<DontDestroyScript>();
     fire = platform.transform.Find("Torch/Fire").particleSystem;
 }
 private void Awake()
 {
     dontDestroy = GameObject.Find("DontDestroyObj").GetComponent <DontDestroyScript>();
 }