UICommonDialog1.cs 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. using FairyGUI;
  2. using System;
  3. using UnityEngine;
  4. namespace ET.Client
  5. {
  6. public class UICommonDialog1
  7. {
  8. public static async ETTask<GComponent> Show(string _title, string _msg, Action okcb, Action cancelcb)
  9. {
  10. var view = await UIHelper.Create("CommonDialog");
  11. var title = view.GetChild("txt_title");
  12. title.text = _title;
  13. var msg = view.GetChild("txt_content");
  14. msg.text = _msg;
  15. if(cancelcb == null)
  16. {
  17. var two = view.GetChild("twobutton");
  18. two.visible = false;
  19. var one = view.GetChild("onebutton");
  20. one.visible = true;
  21. var btn = view.GetChild("btn_ok");
  22. btn.onClick.Add(() =>
  23. {
  24. GRoot.inst.RemoveChild(view);
  25. okcb?.Invoke();
  26. });
  27. }
  28. else
  29. {
  30. var two = view.GetChild("twobutton");
  31. two.visible = true;
  32. var one = view.GetChild("onebutton");
  33. one.visible = false;
  34. var btn = view.GetChild("btn_no");
  35. btn.onClick.Add(() =>
  36. {
  37. GRoot.inst.RemoveChild(view);
  38. cancelcb?.Invoke();
  39. });
  40. btn = view.GetChild("btn_yes");
  41. btn.onClick.Add(() =>
  42. {
  43. GRoot.inst.RemoveChild(view);
  44. okcb?.Invoke();
  45. });
  46. }
  47. return view;
  48. }
  49. }
  50. }