WatchADFreePanelCtrl.cs 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /// #pkgName FGUI包名
  2. /// #panelName UIPanel名字
  3. /// #UIName = $"{#pkgName}{#panelName}" UIKey名字
  4. /// 该脚本由模板创建
  5. /// created by cb 2024
  6. using FairyGUI;
  7. using System;
  8. using XGame.Framework.UI;
  9. namespace FL.FGUI
  10. {
  11. public class ADParam
  12. {
  13. public string adDesc; // 显示的文本信息描述
  14. public Action onPromiseCallback; //回调函数
  15. }
  16. /// <summary>
  17. /// UI逻辑处理类
  18. /// </summary>
  19. /// <typeparam name=""></typeparam>
  20. public partial class WatchADFreePanelCtrl : UIController<WatchADFreePanelVM>
  21. {
  22. private ADParam _adParam;
  23. protected override void OnEnable(object intent)
  24. {
  25. AddUIListenres();
  26. ShowUI(intent as ADParam);
  27. }
  28. protected override void OnDisable()
  29. {
  30. RemoveUIListenres();
  31. }
  32. #region UI事件
  33. private void AddUIListenres()
  34. {
  35. VM.FreeBtn.onClick.Add(OnClickFreeBtn);
  36. }
  37. private void RemoveUIListenres()
  38. {
  39. VM.FreeBtn.onClick.Remove(OnClickFreeBtn);
  40. }
  41. private void OnClickFreeBtn(EventContext context)
  42. {
  43. if (_adParam?.onPromiseCallback != null)
  44. {
  45. _adParam.onPromiseCallback();
  46. }
  47. Context.ClosePanel();
  48. }
  49. #endregion
  50. private void ShowUI(ADParam adParam)
  51. {
  52. _adParam = adParam;
  53. if (adParam != null)
  54. {
  55. VM.ADLabel.text = adParam.adDesc;
  56. }
  57. }
  58. }
  59. }