/// <summary> /// 增加声音代理辅助器 /// </summary> /// <param name="soundGroupName">声音组名称</param> /// <param name="soundAgentHelper">要增加的声音代理辅助器</param> public void AddSoundAgentHelper(string soundGroupName, SoundAgentHelper soundAgentHelper) { SoundGroup soundGroup = GetSoundGroup(soundGroupName); if (soundGroup == null) { throw new Exception(string.Format("Sound group '{0}' is not exist.", soundGroupName)); } soundGroup.AddSoundAgentHelper(soundAgentHelper); }
/// <summary> /// 初始化声音代理的新实例 /// </summary> /// <param name="soundGroup">所在的声音组</param> /// <param name="soundHelper">声音辅助器接口</param> /// <param name="soundAgentHelper">声音代理辅助器接口</param> public SoundAgent(SoundGroup soundGroup, SoundAgentHelper soundAgentHelper) { if (soundGroup == null) { throw new Exception("Sound group is invalid."); } if (soundAgentHelper == null) { throw new Exception("Sound agent helper is invalid."); } m_SoundGroup = soundGroup; m_SoundAgentHelper = soundAgentHelper; m_SoundAgentHelper.ResetSoundAgent += OnResetSoundAgent; m_SerialId = 0; m_SoundAsset = null; Reset(); }
private void OnPlaySoundSuccess(int serialId, string soundAssetName, SoundAgent soundAgent, float duration, object userData) { PlaySoundInfo playSoundInfo = (PlaySoundInfo)userData; if (playSoundInfo != null) { SoundAgentHelper soundAgentHelper = soundAgent.Helper; if (playSoundInfo.BindingEntity != null) { soundAgentHelper.SetBindingEntity(playSoundInfo.BindingEntity); } else { soundAgentHelper.SetWorldPosition(playSoundInfo.WorldPosition); } } if (m_EnablePlaySoundSuccessEvent) { Debug.Log("声音播放成功事件"); } }
/// <summary> /// 增加声音代理辅助器 /// </summary> /// <param name="soundHelper">声音辅助器接口</param> /// <param name="soundAgentHelper">要增加的声音代理辅助器</param> public void AddSoundAgentHelper(SoundAgentHelper soundAgentHelper) { m_SoundAgents.Add(new SoundAgent(this, soundAgentHelper)); }