/// <summary> /// 处理自动播放音效 /// </summary> /// <param name="audio"></param> void OnPlayAuto(AudioSystem.AudioType audio) { if (debugEnable) { Debug.Log("AudioMage.OnPlayAuto," + audio); } if (audio == AudioSystem.AudioType.AUDIO_NONE) { return; } int audioIndex = (int)audio; if (AudioClips[audioIndex] != null) { bool bPlayed = false; for (int i = 0; i < AutoSources.Length; i++) { if (!AutoSources[i].isPlaying) { AutoSources[i].clip = AudioClips[audioIndex]; AutoSources[i].loop = false; AutoSources[i].Play(); bPlayed = true; break; } } if (!bPlayed) { DEBUG.Audio("AudioType " + audio + " is not played. All AutoSources are used. ", LogType.Warning); for (int i = 0; i < AutoSources.Length; i++) { DEBUG.Audio("AudioType " + AutoSources[i].clip.name, LogType.Warning); } } } else { DEBUG.Audio("AudioType " + audio + " is null", LogType.Warning); } }