WFAnimationConnect.cs 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. using System;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class WFAnimationConnect : MonoBehaviour
  5. {
  6. public void Awake()
  7. {
  8. if (this.ConnectObj != null && 0 < this.ConnectObj.Count)
  9. {
  10. for (int i = 0; i < this.ConnectObj.Count; i++)
  11. {
  12. this.SetAllEnabled(this.ConnectObj[i].gameObject, false);
  13. }
  14. }
  15. }
  16. public void OnEnable()
  17. {
  18. if (this.ConnectObj != null && 0 < this.ConnectObj.Count)
  19. {
  20. for (int i = 0; i < this.ConnectObj.Count; i++)
  21. {
  22. this.SetAllEnabled(this.ConnectObj[i].gameObject, false);
  23. }
  24. }
  25. }
  26. public void OnFinishAnime()
  27. {
  28. if (this.ConnectObj != null && 0 < this.ConnectObj.Count)
  29. {
  30. for (int i = 0; i < this.ConnectObj.Count; i++)
  31. {
  32. this.ConnectObj[i].gameObject.SetActive(true);
  33. }
  34. }
  35. }
  36. private void SetAllEnabled(GameObject obj, bool enabled)
  37. {
  38. if (obj != null)
  39. {
  40. obj.SetActive(enabled);
  41. WFAnimationConnect component = obj.GetComponent<WFAnimationConnect>();
  42. if (component != null && 0 < component.ConnectObj.Count)
  43. {
  44. for (int i = 0; i < component.ConnectObj.Count; i++)
  45. {
  46. this.SetAllEnabled(component.ConnectObj[i].gameObject, enabled);
  47. }
  48. }
  49. }
  50. }
  51. public List<Animator> ConnectObj;
  52. }