//------------------------------------------------------------ // Game Framework // Copyright © 2013-2021 loyalsoft. All rights reserved. // Homepage: http://www.game7000.com/ // Feedback: http://www.game7000.com/ //------------------------------------------------------------ using GameFramework; using GameFramework.Event; using GameFramework.Sound; namespace UnityGameFramework.Runtime { /// /// 播放声音时加载依赖资源事件。 /// public sealed class PlaySoundDependencyAssetEventArgs : GameEventArgs { /// /// 播放声音时加载依赖资源事件编号。 /// public static readonly int EventId = typeof(PlaySoundDependencyAssetEventArgs).GetHashCode(); /// /// 初始化播放声音时加载依赖资源事件的新实例。 /// public PlaySoundDependencyAssetEventArgs() { SerialId = 0; SoundAssetName = null; SoundGroupName = null; PlaySoundParams = null; DependencyAssetName = null; LoadedCount = 0; TotalCount = 0; BindingEntity = null; UserData = null; } /// /// 获取播放声音时加载依赖资源事件编号。 /// public override int Id { get { return EventId; } } /// /// 获取声音的序列编号。 /// public int SerialId { get; private set; } /// /// 获取声音资源名称。 /// public string SoundAssetName { get; private set; } /// /// 获取声音组名称。 /// public string SoundGroupName { get; private set; } /// /// 获取播放声音参数。 /// public PlaySoundParams PlaySoundParams { get; private set; } /// /// 获取被加载的依赖资源名称。 /// public string DependencyAssetName { get; private set; } /// /// 获取当前已加载依赖资源数量。 /// public int LoadedCount { get; private set; } /// /// 获取总共加载依赖资源数量。 /// public int TotalCount { get; private set; } /// /// 获取声音绑定的实体。 /// public Entity BindingEntity { get; private set; } /// /// 获取用户自定义数据。 /// public object UserData { get; private set; } /// /// 创建播放声音时加载依赖资源事件。 /// /// 内部事件。 /// 创建的播放声音时加载依赖资源事件。 public static PlaySoundDependencyAssetEventArgs Create(GameFramework.Sound.PlaySoundDependencyAssetEventArgs e) { PlaySoundInfo playSoundInfo = (PlaySoundInfo)e.UserData; PlaySoundDependencyAssetEventArgs playSoundDependencyAssetEventArgs = ReferencePool.Acquire(); playSoundDependencyAssetEventArgs.SerialId = e.SerialId; playSoundDependencyAssetEventArgs.SoundAssetName = e.SoundAssetName; playSoundDependencyAssetEventArgs.SoundGroupName = e.SoundGroupName; playSoundDependencyAssetEventArgs.PlaySoundParams = e.PlaySoundParams; playSoundDependencyAssetEventArgs.DependencyAssetName = e.DependencyAssetName; playSoundDependencyAssetEventArgs.LoadedCount = e.LoadedCount; playSoundDependencyAssetEventArgs.TotalCount = e.TotalCount; playSoundDependencyAssetEventArgs.BindingEntity = playSoundInfo.BindingEntity; playSoundDependencyAssetEventArgs.UserData = playSoundInfo.UserData; return playSoundDependencyAssetEventArgs; } /// /// 清理播放声音时加载依赖资源事件。 /// public override void Clear() { SerialId = 0; SoundAssetName = null; SoundGroupName = null; PlaySoundParams = null; DependencyAssetName = null; LoadedCount = 0; TotalCount = 0; BindingEntity = null; UserData = null; } } }