MiscGUI.cs 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. using UnityEngine;
  2. namespace COM3D2.MeidoPhotoStudio.Plugin
  3. {
  4. internal static class MiscGUI
  5. {
  6. public static readonly GUILayoutOption HalfSlider = GUILayout.Width(98);
  7. public static readonly Texture2D white = Utility.MakeTex(2, 2, Color.white);
  8. public static readonly Texture2D transparentBlack = Utility.MakeTex(2, 2, new Color(0f, 0f, 0f, 0.8f));
  9. private static GUIStyle lineStyleWhite;
  10. private static GUIStyle lineStyleBlack;
  11. private static GUIStyle textureBoxStyle;
  12. static MiscGUI()
  13. {
  14. lineStyleWhite = new GUIStyle(GUI.skin.box);
  15. lineStyleWhite.padding = lineStyleWhite.border = new RectOffset(0, 0, 1, 1);
  16. lineStyleWhite.margin = new RectOffset(0, 0, 8, 8);
  17. lineStyleWhite.normal.background = Utility.MakeTex(2, 2, new Color(1f, 1f, 1f, 0.2f));
  18. lineStyleBlack = new GUIStyle(lineStyleWhite);
  19. lineStyleBlack.normal.background = Utility.MakeTex(2, 2, new Color(0f, 0f, 0f, 0.3f));
  20. textureBoxStyle = new GUIStyle(GUI.skin.box);
  21. textureBoxStyle.normal.background = Utility.MakeTex(2, 2, new Color(0f, 0f, 0f, 0f));
  22. textureBoxStyle.padding = textureBoxStyle.margin = new RectOffset(0, 0, 0, 0);
  23. }
  24. private static void Line(GUIStyle style) => GUILayout.Box(GUIContent.none, style, GUILayout.Height(1));
  25. public static void WhiteLine() => Line(lineStyleWhite);
  26. public static void BlackLine() => Line(lineStyleBlack);
  27. public static void DrawTexture(Texture texture, params GUILayoutOption[] layoutOptions)
  28. {
  29. GUILayout.Box(texture, textureBoxStyle, layoutOptions);
  30. }
  31. public static int ClampFont(int size, int min, int max)
  32. {
  33. return Mathf.Clamp(Utility.GetPix(size), min, max);
  34. }
  35. public static void Header(string text, params GUILayoutOption[] layoutOptions)
  36. {
  37. GUIStyle style = new GUIStyle(GUI.skin.label);
  38. style.padding = new RectOffset(7, 0, 0, -5);
  39. GUILayout.Label(text, style, layoutOptions);
  40. }
  41. }
  42. }