void Awake() { if (instance == null) { instance = this; } else { Destroy(gameObject); } DontDestroyOnLoad(gameObject); }
void Awake() { fuente.clip = clip; // If the instance is not null, then we destroy this gameObject so we // do not have duplicates if (instance != null) { Destroy(gameObject); } // However, if the instance is indeed null, then we asociate it to this // gameObject and we ask Unity to not destroy it on every load. else { instance = this; DontDestroyOnLoad(gameObject); } }
// Start is called before the first frame update void Start() { volumeSlider.value = PlayerPrefsController.GetMasterVolume(); musicPlayer = FindObjectOfType <StartMusic>(); }