UICommonDialog1.cs 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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. Log.Debug("show dialog1.");
  11. var view = await UIHelper.Create("CommonDialog");
  12. var title = view.GetChild("txt_title");
  13. title.text = _title;
  14. var msg = view.GetChild("txt_content");
  15. msg.text = _msg;
  16. if(cancelcb == null)
  17. {
  18. var two = view.GetChild("twobutton");
  19. two.visible = false;
  20. var one = view.GetChild("onebutton");
  21. one.visible = true;
  22. var btn = view.GetChild("btn_ok");
  23. btn.onClick.Add(() =>
  24. {
  25. GRoot.inst.RemoveChild(view);
  26. okcb?.Invoke();
  27. });
  28. }
  29. else
  30. {
  31. var two = view.GetChild("twobutton");
  32. two.visible = true;
  33. var one = view.GetChild("onebutton");
  34. one.visible = false;
  35. var btn = view.GetChild("btn_no");
  36. btn.onClick.Add(() =>
  37. {
  38. GRoot.inst.RemoveChild(view);
  39. cancelcb?.Invoke();
  40. });
  41. btn = view.GetChild("btn_yes");
  42. btn.onClick.Add(() =>
  43. {
  44. GRoot.inst.RemoveChild(view);
  45. okcb?.Invoke();
  46. });
  47. }
  48. return view;
  49. }
  50. }
  51. }