void Awake() { if (instance == null) //Make AudioManager a singleton { instance = this; } else { Destroy(gameObject); return; } //DontDestroyOnLoad(gameObject); if (musicMixerGroup == null || effectsMixerGroup == null) { Debug.LogError("Sound mixer groups not set"); } foreach (Sound sound in sounds) { sound.source = gameObject.AddComponent <AudioSource>(); sound.source.clip = sound.clip; sound.source.volume = sound.volume; sound.source.pitch = sound.pitch; sound.source.loop = sound.loop; sound.source.playOnAwake = sound.playOnAwake; if (sound.soundType == SoundType.Effect) { sound.source.outputAudioMixerGroup = effectsMixerGroup; } if (sound.soundType == SoundType.Music) { sound.source.outputAudioMixerGroup = musicMixerGroup; } if (sound.playOnAwake && !muteSounds) { sound.source.Play(); } } }
void FindMightyReferences() { MightyUIManager[] UIManagers = FindObjectsOfType <MightyUIManager>(); if (UIManagers.Length > 1) { Debug.LogError("There can be only one MightyUIManager at a time"); } else { UIManager = UIManagers[0]; } MightyAudioManager[] audioManagers = FindObjectsOfType <MightyAudioManager>(); if (UIManagers.Length > 1) { Debug.LogError("There can be only one MightyAudioManager at a time"); } else { audioManager = audioManagers[0]; } MightyParticleEffectsManager[] particleEffectsManagers = FindObjectsOfType <MightyParticleEffectsManager>(); if (UIManagers.Length > 1) { Debug.LogError("There can be only one MightyParticleEffectsManager at a time"); } else { particleEffectsManager = particleEffectsManagers[0]; } MightyTimersManager[] timersUIManagers = FindObjectsOfType <MightyTimersManager>(); if (UIManagers.Length > 1) { Debug.LogError("There can be only one MightyTimersManager at a time"); } else { timersManager = timersUIManagers[0]; } }