PlaySoundDependencyAssetEventArgs.cs 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. //------------------------------------------------------------
  2. // Game Framework
  3. // Copyright © 2013-2021 loyalsoft. All rights reserved.
  4. // Homepage: http://www.game7000.com/
  5. // Feedback: http://www.game7000.com/
  6. //------------------------------------------------------------
  7. using GameFramework;
  8. using GameFramework.Event;
  9. using GameFramework.Sound;
  10. namespace UnityGameFramework.Runtime
  11. {
  12. /// <summary>
  13. /// 播放声音时加载依赖资源事件。
  14. /// </summary>
  15. public sealed class PlaySoundDependencyAssetEventArgs : GameEventArgs
  16. {
  17. /// <summary>
  18. /// 播放声音时加载依赖资源事件编号。
  19. /// </summary>
  20. public static readonly int EventId = typeof(PlaySoundDependencyAssetEventArgs).GetHashCode();
  21. /// <summary>
  22. /// 初始化播放声音时加载依赖资源事件的新实例。
  23. /// </summary>
  24. public PlaySoundDependencyAssetEventArgs()
  25. {
  26. SerialId = 0;
  27. SoundAssetName = null;
  28. SoundGroupName = null;
  29. PlaySoundParams = null;
  30. DependencyAssetName = null;
  31. LoadedCount = 0;
  32. TotalCount = 0;
  33. BindingEntity = null;
  34. UserData = null;
  35. }
  36. /// <summary>
  37. /// 获取播放声音时加载依赖资源事件编号。
  38. /// </summary>
  39. public override int Id
  40. {
  41. get
  42. {
  43. return EventId;
  44. }
  45. }
  46. /// <summary>
  47. /// 获取声音的序列编号。
  48. /// </summary>
  49. public int SerialId
  50. {
  51. get;
  52. private set;
  53. }
  54. /// <summary>
  55. /// 获取声音资源名称。
  56. /// </summary>
  57. public string SoundAssetName
  58. {
  59. get;
  60. private set;
  61. }
  62. /// <summary>
  63. /// 获取声音组名称。
  64. /// </summary>
  65. public string SoundGroupName
  66. {
  67. get;
  68. private set;
  69. }
  70. /// <summary>
  71. /// 获取播放声音参数。
  72. /// </summary>
  73. public PlaySoundParams PlaySoundParams
  74. {
  75. get;
  76. private set;
  77. }
  78. /// <summary>
  79. /// 获取被加载的依赖资源名称。
  80. /// </summary>
  81. public string DependencyAssetName
  82. {
  83. get;
  84. private set;
  85. }
  86. /// <summary>
  87. /// 获取当前已加载依赖资源数量。
  88. /// </summary>
  89. public int LoadedCount
  90. {
  91. get;
  92. private set;
  93. }
  94. /// <summary>
  95. /// 获取总共加载依赖资源数量。
  96. /// </summary>
  97. public int TotalCount
  98. {
  99. get;
  100. private set;
  101. }
  102. /// <summary>
  103. /// 获取声音绑定的实体。
  104. /// </summary>
  105. public Entity BindingEntity
  106. {
  107. get;
  108. private set;
  109. }
  110. /// <summary>
  111. /// 获取用户自定义数据。
  112. /// </summary>
  113. public object UserData
  114. {
  115. get;
  116. private set;
  117. }
  118. /// <summary>
  119. /// 创建播放声音时加载依赖资源事件。
  120. /// </summary>
  121. /// <param name="e">内部事件。</param>
  122. /// <returns>创建的播放声音时加载依赖资源事件。</returns>
  123. public static PlaySoundDependencyAssetEventArgs Create(GameFramework.Sound.PlaySoundDependencyAssetEventArgs e)
  124. {
  125. PlaySoundInfo playSoundInfo = (PlaySoundInfo)e.UserData;
  126. PlaySoundDependencyAssetEventArgs playSoundDependencyAssetEventArgs = ReferencePool.Acquire<PlaySoundDependencyAssetEventArgs>();
  127. playSoundDependencyAssetEventArgs.SerialId = e.SerialId;
  128. playSoundDependencyAssetEventArgs.SoundAssetName = e.SoundAssetName;
  129. playSoundDependencyAssetEventArgs.SoundGroupName = e.SoundGroupName;
  130. playSoundDependencyAssetEventArgs.PlaySoundParams = e.PlaySoundParams;
  131. playSoundDependencyAssetEventArgs.DependencyAssetName = e.DependencyAssetName;
  132. playSoundDependencyAssetEventArgs.LoadedCount = e.LoadedCount;
  133. playSoundDependencyAssetEventArgs.TotalCount = e.TotalCount;
  134. playSoundDependencyAssetEventArgs.BindingEntity = playSoundInfo.BindingEntity;
  135. playSoundDependencyAssetEventArgs.UserData = playSoundInfo.UserData;
  136. return playSoundDependencyAssetEventArgs;
  137. }
  138. /// <summary>
  139. /// 清理播放声音时加载依赖资源事件。
  140. /// </summary>
  141. public override void Clear()
  142. {
  143. SerialId = 0;
  144. SoundAssetName = null;
  145. SoundGroupName = null;
  146. PlaySoundParams = null;
  147. DependencyAssetName = null;
  148. LoadedCount = 0;
  149. TotalCount = 0;
  150. BindingEntity = null;
  151. UserData = null;
  152. }
  153. }
  154. }