UI.cs 1.0 KB

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