WitStyles.cs 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. /*
  2. * Copyright (c) Meta Platforms, Inc. and affiliates.
  3. * All rights reserved.
  4. *
  5. * This source code is licensed under the license found in the
  6. * LICENSE file in the root directory of this source tree.
  7. */
  8. using UnityEditor;
  9. using UnityEngine;
  10. namespace Meta.WitAi
  11. {
  12. public static class WitStyles
  13. {
  14. // Window Layout Data
  15. public const float WindowMinWidth = 0f;
  16. public const float WindowMaxWidth = 450f;
  17. public const float WindowMinHeight = 400f;
  18. public const float WindowMaxSize = 5000f;
  19. public const float WindowPaddingTop = 8f;
  20. public const float WindowPaddingBottom = 8f;
  21. public const float WindowPaddingLeft = 8f;
  22. public const float WindowPaddingRight = 8f;
  23. public const float WindowScrollBarSize = 15f;
  24. // Spacing
  25. public const float HeaderWidth = 350f;
  26. public const float HeaderPaddingBottom = 8f;
  27. public const float WizardFieldPadding = 16f;
  28. // Text padding
  29. public const float ButtonMargin = 5f;
  30. // Icons
  31. public static GUIContent PasteIcon;
  32. public static GUIContent EditIcon;
  33. public static GUIContent ResetIcon;
  34. public static GUIContent AcceptIcon;
  35. public static GUIContent ObjectPickerIcon;
  36. public static GUIContent HelpIcon;
  37. // Label Styles
  38. public static GUIStyle Label;
  39. public static GUIStyle LabelWrap;
  40. public static GUIStyle LabelError;
  41. public static GUIStyle LabelHeader;
  42. public static GUIStyle LabelSubheader;
  43. public static GUIStyle LabelStatus;
  44. public static GUIStyle LabelStatusBackground;
  45. // Button styles
  46. public static GUIStyle TextButton;
  47. private const float TextButtonHeight = 25f;
  48. public const float TextButtonPadding = 5f;
  49. public static GUIStyle IconButton;
  50. public const float IconButtonSize = 16f; // Width & Height
  51. public static GUIStyle TabButton;
  52. private const float TabButtonHeight = 40f;
  53. public static GUIStyle HeaderButton;
  54. public static Color HeaderTextColor = new Color(0.09f, 0.47f, 0.95f); // FB
  55. // Wit error color (Red if in light non-pro editor mode)
  56. public static string ErrorColor = "#cc7777";
  57. // Wit link color (Blue if in light non-pro editor mode)
  58. public static string WitLinkColor = "#ccccff";
  59. public const string WitLinkKey = "[COLOR]";
  60. // Indentation
  61. public const float IndentationSpaces = 15f;
  62. // Text Field Styles
  63. public static GUIStyle TextField;
  64. public static GUIStyle IntField;
  65. public static GUIStyle PasswordField;
  66. // Foldout Style
  67. public static GUIStyle Foldout;
  68. // Toggle Style
  69. public static GUIStyle Toggle;
  70. // Popup/Dropdown Styles
  71. public static GUIStyle Popup;
  72. // Texture
  73. public static Texture2D TextureBlack25P;
  74. // Init
  75. static WitStyles()
  76. {
  77. // Setup icons
  78. PasteIcon = EditorGUIUtility.IconContent("Clipboard");
  79. EditIcon = EditorGUIUtility.IconContent("editicon.sml");
  80. ResetIcon = EditorGUIUtility.IconContent("TreeEditor.Trash");
  81. AcceptIcon = EditorGUIUtility.IconContent("FilterSelectedOnly");
  82. ObjectPickerIcon = EditorGUIUtility.IconContent("d_Record Off");
  83. HelpIcon = EditorGUIUtility.IconContent("_Help");
  84. // Adjust colors to be more visible on light background
  85. if (!EditorGUIUtility.isProSkin)
  86. {
  87. ErrorColor = "red";
  88. WitLinkColor = "blue";
  89. }
  90. // Label Styles
  91. Label = new GUIStyle();
  92. Label.fontSize = 11;
  93. Label.padding = new RectOffset(5, 5, 0, 0);
  94. Label.margin = new RectOffset(5, 5, 0, 0);
  95. Label.alignment = TextAnchor.MiddleLeft;
  96. Label.normal.textColor = Color.white;
  97. Label.hover.textColor = Color.white;
  98. Label.active.textColor = Color.white;
  99. Label.richText = true;
  100. Label.wordWrap = false;
  101. Label.clipping = TextClipping.Clip;
  102. LabelWrap = new GUIStyle(Label);
  103. LabelWrap.wordWrap = true;
  104. LabelSubheader = new GUIStyle(Label);
  105. LabelSubheader.fontSize = 14;
  106. LabelHeader = new GUIStyle(Label);
  107. LabelHeader.fontSize = 24;
  108. LabelHeader.padding = new RectOffset(0, 0, 10, 10);
  109. LabelHeader.margin = new RectOffset(0, 0, 10, 10);
  110. LabelHeader.wordWrap = true;
  111. LabelError = new GUIStyle(Label);
  112. LabelError.wordWrap = true;
  113. Color errorColor = Color.red;
  114. ColorUtility.TryParseHtmlString(ErrorColor, out errorColor);
  115. LabelError.normal.textColor = errorColor;
  116. LabelStatus = new GUIStyle(Label);
  117. TextureBlack25P = new Texture2D(1, 1);
  118. TextureBlack25P.SetPixel(0, 0, new Color(0, 0, 0, .25f));
  119. TextureBlack25P.Apply();
  120. LabelStatusBackground = new GUIStyle();
  121. LabelStatusBackground.normal.background = TextureBlack25P;
  122. LabelStatus.normal.background = TextureBlack25P;
  123. LabelStatus.wordWrap = true;
  124. LabelStatus.fontSize++;
  125. LabelStatus.alignment = TextAnchor.LowerLeft;
  126. LabelStatus.margin = new RectOffset(0, 0, 0, 0);
  127. LabelStatus.wordWrap = false;
  128. LabelStatus.fontSize = 10;
  129. // Button Styles
  130. TextButton = new GUIStyle(EditorStyles.miniButton);
  131. TextButton.alignment = TextAnchor.MiddleCenter;
  132. TextButton.fixedHeight = TextButtonHeight;
  133. TabButton = new GUIStyle(TextButton);
  134. TabButton.fixedHeight = TabButtonHeight;
  135. IconButton = new GUIStyle(Label);
  136. IconButton.margin = new RectOffset(0, 0, 0, 0);
  137. IconButton.padding = new RectOffset(0, 0, 0, 0);
  138. IconButton.fixedWidth = IconButtonSize;
  139. IconButton.fixedHeight = IconButtonSize;
  140. HeaderButton = new GUIStyle(Label);
  141. HeaderButton.normal.textColor = HeaderTextColor;
  142. // Text Field Styles
  143. TextField = new GUIStyle(EditorStyles.textField);
  144. TextField.padding = Label.padding;
  145. TextField.margin = Label.margin;
  146. TextField.alignment = Label.alignment;
  147. TextField.clipping = TextClipping.Clip;
  148. PasswordField = new GUIStyle(TextField);
  149. IntField = new GUIStyle(TextField);
  150. // Miscellaneous
  151. Foldout = new GUIStyle(EditorStyles.foldout);
  152. Toggle = new GUIStyle(EditorStyles.toggle);
  153. Popup = new GUIStyle(EditorStyles.popup);
  154. }
  155. }
  156. }