示例#1
0
        private void Awake()
        {
            Instance = this;

            foreach (var sound in SoundList)
            {
                if (NameToSound.ContainsKey(sound.name))
                {
                    throw new Exception("error initializing sounds: duplicate sound name in list");
                }
                if (sound.name.IsNullOrEmpty())
                {
                    throw new Exception("error initializing sounds: all sounds must have a name");
                }

                NameToSound.Add(sound.name, sound);
            }

            foreach (var voice in VoiceList)
            {
                if (NameToVoice.ContainsKey(voice.name))
                {
                    throw new Exception("error initializing voice lines: duplicate name in list");
                }
                if (voice.name.IsNullOrEmpty())
                {
                    throw new Exception("error initializing voice lines: all lines must have a name");
                }
            }
        }
示例#2
0
        public static void PlayVoice(string voiceName)
        {
            if (!NameToVoice.ContainsKey(voiceName))
            {
                throw new Exception($"tried to play uninitialized voice line {voiceName}");
            }

            Instance.Play(NameToVoice[voiceName]);
        }