EditOkCancel.cs 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. using System;
  2. using UnityEngine;
  3. public class EditOkCancel : MonoBehaviour
  4. {
  5. private void Awake()
  6. {
  7. this.m_goOk = UTY.GetChildObject(base.gameObject, "Ok", false);
  8. this.m_uiBtnOk = this.m_goOk.GetComponent<UIButton>();
  9. this.m_goCancel = UTY.GetChildObject(base.gameObject, "Cancel", false);
  10. this.m_uiBtnCancel = this.m_goCancel.GetComponent<UIButton>();
  11. this.m_goOk.SetActive(false);
  12. this.m_goCancel.SetActive(false);
  13. EventDelegate.Add(this.m_uiBtnOk.onClick, new EventDelegate.Callback(this.OnClickOk));
  14. EventDelegate.Add(this.m_uiBtnCancel.onClick, new EventDelegate.Callback(this.OnClickCancel));
  15. }
  16. private void Start()
  17. {
  18. }
  19. public void SetOnClickCallBack(EditOkCancel.OnClick f_dgOk, EditOkCancel.OnClick f_dgCancel = null)
  20. {
  21. this.m_dgOnClickOk = f_dgOk;
  22. this.m_dgOnClickCancel = f_dgCancel;
  23. }
  24. public void Show(EditOkCancel.TYPE f_eType)
  25. {
  26. this.m_goOk.SetActive(true);
  27. if (f_eType == EditOkCancel.TYPE.OK_CANCEL)
  28. {
  29. this.m_goCancel.SetActive(true);
  30. }
  31. else
  32. {
  33. this.m_goCancel.SetActive(false);
  34. }
  35. }
  36. public void Close()
  37. {
  38. this.m_goOk.SetActive(false);
  39. this.m_goCancel.SetActive(false);
  40. }
  41. private void OnClickOk()
  42. {
  43. if (this.m_dgOnClickOk != null)
  44. {
  45. this.m_dgOnClickOk();
  46. }
  47. }
  48. private void OnClickCancel()
  49. {
  50. if (this.m_dgOnClickCancel != null)
  51. {
  52. this.m_dgOnClickCancel();
  53. }
  54. }
  55. private void Update()
  56. {
  57. }
  58. private GameObject m_goOk;
  59. private UIButton m_uiBtnOk;
  60. private GameObject m_goCancel;
  61. private UIButton m_uiBtnCancel;
  62. private EditOkCancel.OnClick m_dgOnClickOk;
  63. private EditOkCancel.OnClick m_dgOnClickCancel;
  64. public delegate void OnClick();
  65. public enum TYPE
  66. {
  67. OK,
  68. OK_CANCEL
  69. }
  70. }