Modal.cs 1003 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. using UnityEngine;
  2. namespace COM3D2.MeidoPhotoStudio.Plugin
  3. {
  4. internal static class Modal
  5. {
  6. private static BaseWindow currentModal;
  7. public static bool Visible
  8. {
  9. get => currentModal?.Visible ?? false;
  10. set
  11. {
  12. if (currentModal == null) return;
  13. currentModal.Visible = value;
  14. }
  15. }
  16. public static void Show(BaseWindow modalWindow)
  17. {
  18. if (currentModal != null) Close();
  19. currentModal = modalWindow;
  20. Visible = true;
  21. }
  22. public static void Close()
  23. {
  24. Visible = false;
  25. currentModal = null;
  26. }
  27. public static void Draw()
  28. {
  29. GUIStyle windowStyle = new GUIStyle(GUI.skin.box);
  30. currentModal.WindowRect = GUI.ModalWindow(
  31. currentModal.windowID, currentModal.WindowRect, currentModal.GUIFunc, "", windowStyle
  32. );
  33. }
  34. }
  35. }