/// <summary> /// Awake is called when the script instance is being loaded. /// </summary> private void Awake() { if (instance == null) { // This is like a Singleton! instance = this; DontDestroyOnLoad(gameObject); // Literally what it says there PlayOtherMusic(); } else { Destroy(gameObject); } }
private void Start() { persistence = FindObjectOfType <MusicPersistence>(); if (persistence != null) { if (persistence.loop == this.loop.clip) { this.loop.time = persistence.time; } } else { persistence = Instantiate(persistencePrefab); DontDestroyOnLoad(persistence); } }