SequencerTools GetAudioSource should also check DialogueManager
Posted: Thu Sep 03, 2020 10:58 am
If the subject does not have an AudioSource, don't add a default one without first checking DialogueManager. Doing so means I cannot choose output channel, volume, etc.
Old:
New:
Old:
Code: Select all
public static AudioSource GetAudioSource(Transform subject)
{
GameObject go = (subject != null) ? subject.gameObject : DialogueManager.instance.gameObject;
AudioSource audio = go.GetComponentInChildren<AudioSource>();
return (audio != null) ? audio : go.AddComponent<AudioSource>();
}
Code: Select all
public static AudioSource GetAudioSource(Transform subject)
{
GameObject go = (subject != null) ? subject.gameObject : DialogueManager.instance.gameObject;
AudioSource audio = go.GetComponentInChildren<AudioSource>();
// --------------------------------------------
// KevinJ:
if (audio == null && go != DialogueManager.instance.gameObject)
audio = DialogueManager.instance.gameObject.GetComponentInChildren<AudioSource>();
// --------------------------------------------
return (audio != null) ? audio : go.AddComponent<AudioSource>();
}