Exemplo n.º 1
0
 private void Awake()
 {
     if (instance != null)
     {
         Destroy(this.gameObject);
     }
     else
     {
         instance = this;
         DontDestroyOnLoad(gameObject);
     }
 }
Exemplo n.º 2
0
    private void Start()
    {
        if (instance == null)
        {
            instance = this;
            DontDestroyOnLoad(this.gameObject);
            SceneManager.activeSceneChanged += changeBackgroundAudio;

            audio = GetComponent <AudioSource>();
            // audio.clip=menuBackgroundAudio;
            audio.Play();
        }
        else
        {
            Destroy(this.gameObject);
        }
    }