UI.cs 953 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. using UnityEngine;
  2. namespace MeidoPhotoStudio.Converter;
  3. public class UI
  4. {
  5. public bool Visible;
  6. private const int WindowID = 0xEA4040;
  7. private const string WindowTitle = Plugin.PluginName + " " + Plugin.PluginVersion;
  8. private readonly PluginCore core;
  9. private Rect windowRect;
  10. public UI(PluginCore pluginCore) =>
  11. core = pluginCore;
  12. public void Draw()
  13. {
  14. if (!Visible)
  15. return;
  16. windowRect.width = 230f;
  17. windowRect.height = 100f;
  18. windowRect.x = Mathf.Clamp(windowRect.x, 0, Screen.width - windowRect.width);
  19. windowRect.y = Mathf.Clamp(windowRect.y, 0, Screen.height - windowRect.height);
  20. windowRect = GUI.Window(WindowID, windowRect, GUIFunc, WindowTitle);
  21. }
  22. private void GUIFunc(int windowId)
  23. {
  24. GUILayout.FlexibleSpace();
  25. if (GUILayout.Button("Convert"))
  26. core.Convert();
  27. GUI.DragWindow();
  28. }
  29. }