UIAnimationEvent.cs 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. using System;
  2. using UnityEngine;
  3. using System.Collections.Generic;
  4. public class UIAnimationEvent : MonoBehaviour
  5. {
  6. private UIBase mBasePage;
  7. public UIBase BasePage
  8. {
  9. get { return mBasePage; }
  10. set { mBasePage = value; }
  11. }
  12. public void ActiveEffect(string effectName)
  13. {
  14. //if (mBasePage == null) {
  15. // Transform effectTrans = transform.Find(effectName);
  16. // if (effectTrans != null) {
  17. // effectTrans.gameObject.SetActive (true);
  18. // Canvas canvas = effectTrans.GetComponentInParent<Canvas> ();
  19. // if (canvas != null)
  20. // EffectUtility.Instance.SetEffectSortingOrder (effectTrans, canvas.sortingOrder + 1);
  21. // }
  22. //}
  23. // else if(!BasePage.ActiveAnimEffect(effectName))
  24. // {
  25. // Transform effectTrans = transform.Find(effectName);
  26. // if (effectTrans != null) {
  27. // effectTrans.gameObject.SetActive (true);
  28. // EffectUtility.Instance.SetEffectSortingOrder (effectTrans, mBasePage.SortingOrder + 1);
  29. // }
  30. // }
  31. }
  32. public void DisActiveEffect(string effectName)
  33. {
  34. //if (mBasePage == null) {
  35. // Transform effectTrans = transform.Find(effectName);
  36. // if (effectTrans != null)
  37. // effectTrans.gameObject.SetActive(false);
  38. //}
  39. // else if (!BasePage.DisActiveAnimEffect(effectName))
  40. // {
  41. // Transform effectTrans = transform.Find(effectName);
  42. // if (effectTrans != null)
  43. // effectTrans.gameObject.SetActive(false);
  44. // }
  45. }
  46. /// <summary>
  47. /// 播放UI声音
  48. /// </summary>
  49. /// <param name="soundName"></param>
  50. public void PlayUISound(string soundName)
  51. {
  52. if (MusicMgr.Instance == null) return;
  53. //MusicMgr.Instance.PlayUISound(soundName, false);
  54. }
  55. /// <summary>
  56. /// 空事件不进行任何处理
  57. /// </summary>
  58. public void EmptyEvent()
  59. {
  60. }
  61. /// <summary>
  62. /// 隐藏自己事件
  63. /// </summary>
  64. public void HideSelf()
  65. {
  66. gameObject.SetActive(false);
  67. }
  68. public void OnAnimCompleted(string pageName)
  69. {
  70. //EventMgr.DispatchEvent<string>(new CoreEvent<string>(ECoreEventType.EID_ANIMATION_COMPLETED, pageName));
  71. if (mBasePage == null) return;
  72. mBasePage.animListener.OnOpenAnimEnd();
  73. }
  74. public void OnCloseAnimCompleted()
  75. {
  76. if (mBasePage == null) return;
  77. mBasePage.animListener.OnCloseAnimEnd();
  78. }
  79. public void OnSubCloseAnimCompleted()
  80. {
  81. if (mBasePage == null) return;
  82. UINode node = GetComponent<UINode>();
  83. if (node == null)
  84. {
  85. return;
  86. }
  87. string path = string.Empty;
  88. node.FindUINodeGOPath(ref path);
  89. mBasePage.animListener.OnSubCloseAnimEnd(path);
  90. }
  91. }