LatticeButton.cs 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using UnityEngine;
  5. using UnityEngine.SceneManagement;
  6. using UnityEngine.UI;
  7. using static UnityEngine.UI.Button;
  8. /// <summary>
  9. /// 晶格操作按钮
  10. /// </summary>
  11. public class LatticeButton : MonoBehaviour
  12. {
  13. public GameObject m_focusObj;
  14. //数字越大 级别越低
  15. public int level = 1;
  16. //数字越大约靠后
  17. public int order = 1;
  18. public Action OnFocus;
  19. public Action OnUnFocus;
  20. public ButtonClickedEvent onClick { get; set; }
  21. public LatticeButton()
  22. {
  23. onClick = new ButtonClickedEvent();
  24. }
  25. void Awake()
  26. {
  27. LatticeBrain.RegButton(this);
  28. if (m_focusObj != null)
  29. {
  30. m_focusObj.SetActive(false);
  31. }
  32. }
  33. void OnDestroy()
  34. {
  35. LatticeBrain.RemoveButton(this);
  36. }
  37. public void MonoFocus()
  38. {
  39. OnFocus?.Invoke();
  40. if (m_focusObj != null)
  41. {
  42. m_focusObj.SetActive(true);
  43. }
  44. }
  45. public void MonoUnFocus()
  46. {
  47. OnUnFocus?.Invoke();
  48. if (m_focusObj != null)
  49. {
  50. m_focusObj.SetActive(false);
  51. }
  52. }
  53. //public bool InFocus
  54. //{
  55. // get
  56. // {
  57. // return m_focusObj
  58. // }
  59. //}
  60. }