SUIPanelTips.cs 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. namespace SFramework
  5. {
  6. public class SUIPanelTips : SUIObjectBase
  7. {
  8. private GameObject _textTitle;
  9. private GameObject _textInfo;
  10. System.Action _clickYesCallBack;
  11. System.Action _clickNoCallBack;
  12. public override void UI_Awake()
  13. {
  14. Debug.Log("SUIPanelTips -> Awake()");
  15. GameObject rootCanvas = GameObject.Find("Canvas_Update(Clone)");
  16. Debug.Assert(rootCanvas != null);
  17. _rootPanel = rootCanvas.transform.Find("Panel_Tips").gameObject;
  18. Debug.Assert(_rootPanel != null);
  19. _textTitle = GetSubUI("Text_Title");
  20. _textInfo = GetSubUI("Text_Info");
  21. _rootPanel.SetActive(false);
  22. }
  23. public override void UI_Start()
  24. {
  25. }
  26. public override void UI_RefreshInfo()
  27. {
  28. _textTitle.GetComponent<UnityEngine.UI.Text>().text = "UpdateTips";
  29. _textInfo.GetComponent<UnityEngine.UI.Text>().text = "Prepare For Update.";
  30. }
  31. public override void UI_BindTouchEvent()
  32. {
  33. BindButtonClick("Button_Yes", onClickButtonYes);
  34. BindButtonClick("Button_No", onClickButtonNo);
  35. }
  36. private void onClickButtonYes(GameObject buttonObject)
  37. {
  38. Debug.Log("SUIPanelTips -> onClickButtonYes");
  39. _rootPanel.SetActive(false);
  40. if (_clickYesCallBack != null)
  41. {
  42. _clickYesCallBack();
  43. _clickYesCallBack = null;
  44. }
  45. }
  46. private void onClickButtonNo(GameObject buttonObject)
  47. {
  48. Debug.Log("SUIPanelTips -> onClickButtonNo");
  49. _rootPanel.SetActive(false);
  50. if (_clickNoCallBack != null)
  51. {
  52. _clickNoCallBack();
  53. _clickNoCallBack = null;
  54. }
  55. }
  56. public void ShowTips(string tipsTitle, string tipsInfo, System.Action yesAction, System.Action noAction)
  57. {
  58. _rootPanel.SetActive(true);
  59. _textTitle.GetComponent<UnityEngine.UI.Text>().text = tipsTitle;
  60. _textInfo.GetComponent<UnityEngine.UI.Text>().text = tipsInfo;
  61. _clickYesCallBack = yesAction;
  62. _clickNoCallBack = noAction;
  63. }
  64. }
  65. }