void Awake() { if (instance == null) { instance = this; } else { Destroy(gameObject); return; } DontDestroyOnLoad(gameObject); foreach (Sound s in sounds) { s.source = gameObject.AddComponent <AudioSource>(); s.source.clip = s.clip; s.source.volume = s.volume; s.source.pitch = s.pitch; s.source.loop = s.loop; s.source.spatialBlend = s.spatialBlend; s.source.minDistance = s.minDistance; s.source.maxDistance = s.maxDistance; s.source.priority = s.priority; } StartCoroutine("StartStartSceneBackgroundMusic"); }
private void Update() { //This is an incredibly rough workaround that lets the duplicate AudioManager get destroyed before changing the music if (!done) { timer -= Time.deltaTime; if (timer < 0) { done = true; am = FindObjectOfType <AudioManagerController>(); switch (trackName) { case Music.TITLEMUSIC: am.Stop("TutorialMusic"); am.Stop("GameplayMusic"); if (!am.IsPlaying("TitleMusic")) { am.Play("TitleMusic"); } break; case Music.GAMEPLAYMUSIC: am.Stop("TutorialMusic"); am.Stop("TitleMusic"); if (!am.IsPlaying("GameplayMusic")) { am.Play("GameplayMusic"); } break; case Music.TUTORIALMUSIC: am.Stop("TitleMusic"); am.Stop("GameplayMusic"); if (!am.IsPlaying("TutorialMusic")) { am.Play("TutorialMusic"); } break; default: am.Stop("TitleMusic"); am.Stop("GameplayMusic"); am.Stop("TutorialMusic"); break; } } } }
void Awake() { if (instance != null) { Destroy(gameObject); } else { instance = this; DontDestroyOnLoad(gameObject); } foreach (Sound s in soundArray) { s.source = gameObject.AddComponent <AudioSource>(); s.source.clip = s.clip; s.source.name = s.name; s.source.volume = s.volume; s.source.pitch = s.pitch; s.source.loop = s.loop; } }
// Start is called before the first frame update void Start() { AudioManager = GameObject.Find("AudioManager").GetComponent <AudioManagerController>(); SetupGame(); }
// Start is called before the first frame update void Start() { AudioManager = GameObject.Find("AudioManager").GetComponent <AudioManagerController>(); StartCoroutine(LaunchBall()); }
private void Start() { AudioManager = GameObject.Find("AudioManager").GetComponent <AudioManagerController>(); AudioManager.PlaySound(name: "Menu", loopable: true, selfDestruct: false, volume: 0.15f); }