void LoadSoundAssetSuccess(string path, object[] userdata, AudioClip audioAsset, OnAssetDestory onDestory) { int soundId = (int)userdata[0]; SoundTableSetting soundTable = (SoundTableSetting)userdata[1]; SoundGroup soundGroup = dicSoundGroups[soundTable.Group]; PlaySoundParams soundParams = new PlaySoundParams(); soundParams.Time = soundTable.Time; soundParams.MuteInSoundGroup = Constant.DefaultMute; soundParams.Loop = soundTable.Loop; soundParams.Priority = soundTable.Priority; soundParams.VolumeInSoundGroup = Constant.DefaultVolume; soundParams.FadeInSeconds = soundTable.FadeInSeconds; soundParams.FadeOutSeconds = soundTable.FadeOutSeconds; soundParams.Pitch = soundTable.Pitch; soundParams.PanStereo = soundTable.PanStereo; soundParams.SpatialBlend = soundTable.SpatialBlend; soundParams.MaxDistance = soundTable.MaxDistance; PlaySoundErrorCode?errCode; soundGroup.PlaySound(soundId, audioAsset, soundParams, onDestory, out errCode); if (errCode != null) { Debug.LogError(soundId + " PlaySoundErrorCode=>" + errCode.ToString()); } }
protected void LoadSceneSuccess(string path, object[] args, OnAssetDestory onAssetDestory) { if (lastSceneDestory != null) { lastSceneDestory(); } loadState = LoadState.ClearMemery; lastSceneDestory = onAssetDestory; }
void LoadCallback(string path, object[] args, Texture2D texture, OnAssetDestory destory) { mainTexture = texture; if (assetDestory != null) { assetDestory(); } assetDestory = destory; }
public bool SetSoundAsset(object soundAsset, OnAssetDestory onAssetDestory) { Reset(); m_SoundAsset = soundAsset; m_SetSoundAssetTime = DateTime.Now; AudioClip audioClip = soundAsset as AudioClip; if (audioClip == null) { return(false); } this.onAssetDestory = onAssetDestory; m_AudioSource.clip = audioClip; return(true); }
public void LoadDependenceSuccess(string path, object[] userData, Object loader, OnAssetDestory onDestory) { dicDependenceOnDestory.Add(path, onDestory); bool loadDenpendenceEnd = true; foreach (var item in dicDependenceLoader) { if (item.Value.LoadState < AssetLoadState.Loaded) { loadDenpendenceEnd = false; } } if (loadDenpendenceEnd) { LoadState = AssetLoadState.LoadDenpendenceSuccess; } }
/// <summary> /// 播放声音。 /// </summary> /// <param name="serialId">声音的序列编号。</param> /// <param name="soundAsset">声音资源。</param> /// <param name="playSoundParams">播放声音参数。</param> /// <param name="onDestory">销毁资源的操作</param> /// <param name="errorCode">错误码。</param> /// <returns>用于播放的声音代理。</returns> public ISoundAgent PlaySound(int serialId, object soundAsset, PlaySoundParams playSoundParams, OnAssetDestory onDestory, out PlaySoundErrorCode?errorCode) { errorCode = null; SoundAgent candidateAgent = null; foreach (SoundAgent soundAgent in m_SoundAgents) { if (!soundAgent.IsPlaying) { candidateAgent = soundAgent; break; } if (soundAgent.Priority < playSoundParams.Priority) { if (candidateAgent == null || soundAgent.Priority < candidateAgent.Priority) { candidateAgent = soundAgent; } } else if (!m_AvoidBeingReplacedBySamePriority && soundAgent.Priority == playSoundParams.Priority) { if (candidateAgent == null || soundAgent.SetSoundAssetTime < candidateAgent.SetSoundAssetTime) { candidateAgent = soundAgent; } } } if (candidateAgent == null) { errorCode = PlaySoundErrorCode.IgnoredDueToLowPriority; return(null); } if (!candidateAgent.SetSoundAsset(soundAsset, onDestory)) { errorCode = PlaySoundErrorCode.SetSoundAssetFailure; return(null); } candidateAgent.SerialId = serialId; candidateAgent.Time = playSoundParams.Time; candidateAgent.MuteInSoundGroup = playSoundParams.MuteInSoundGroup; candidateAgent.Loop = playSoundParams.Loop; candidateAgent.Priority = playSoundParams.Priority; candidateAgent.VolumeInSoundGroup = playSoundParams.VolumeInSoundGroup; candidateAgent.Pitch = playSoundParams.Pitch; candidateAgent.PanStereo = playSoundParams.PanStereo; candidateAgent.SpatialBlend = playSoundParams.SpatialBlend; candidateAgent.MaxDistance = playSoundParams.MaxDistance; candidateAgent.Play(playSoundParams.FadeInSeconds); return(candidateAgent); }
public void Init(OnAssetDestory destory) { this.destory = destory; }