com.typhoon.unitysdk 1.0.90 → 1.0.92

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (158) hide show
  1. package/CHANGELOG.md +13 -1
  2. package/Editor/GUIDrawer.cs +1 -1
  3. package/Editor/HistoryVersionWindow.cs +6 -4
  4. package/Editor/OppoMiniConfig.cs +7 -7
  5. package/Editor/PreferencesWindow.cs +1 -2
  6. package/Editor/PublishSettingGUIDrawer.cs +2 -2
  7. package/Editor/PublishSettingInspector.cs +2 -2
  8. package/Editor/PublishWindow.cs +24 -21
  9. package/Editor/Styles.cs +474 -181
  10. package/Editor/Texture/dark/blue_active.png +0 -0
  11. package/Editor/Texture/dark/blue_active.png.meta +144 -0
  12. package/Editor/Texture/dark/blue_hover.png +0 -0
  13. package/Editor/Texture/dark/blue_hover.png.meta +144 -0
  14. package/Editor/Texture/dark/blue_normal.png +0 -0
  15. package/Editor/Texture/dark/blue_normal.png.meta +144 -0
  16. package/Editor/Texture/dark/green_active.png +0 -0
  17. package/Editor/Texture/dark/green_active.png.meta +144 -0
  18. package/Editor/Texture/dark/green_hover.png +0 -0
  19. package/Editor/Texture/dark/green_hover.png.meta +144 -0
  20. package/Editor/Texture/dark/green_normal.png +0 -0
  21. package/Editor/Texture/dark/green_normal.png.meta +144 -0
  22. package/Editor/Texture/dark/help_box.png +0 -0
  23. package/Editor/Texture/dark/help_box.png.meta +144 -0
  24. package/Editor/Texture/dark/menu_active.png +0 -0
  25. package/Editor/Texture/dark/menu_active.png.meta +144 -0
  26. package/Editor/Texture/dark/n_active.png +0 -0
  27. package/Editor/Texture/dark/n_active.png.meta +144 -0
  28. package/Editor/Texture/dark/n_hover.png +0 -0
  29. package/Editor/Texture/dark/n_hover.png.meta +144 -0
  30. package/Editor/Texture/dark/n_normal.png +0 -0
  31. package/Editor/Texture/dark/n_normal.png.meta +144 -0
  32. package/Editor/Texture/dark/red_active.png +0 -0
  33. package/Editor/Texture/dark/red_active.png.meta +144 -0
  34. package/Editor/Texture/dark/red_hover.png +0 -0
  35. package/Editor/Texture/dark/red_hover.png.meta +144 -0
  36. package/Editor/Texture/dark/red_normal.png +0 -0
  37. package/Editor/Texture/dark/red_normal.png.meta +144 -0
  38. package/Editor/Texture/dark/square_b_active.png +0 -0
  39. package/Editor/Texture/dark/square_b_active.png.meta +144 -0
  40. package/Editor/Texture/dark/square_b_hover.png +0 -0
  41. package/Editor/Texture/dark/square_b_hover.png.meta +144 -0
  42. package/Editor/Texture/dark/square_b_normal.png +0 -0
  43. package/Editor/Texture/dark/square_b_normal.png.meta +144 -0
  44. package/Editor/Texture/dark/square_g_active.png +0 -0
  45. package/Editor/Texture/dark/square_g_active.png.meta +144 -0
  46. package/Editor/Texture/dark/square_g_hover.png +0 -0
  47. package/Editor/Texture/dark/square_g_hover.png.meta +144 -0
  48. package/Editor/Texture/dark/square_g_normal.png +0 -0
  49. package/Editor/Texture/dark/square_g_normal.png.meta +144 -0
  50. package/Editor/Texture/dark/square_menu_active.png +0 -0
  51. package/Editor/Texture/dark/square_menu_active.png.meta +144 -0
  52. package/Editor/Texture/dark/square_n_active.png +0 -0
  53. package/Editor/Texture/dark/square_n_active.png.meta +144 -0
  54. package/Editor/Texture/dark/square_n_hover.png +0 -0
  55. package/Editor/Texture/dark/square_n_hover.png.meta +144 -0
  56. package/Editor/Texture/dark/square_n_normal.png +0 -0
  57. package/Editor/Texture/dark/square_n_normal.png.meta +144 -0
  58. package/Editor/Texture/dark/square_r_active.png +0 -0
  59. package/Editor/Texture/dark/square_r_active.png.meta +144 -0
  60. package/Editor/Texture/dark/square_r_hover.png +0 -0
  61. package/Editor/Texture/dark/square_r_hover.png.meta +144 -0
  62. package/Editor/Texture/dark/square_r_normal.png +0 -0
  63. package/Editor/Texture/dark/square_r_normal.png.meta +144 -0
  64. package/Editor/Texture/dark/square_y_active.png +0 -0
  65. package/Editor/Texture/dark/square_y_active.png.meta +144 -0
  66. package/Editor/Texture/dark/square_y_hover.png +0 -0
  67. package/Editor/Texture/dark/square_y_hover.png.meta +144 -0
  68. package/Editor/Texture/dark/square_y_normal.png +0 -0
  69. package/Editor/Texture/dark/square_y_normal.png.meta +144 -0
  70. package/Editor/Texture/dark/title_bar.png +0 -0
  71. package/Editor/Texture/dark/title_bar.png.meta +144 -0
  72. package/Editor/Texture/dark/yellow_active.png +0 -0
  73. package/Editor/Texture/dark/yellow_active.png.meta +144 -0
  74. package/Editor/Texture/dark/yellow_hover.png +0 -0
  75. package/Editor/Texture/dark/yellow_hover.png.meta +144 -0
  76. package/Editor/Texture/dark/yellow_normal.png +0 -0
  77. package/Editor/Texture/dark/yellow_normal.png.meta +144 -0
  78. package/Editor/Texture/dark.meta +8 -0
  79. package/Editor/Texture/icon/error.png +0 -0
  80. package/Editor/Texture/icon/error.png.meta +144 -0
  81. package/Editor/Texture/icon/info.png +0 -0
  82. package/Editor/Texture/icon/info.png.meta +144 -0
  83. package/Editor/Texture/icon/warning.png +0 -0
  84. package/Editor/Texture/icon/warning.png.meta +144 -0
  85. package/Editor/Texture/icon.meta +8 -0
  86. package/Editor/Texture/light/blue_active.png +0 -0
  87. package/Editor/Texture/light/blue_active.png.meta +144 -0
  88. package/Editor/Texture/light/blue_hover.png +0 -0
  89. package/Editor/Texture/light/blue_hover.png.meta +144 -0
  90. package/Editor/Texture/light/blue_normal.png +0 -0
  91. package/Editor/Texture/light/blue_normal.png.meta +144 -0
  92. package/Editor/Texture/light/green_active.png +0 -0
  93. package/Editor/Texture/light/green_active.png.meta +144 -0
  94. package/Editor/Texture/light/green_hover.png +0 -0
  95. package/Editor/Texture/light/green_hover.png.meta +144 -0
  96. package/Editor/Texture/light/green_normal.png +0 -0
  97. package/Editor/Texture/light/green_normal.png.meta +144 -0
  98. package/Editor/Texture/light/help_box.png +0 -0
  99. package/Editor/Texture/light/help_box.png.meta +144 -0
  100. package/Editor/Texture/light/menu_active.png +0 -0
  101. package/Editor/Texture/light/menu_active.png.meta +144 -0
  102. package/Editor/Texture/light/n_active.png +0 -0
  103. package/Editor/Texture/light/n_active.png.meta +144 -0
  104. package/Editor/Texture/light/n_hover.png +0 -0
  105. package/Editor/Texture/light/n_hover.png.meta +144 -0
  106. package/Editor/Texture/light/n_normal.png +0 -0
  107. package/Editor/Texture/light/n_normal.png.meta +144 -0
  108. package/Editor/Texture/light/red_active.png +0 -0
  109. package/Editor/Texture/light/red_active.png.meta +144 -0
  110. package/Editor/Texture/light/red_hover.png +0 -0
  111. package/Editor/Texture/light/red_hover.png.meta +144 -0
  112. package/Editor/Texture/light/red_normal.png +0 -0
  113. package/Editor/Texture/light/red_normal.png.meta +144 -0
  114. package/Editor/Texture/light/square_b_active.png +0 -0
  115. package/Editor/Texture/light/square_b_active.png.meta +144 -0
  116. package/Editor/Texture/light/square_b_hover.png +0 -0
  117. package/Editor/Texture/light/square_b_hover.png.meta +144 -0
  118. package/Editor/Texture/light/square_b_normal.png +0 -0
  119. package/Editor/Texture/light/square_b_normal.png.meta +144 -0
  120. package/Editor/Texture/light/square_g_active.png +0 -0
  121. package/Editor/Texture/light/square_g_active.png.meta +144 -0
  122. package/Editor/Texture/light/square_g_hover.png +0 -0
  123. package/Editor/Texture/light/square_g_hover.png.meta +144 -0
  124. package/Editor/Texture/light/square_g_normal.png +0 -0
  125. package/Editor/Texture/light/square_g_normal.png.meta +144 -0
  126. package/Editor/Texture/light/square_menu_active.png +0 -0
  127. package/Editor/Texture/light/square_menu_active.png.meta +144 -0
  128. package/Editor/Texture/light/square_n_active.png +0 -0
  129. package/Editor/Texture/light/square_n_active.png.meta +144 -0
  130. package/Editor/Texture/light/square_n_hover.png +0 -0
  131. package/Editor/Texture/light/square_n_hover.png.meta +144 -0
  132. package/Editor/Texture/light/square_n_normal.png +0 -0
  133. package/Editor/Texture/light/square_n_normal.png.meta +144 -0
  134. package/Editor/Texture/light/square_r_active.png +0 -0
  135. package/Editor/Texture/light/square_r_active.png.meta +144 -0
  136. package/Editor/Texture/light/square_r_hover.png +0 -0
  137. package/Editor/Texture/light/square_r_hover.png.meta +144 -0
  138. package/Editor/Texture/light/square_r_normal.png +0 -0
  139. package/Editor/Texture/light/square_r_normal.png.meta +144 -0
  140. package/Editor/Texture/light/square_y_active.png +0 -0
  141. package/Editor/Texture/light/square_y_active.png.meta +144 -0
  142. package/Editor/Texture/light/square_y_hover.png +0 -0
  143. package/Editor/Texture/light/square_y_hover.png.meta +144 -0
  144. package/Editor/Texture/light/square_y_normal.png +0 -0
  145. package/Editor/Texture/light/square_y_normal.png.meta +144 -0
  146. package/Editor/Texture/light/title_bar.png +0 -0
  147. package/Editor/Texture/light/title_bar.png.meta +144 -0
  148. package/Editor/Texture/light/yellow_active.png +0 -0
  149. package/Editor/Texture/light/yellow_active.png.meta +144 -0
  150. package/Editor/Texture/light/yellow_hover.png +0 -0
  151. package/Editor/Texture/light/yellow_hover.png.meta +144 -0
  152. package/Editor/Texture/light/yellow_normal.png +0 -0
  153. package/Editor/Texture/light/yellow_normal.png.meta +144 -0
  154. package/Editor/Texture/light.meta +8 -0
  155. package/Editor/VariablePresetWindow.cs +3 -4
  156. package/Editor/VivoMiniConfig.cs +7 -7
  157. package/Editor/WxMiniConfig.cs +1 -1
  158. package/package.json +1 -1
package/Editor/Styles.cs CHANGED
@@ -1,4 +1,5 @@
1
1
  using System;
2
+ using System.Collections.Generic;
2
3
  using UnityEditor;
3
4
  using UnityEngine;
4
5
 
@@ -7,258 +8,550 @@ namespace TyphoonUnitySDK
7
8
  //样式
8
9
  public class Styles
9
10
  {
10
- public static Color TitleBgColor => EditorGUIUtility.isProSkin
11
- ? new Color(0.17f, 0.17f, 0.17f, 1f)
12
- : new Color(0.65f, 0.65f, 0.65f, 1f);
11
+ #region 图片
13
12
 
14
- private static Color TextColor = EditorGUIUtility.isProSkin
15
- ? new Color(0.93f, 0.93f, 0.93f, 1f)
16
- : new Color(0.04f, 0.04f, 0.04f, 1f);
13
+ private static Dictionary<string, Texture2D> _texture2Ds = new Dictionary<string, Texture2D>();
17
14
 
18
- private static Color NormalColor = EditorGUIUtility.isProSkin
19
- ? new Color(0.35f, 0.35f, 0.35f, 1f)
20
- : new Color(0.88f, 0.88f, 0.88f, 1f);
21
-
22
- private static Color HoverColor = EditorGUIUtility.isProSkin
23
- ? new Color(0.4f, 0.4f, 0.4f, 1f)
24
- : new Color(0.9f, 0.9f, 0.9f, 1f);
15
+ private static Texture2D Get2D(string name)
16
+ {
17
+ if (_texture2Ds.TryGetValue(name, out var match))
18
+ {
19
+ return match;
20
+ }
25
21
 
26
- private static Color ActiveColor = EditorGUIUtility.isProSkin
27
- ? new Color(0.21f, 0.21f, 0.21f, 1f)
28
- : new Color(0.69f, 0.69f, 0.69f, 1f);
22
+ return null;
23
+ }
29
24
 
30
- private static Color Blue = EditorGUIUtility.isProSkin
31
- ? new Color(0.28f, 0.48f, 0.6f, 1f)
32
- : new Color(0.47f, 0.8f, 1f, 1f);
33
25
 
34
- private static GUIStyle _button = null;
26
+ private static Dictionary<string, GUIStyle> _styles = new Dictionary<string, GUIStyle>();
35
27
 
36
- public static GUIStyle Button => CreateStyle(ref _button, "button", (e) =>
28
+ private static GUIStyle GetStyle(string name)
37
29
  {
38
- var normal = NormalColor;
39
- var hover = HoverColor;
40
- var active = ActiveColor;
41
- e.margin = new RectOffset(0, 0, 0, 0);
42
- e.border = new RectOffset(0, 0, 0, 0);
43
- e.padding = new RectOffset(0, 0, 0, 0);
44
- SetStyleStateColor(e, normal, hover, active);
45
- e.normal.textColor = TextColor;
46
- e.focused.textColor = TextColor;
47
- e.hover.textColor = TextColor;
48
- e.active.textColor = TextColor;
49
- e.alignment = TextAnchor.MiddleCenter;
50
- e.contentOffset = Vector2.zero;
51
- e.fixedWidth = 0;
52
- e.fixedHeight = 0;
53
- e.stretchHeight = false;
54
- e.stretchWidth = false;
55
- });
30
+ if (_styles.TryGetValue(name, out var match))
31
+ {
32
+ return match;
33
+ }
56
34
 
35
+ return null;
36
+ }
57
37
 
58
- private static GUIStyle _titleFoldoutButton = null;
59
38
 
60
- public static GUIStyle TitleFoldoutButton =>
61
- CreateStyle(ref _titleFoldoutButton, Button, (e) =>
62
- {
63
- e.fontSize = 16;
64
- e.padding = new RectOffset(2, 2, 2, 2);
65
- e.alignment = TextAnchor.MiddleLeft;
66
- e.stretchWidth = true;
67
- });
39
+ public static Texture2D Green2DNormal => LoadTheme2D("green_normal.png");
68
40
 
69
- private static GUIStyle _menuButtonNormal = null;
41
+ public static Texture2D Green2DHover => LoadTheme2D("green_hover.png");
70
42
 
71
- public static GUIStyle MenuButtonNormal =>
72
- CreateStyle(ref _menuButtonNormal, Button, (e) =>
73
- {
74
- e.padding = new RectOffset(2, 2, 2, 2);
75
- e.alignment = TextAnchor.MiddleLeft;
76
- });
43
+ public static Texture2D Green2DActive => LoadTheme2D("green_active.png");
77
44
 
78
45
 
79
- private static GUIStyle _menuButtonActive = null;
46
+ public static Texture2D Blue2DNormal => LoadTheme2D("blue_normal.png");
80
47
 
81
- public static GUIStyle MenuButtonActive => CreateStyle(ref _menuButtonActive, "button", (e) =>
82
- {
83
- var normal = ActiveColor;
84
- var hover = ActiveColor;
85
- var active = ActiveColor;
86
- e.margin = new RectOffset(0, 0, 0, 0);
87
- e.border = new RectOffset(0, 0, 0, 0);
88
- e.padding = new RectOffset(2, 2, 2, 2);
89
- SetStyleStateColor(e, normal, hover, active);
90
- e.normal.textColor = TextColor;
91
- e.focused.textColor = TextColor;
92
- e.hover.textColor = TextColor;
93
- e.active.textColor = TextColor;
94
- e.contentOffset = Vector2.zero;
95
- e.fixedWidth = 0;
96
- e.fixedHeight = 0;
97
- e.stretchHeight = false;
98
- e.stretchWidth = false;
99
- e.alignment = TextAnchor.MiddleLeft;
100
- e.fontSize = 14;
101
- e.fontStyle = FontStyle.Bold;
102
- });
48
+ public static Texture2D Blue2DHover => LoadTheme2D("blue_hover.png");
49
+
50
+ public static Texture2D Blue2DActive => LoadTheme2D("blue_active.png");
51
+
52
+
53
+ public static Texture2D Yellow2DNormal => LoadTheme2D("yellow_normal.png");
54
+
55
+ public static Texture2D Yellow2DHover => LoadTheme2D("yellow_hover.png");
56
+
57
+ public static Texture2D Yellow2DActive => LoadTheme2D("yellow_active.png");
58
+
59
+
60
+ public static Texture2D Red2DNormal => LoadTheme2D("red_normal.png");
61
+
62
+ public static Texture2D Red2DHover => LoadTheme2D("red_hover.png");
63
+
64
+ public static Texture2D Red2DActive => LoadTheme2D("red_active.png");
65
+
66
+
67
+ public static Texture2D General2DNormal => LoadTheme2D("n_normal.png");
68
+
69
+ public static Texture2D General2DHover => LoadTheme2D("n_hover.png");
70
+
71
+ public static Texture2D General2DActive => LoadTheme2D("n_active.png");
72
+
73
+
74
+ public static Texture2D Menu2DActive => LoadTheme2D("menu_active.png");
75
+
76
+ public static Texture2D HelpBox2D => LoadTheme2D("help_box.png");
77
+
78
+ public static Texture2D TitleBar2D => LoadTheme2D("title_bar.png");
79
+
80
+ public static Texture2D IconWarning => LoadIcon2D("warning.png");
81
+ public static Texture2D IconInfo => LoadIcon2D("info.png");
82
+ public static Texture2D IconError => LoadIcon2D("error.png");
83
+
84
+ #endregion
85
+
86
+
87
+ #region 默认按钮-圆角
88
+
89
+ public static GUIStyle Btn => CreateColorButtonStyle("Default.Btn", General2DNormal, General2DHover,
90
+ General2DActive, (style) => { style.alignment = TextAnchor.MiddleCenter; });
91
+
92
+ public static GUIStyle BtnLeft => CreateColorButtonStyle("Default.BtnLeft", General2DNormal, General2DHover,
93
+ General2DActive, (style) => { style.alignment = TextAnchor.MiddleLeft; });
94
+
95
+ public static GUIStyle BtnRight => CreateColorButtonStyle("Default.BtnRight", General2DNormal, General2DHover,
96
+ General2DActive, (style) => { style.alignment = TextAnchor.MiddleRight; });
103
97
 
98
+ #endregion
104
99
 
105
- private static GUIStyle _boldLabel = null;
100
+ #region 菜单栏按钮-圆角
106
101
 
107
- public static GUIStyle BoldLabel =>
108
- CreateStyle(ref _boldLabel, "label", (e) => { e.fontStyle = FontStyle.Bold; });
102
+ public static GUIStyle MenuButton => CreateColorButtonStyle("Default.MenuButton", General2DNormal,
103
+ General2DHover,
104
+ General2DActive, (style) => { style.alignment = TextAnchor.MiddleLeft; });
109
105
 
110
- private static GUIStyle _boldButton = null;
111
106
 
112
- public static GUIStyle BoldButton =>
113
- CreateStyle(ref _boldButton, Button, (e) =>
107
+ public static GUIStyle MenuButtonActive => CreateColorButtonStyle("Default.MenuButtonActive", Menu2DActive,
108
+ Menu2DActive,
109
+ Menu2DActive, (style) =>
114
110
  {
115
- e.fontSize = 16;
116
- e.fontStyle = FontStyle.Bold;
111
+ style.alignment = TextAnchor.MiddleLeft;
112
+ style.fontStyle = FontStyle.Bold;
117
113
  });
118
114
 
119
- private static GUIStyle _boldTitle = null;
115
+ #endregion
120
116
 
121
- public static GUIStyle BoldTitle => CreateStyle(ref _boldTitle, "label", (e) =>
117
+ #region 绿色按钮-圆角
118
+
119
+ public static GUIStyle BtnGreen => CreateColorButtonStyle("Default.BtnGreen", Green2DNormal, Green2DHover,
120
+ Green2DActive,
121
+ (style) => { style.alignment = TextAnchor.MiddleCenter; });
122
+
123
+
124
+ public static GUIStyle BtnGreenLeft => CreateColorButtonStyle("Default.BtnGreenLeft", Green2DNormal,
125
+ Green2DHover,
126
+ Green2DActive,
127
+ (style) => { style.alignment = TextAnchor.MiddleLeft; });
128
+
129
+
130
+ public static GUIStyle BtnGreenRight => CreateColorButtonStyle("Default.BtnGreenRight", Green2DNormal,
131
+ Green2DHover,
132
+ Green2DActive,
133
+ (style) => { style.alignment = TextAnchor.MiddleRight; });
134
+
135
+ #endregion
136
+
137
+ #region 蓝色按钮-圆角
138
+
139
+ public static GUIStyle BtnBlue => CreateColorButtonStyle("Default.BtnBlue", Blue2DNormal, Blue2DHover,
140
+ Blue2DActive,
141
+ (style) => { style.alignment = TextAnchor.MiddleCenter; });
142
+
143
+ public static GUIStyle BtnBlueLeft => CreateColorButtonStyle("Default.BtnBlueLeft", Blue2DNormal, Blue2DHover,
144
+ Blue2DActive,
145
+ (style) => { style.alignment = TextAnchor.MiddleLeft; });
146
+
147
+ public static GUIStyle BtnBlueRight => CreateColorButtonStyle("Default.BtnBlueRight", Blue2DNormal, Blue2DHover,
148
+ Blue2DActive,
149
+ (style) => { style.alignment = TextAnchor.MiddleRight; });
150
+
151
+ #endregion
152
+
153
+ #region 黄色按钮-圆角
154
+
155
+ public static GUIStyle BtnYellow => CreateColorButtonStyle("Default.BtnYellow", Yellow2DNormal, Yellow2DHover,
156
+ Yellow2DActive,
157
+ (style) => { style.alignment = TextAnchor.MiddleCenter; });
158
+
159
+
160
+ public static GUIStyle BtnYellowLeft => CreateColorButtonStyle("Default.BtnYellowLeft", Yellow2DNormal,
161
+ Yellow2DHover,
162
+ Yellow2DActive,
163
+ (style) => { style.alignment = TextAnchor.MiddleLeft; });
164
+
165
+
166
+ public static GUIStyle BtnYellowRight => CreateColorButtonStyle("Default.BtnYellowRight", Yellow2DNormal,
167
+ Yellow2DHover,
168
+ Yellow2DActive,
169
+ (style) => { style.alignment = TextAnchor.MiddleRight; });
170
+
171
+ #endregion
172
+
173
+ #region 红色按钮-圆角
174
+
175
+ public static GUIStyle BtnRed => CreateColorButtonStyle("Default.BtnRed", Red2DNormal, Red2DHover,
176
+ Red2DActive,
177
+ (style) => { style.alignment = TextAnchor.MiddleCenter; });
178
+
179
+ public static GUIStyle BtnRedLeft => CreateColorButtonStyle("Default.BtnRedLeft", Red2DNormal, Red2DHover,
180
+ Red2DActive,
181
+ (style) => { style.alignment = TextAnchor.MiddleLeft; });
182
+
183
+ public static GUIStyle BtnRedRight => CreateColorButtonStyle("Default.BtnRedRight", Red2DNormal, Red2DHover,
184
+ Red2DActive,
185
+ (style) => { style.alignment = TextAnchor.MiddleRight; });
186
+
187
+ #endregion
188
+
189
+ #region Label
190
+
191
+ public static GUIStyle HelpBox => CreateStyle("Default.HelpBox", GUI.skin.textArea, (style) =>
122
192
  {
123
- e.fontSize = 14;
124
- e.fontStyle = FontStyle.Bold;
125
- e.alignment = TextAnchor.MiddleLeft;
193
+ style.border = new RectOffset(6, 6, 6, 6);
194
+ style.margin = new RectOffset(2, 2, 2, 2);
195
+ style.padding = new RectOffset(4, 4, 4, 4);
196
+ style.normal.background = HelpBox2D;
197
+ style.normal.scaledBackgrounds = Array.Empty<Texture2D>();
198
+ style.alignment = TextAnchor.UpperLeft;
199
+ style.stretchWidth = true;
200
+ style.fontSize = 11;
126
201
  });
127
202
 
128
- public static GUIStyle _italicLabel = null;
129
203
 
130
- public static GUIStyle ItalicLabel => CreateStyle(ref _italicLabel, "label", (e) =>
204
+ public static GUIStyle ItalicLabel => CreateStyle("Default.ItalicLabel", "label", (style) =>
131
205
  {
132
- e.fontStyle = FontStyle.Italic;
133
- e.alignment = TextAnchor.MiddleLeft;
134
- e.padding = new RectOffset(2, 0, 2, 0);
135
- e.margin = new RectOffset(2, 2, 2, 2);
206
+ style.border = new RectOffset(0, 0, 0, 0);
207
+ style.margin = new RectOffset(2, 2, 2, 2);
208
+ style.padding = new RectOffset(2, 0, 2, 0);
209
+ style.fontStyle = FontStyle.Italic;
210
+ style.alignment = TextAnchor.UpperLeft;
136
211
  });
137
212
 
138
213
 
139
- public static GUIStyle _blueButton = null;
214
+ public static GUIStyle ItalicLabelMiddle => CreateStyle("Default.ItalicLabelMiddle", "label", (style) =>
215
+ {
216
+ style.border = new RectOffset(0, 0, 0, 0);
217
+ style.margin = new RectOffset(2, 2, 2, 2);
218
+ style.padding = new RectOffset(2, 0, 2, 0);
219
+ style.fontStyle = FontStyle.Italic;
220
+ style.alignment = TextAnchor.MiddleLeft;
221
+ });
140
222
 
141
- public static GUIStyle BlueButton = CreateStyle(ref _blueButton, Button, (e) =>
223
+ public static GUIStyle BoldLabel => CreateStyle("Default.BoldLabel", "label", (style) =>
142
224
  {
143
- var normal = Blue;
144
- var hover = Blue * 1.1f;
145
- var active = Blue * 0.9f;
146
- e.margin = new RectOffset(2, 2, 2, 2);
147
- e.border = new RectOffset(2, 2, 2, 2);
148
- e.padding = new RectOffset(0, 0, 0, 0);
149
- SetStyleStateOutlineColor(e, normal, hover, active, new Color(0.17f, 0.3f, 0.34f, 1f));
150
- e.normal.textColor = TextColor;
151
- e.focused.textColor = TextColor;
152
- e.hover.textColor = TextColor;
153
- e.active.textColor = TextColor;
154
- e.alignment = TextAnchor.MiddleCenter;
155
- e.contentOffset = Vector2.zero;
156
- e.fixedWidth = 0;
157
- e.fixedHeight = 0;
158
- e.stretchHeight = false;
159
- e.stretchWidth = true;
160
- e.fontStyle = FontStyle.Bold;
225
+ style.border = new RectOffset(2, 2, 2, 2);
226
+ style.margin = new RectOffset(2, 2, 2, 2);
227
+ style.padding = new RectOffset(4, 4, 4, 4);
228
+ style.fontStyle = FontStyle.Bold;
229
+ style.alignment = TextAnchor.UpperLeft;
161
230
  });
162
231
 
232
+ public static GUIStyle BoldLabelMiddle => CreateStyle("Default.BoldLabelMiddle", "label", (style) =>
233
+ {
234
+ style.border = new RectOffset(2, 2, 2, 2);
235
+ style.margin = new RectOffset(2, 2, 2, 2);
236
+ style.padding = new RectOffset(4, 4, 4, 4);
237
+ style.fontStyle = FontStyle.Bold;
238
+ style.alignment = TextAnchor.MiddleLeft;
239
+ });
163
240
 
164
- private static GUIStyle CreateStyle(ref GUIStyle style, string proto, Action<GUIStyle> onCreate)
241
+
242
+ public static GUIStyle TitleBar => CreateStyle("Default.TitleBar", "label", (style) =>
165
243
  {
244
+ style.border = new RectOffset(2, 2, 2, 2);
245
+ style.margin = new RectOffset(2, 2, 2, 2);
246
+ style.padding = new RectOffset(4, 4, 4, 4);
247
+ style.overflow = new RectOffset(0, 0, 0, 0);
248
+
249
+ style.normal.background = TitleBar2D;
250
+ style.fontStyle = FontStyle.Bold;
251
+ style.stretchWidth = true;
252
+ style.alignment = TextAnchor.MiddleLeft;
253
+ });
254
+
255
+ #endregion
256
+
257
+
258
+ public class Square
259
+ {
260
+ //Square 绿色
261
+ public static Texture2D SquareGreen2DNormal => LoadTheme2D("square_g_normal.png");
262
+ public static Texture2D SquareGreen2DHover => LoadTheme2D("square_g_hover.png");
263
+ public static Texture2D SquareGreen2DActive => LoadTheme2D("square_g_active.png");
264
+
265
+ //Square 蓝色
266
+ public static Texture2D SquareBlue2DNormal => LoadTheme2D("square_b_normal.png");
267
+ public static Texture2D SquareBlue2DHover => LoadTheme2D("square_b_hover.png");
268
+
269
+ public static Texture2D SquareBlue2DActive => LoadTheme2D("square_b_active.png");
270
+
271
+ //Square 红色
272
+ public static Texture2D SquareRed2DNormal => LoadTheme2D("square_r_normal.png");
273
+ public static Texture2D SquareRed2DHover => LoadTheme2D("square_r_hover.png");
274
+ public static Texture2D SquareRed2DActive => LoadTheme2D("square_r_active.png");
275
+
276
+ //Square 黄色
277
+ public static Texture2D SquareYellow2DNormal => LoadTheme2D("square_y_normal.png");
278
+ public static Texture2D SquareYellow2DHover => LoadTheme2D("square_y_hover.png");
279
+ public static Texture2D SquareYellow2DActive => LoadTheme2D("square_y_active.png");
280
+
281
+
282
+ //Square 默认色
283
+ public static Texture2D SquareGeneral2DNormal => LoadTheme2D("square_n_normal.png");
284
+ public static Texture2D SquareGeneral2DHover => LoadTheme2D("square_n_hover.png");
285
+ public static Texture2D SquareGeneral2DActive => LoadTheme2D("square_n_active.png");
286
+
287
+ public static Texture2D SquareMenu2DActive => LoadTheme2D("square_menu_active.png");
288
+
289
+ #region 默认按钮-方形
290
+
291
+ public static GUIStyle Btn => CreateColorSquareButtonStyle("Square.Btn", SquareGeneral2DNormal,
292
+ SquareGeneral2DHover, SquareGeneral2DActive, (style) => { style.alignment = TextAnchor.MiddleCenter; });
293
+
294
+
295
+ public static GUIStyle BtnBold => CreateColorSquareButtonStyle("Square.BtnBold", SquareGeneral2DNormal,
296
+ SquareGeneral2DHover, SquareGeneral2DActive, (style) =>
297
+ {
298
+ style.alignment = TextAnchor.MiddleCenter;
299
+ style.fontStyle = FontStyle.Bold;
300
+ });
301
+
302
+
303
+ public static GUIStyle BtnLeft => CreateColorSquareButtonStyle("Square.BtnLeft",
304
+ SquareGeneral2DNormal,
305
+ SquareGeneral2DHover, SquareGeneral2DActive, (style) => { style.alignment = TextAnchor.MiddleLeft; });
306
+
307
+ public static GUIStyle BtnRight => CreateColorSquareButtonStyle("Square.BtnRight",
308
+ SquareGeneral2DNormal,
309
+ SquareGeneral2DHover, SquareGeneral2DActive, (style) => { style.alignment = TextAnchor.MiddleRight; });
310
+
311
+ #endregion
312
+
313
+ #region 菜单栏按钮-方形
314
+
315
+ public static GUIStyle MenuButton => CreateColorSquareButtonStyle("Square.MenuButton",
316
+ SquareGeneral2DNormal,
317
+ SquareGeneral2DHover, SquareGeneral2DActive,
318
+ (style) => { style.alignment = TextAnchor.MiddleLeft; });
319
+
320
+ public static GUIStyle MenuButtonActive => CreateColorSquareButtonStyle("Square.MenuButtonActive",
321
+ SquareMenu2DActive,
322
+ SquareMenu2DActive, SquareMenu2DActive,
323
+ (style) =>
324
+ {
325
+ style.alignment = TextAnchor.MiddleLeft;
326
+ style.fontStyle = FontStyle.Bold;
327
+ });
328
+
329
+ #endregion
330
+
331
+ #region 绿色按钮-方形
332
+
333
+ public static GUIStyle BtnGreen => CreateColorSquareButtonStyle("Square.BtnGreen",
334
+ SquareGreen2DNormal,
335
+ SquareGreen2DHover,
336
+ SquareGreen2DActive,
337
+ (style) => { style.alignment = TextAnchor.MiddleCenter; });
338
+
339
+
340
+ public static GUIStyle BtnGreenLeft => CreateColorSquareButtonStyle("Square.BtnGreenLeft",
341
+ SquareGreen2DNormal,
342
+ SquareGreen2DHover,
343
+ SquareGreen2DActive,
344
+ (style) => { style.alignment = TextAnchor.MiddleLeft; });
345
+
346
+
347
+ public static GUIStyle BtnGreenRight => CreateColorSquareButtonStyle("Square.BtnGreenRight",
348
+ SquareGreen2DNormal,
349
+ SquareGreen2DHover,
350
+ SquareGreen2DActive,
351
+ (style) => { style.alignment = TextAnchor.MiddleRight; });
352
+
353
+ #endregion
354
+
355
+ #region 蓝色按钮-方形
356
+
357
+ public static GUIStyle BtnBlue => CreateColorSquareButtonStyle("Square.BtnBlue",
358
+ SquareBlue2DNormal,
359
+ SquareBlue2DHover,
360
+ SquareBlue2DActive,
361
+ (style) => { style.alignment = TextAnchor.MiddleCenter; });
362
+
363
+ public static GUIStyle BtnBlueLeft => CreateColorSquareButtonStyle("Square.BtnBlueLeft",
364
+ SquareBlue2DNormal,
365
+ SquareBlue2DHover,
366
+ SquareBlue2DActive,
367
+ (style) => { style.alignment = TextAnchor.MiddleLeft; });
368
+
369
+ public static GUIStyle BtnBlueRight => CreateColorSquareButtonStyle("Square.BtnBlueRight",
370
+ SquareBlue2DNormal,
371
+ SquareBlue2DHover,
372
+ SquareBlue2DActive,
373
+ (style) => { style.alignment = TextAnchor.MiddleRight; });
374
+
375
+ #endregion
376
+
377
+ #region 黄色按钮-方形
378
+
379
+ public static GUIStyle BtnYellow => CreateColorSquareButtonStyle("Square.BtnYellow",
380
+ SquareYellow2DNormal,
381
+ SquareYellow2DHover,
382
+ SquareYellow2DActive,
383
+ (style) => { style.alignment = TextAnchor.MiddleCenter; });
384
+
385
+
386
+ public static GUIStyle BtnYellowLeft => CreateColorSquareButtonStyle("Square.BtnYellowLeft",
387
+ SquareYellow2DNormal,
388
+ SquareYellow2DHover,
389
+ SquareYellow2DActive,
390
+ (style) => { style.alignment = TextAnchor.MiddleLeft; });
391
+
392
+
393
+ public static GUIStyle BtnYellowRight => CreateColorSquareButtonStyle("Square.BtnYellowRight",
394
+ SquareYellow2DNormal,
395
+ SquareYellow2DHover,
396
+ SquareYellow2DActive,
397
+ (style) => { style.alignment = TextAnchor.MiddleRight; });
398
+
399
+ #endregion
400
+
401
+ #region 红色按钮-方形
402
+
403
+ public static GUIStyle BtnRed => CreateColorSquareButtonStyle("Square.BtnRed",
404
+ SquareRed2DNormal,
405
+ SquareRed2DHover,
406
+ SquareRed2DActive,
407
+ (style) => { style.alignment = TextAnchor.MiddleCenter; });
408
+
409
+
410
+ public static GUIStyle BtnRedLeft => CreateColorSquareButtonStyle("Square.BtnRedLeft",
411
+ SquareRed2DNormal,
412
+ SquareRed2DHover,
413
+ SquareRed2DActive,
414
+ (style) => { style.alignment = TextAnchor.MiddleLeft; });
415
+
416
+
417
+ public static GUIStyle BtnRedRight => CreateColorSquareButtonStyle("Square.BtnRedRight",
418
+ SquareRed2DNormal,
419
+ SquareRed2DHover,
420
+ SquareRed2DActive,
421
+ (style) => { style.alignment = TextAnchor.MiddleRight; });
422
+
423
+ #endregion
424
+ }
425
+
426
+ private static GUIStyle CreateStyle(string name, string proto, Action<GUIStyle> onCreate)
427
+ {
428
+ var style = GetStyle(name);
166
429
  if (style == null)
167
430
  {
168
431
  style = new GUIStyle(proto);
169
432
  onCreate?.Invoke(style);
433
+ _styles.Add(name, style);
170
434
  }
171
435
 
172
436
  return style;
173
437
  }
174
438
 
175
- private static GUIStyle CreateStyle(ref GUIStyle style, GUIStyle proto, Action<GUIStyle> onCreate)
439
+ private static GUIStyle CreateStyle(string name, GUIStyle proto, Action<GUIStyle> onCreate)
176
440
  {
441
+ var style = GetStyle(name);
177
442
  if (style == null)
178
443
  {
179
444
  style = new GUIStyle(proto);
180
445
  onCreate?.Invoke(style);
446
+ _styles.Add(name, style);
181
447
  }
182
448
 
183
449
  return style;
184
450
  }
185
451
 
186
-
187
- //创建一个纯色图
188
- public static Texture2D MakeColorTex(Color color)
452
+ private static GUIStyle CreateColorButtonStyle(string name, Texture2D normal, Texture2D hover,
453
+ Texture2D active, Action<GUIStyle> onCreate)
189
454
  {
190
- var tex = new Texture2D(2, 2);
191
- tex.SetPixels(new[]
455
+ return CreateStyle(name, "button", (style) =>
192
456
  {
193
- color, color,
194
- color, color,
457
+ style.border = new RectOffset(6, 6, 6, 6);
458
+ style.margin = new RectOffset(2, 2, 2, 2);
459
+ style.padding = new RectOffset(4, 4, 4, 4);
460
+ style.overflow = new RectOffset(0, 0, 0, 0);
461
+ style.alignment = TextAnchor.MiddleCenter;
462
+ style.normal.background = normal;
463
+ style.normal.scaledBackgrounds = Array.Empty<Texture2D>();
464
+
465
+ style.hover.background = hover;
466
+ style.hover.scaledBackgrounds = Array.Empty<Texture2D>();
467
+
468
+ style.focused.background = active;
469
+ style.focused.scaledBackgrounds = Array.Empty<Texture2D>();
470
+
471
+ style.active.background = active;
472
+ style.active.scaledBackgrounds = Array.Empty<Texture2D>();
473
+
474
+
475
+ style.onNormal.background = normal;
476
+ style.onNormal.scaledBackgrounds = Array.Empty<Texture2D>();
477
+
478
+ style.onHover.background = hover;
479
+ style.onHover.scaledBackgrounds = Array.Empty<Texture2D>();
480
+
481
+ style.onActive.background = active;
482
+ style.onActive.scaledBackgrounds = Array.Empty<Texture2D>();
483
+
484
+ style.onFocused.background = active;
485
+ style.onFocused.scaledBackgrounds = Array.Empty<Texture2D>();
486
+ onCreate?.Invoke(style);
195
487
  });
196
- tex.Apply();
197
- return tex;
198
488
  }
199
489
 
200
- //创建一个描边背景图
201
- public static Texture2D MakeOutlineTex(Color baseColor, Color outline)
490
+ //方形按钮
491
+ private static GUIStyle CreateColorSquareButtonStyle(string name, Texture2D normal, Texture2D hover,
492
+ Texture2D active, Action<GUIStyle> onCreate)
202
493
  {
203
- var tex = new Texture2D(4, 4);
204
- tex.SetPixels(new[]
494
+ return CreateStyle(name, "button", (style) =>
205
495
  {
206
- outline, outline, outline, outline,
207
- outline, baseColor, baseColor, outline,
208
- outline, baseColor, baseColor, outline,
209
- outline, outline, outline, outline,
496
+ style.border = new RectOffset(2, 2, 2, 2);
497
+ style.margin = new RectOffset(2, 2, 2, 2);
498
+ style.padding = new RectOffset(4, 4, 4, 4);
499
+ style.overflow = new RectOffset(0, 0, 0, 0);
500
+ style.alignment = TextAnchor.MiddleCenter;
501
+ style.normal.background = normal;
502
+ style.normal.scaledBackgrounds = Array.Empty<Texture2D>();
503
+
504
+ style.hover.background = hover;
505
+ style.hover.scaledBackgrounds = Array.Empty<Texture2D>();
506
+
507
+ style.focused.background = active;
508
+ style.focused.scaledBackgrounds = Array.Empty<Texture2D>();
509
+
510
+ style.active.background = active;
511
+ style.active.scaledBackgrounds = Array.Empty<Texture2D>();
512
+
513
+
514
+ style.onNormal.background = normal;
515
+ style.onNormal.scaledBackgrounds = Array.Empty<Texture2D>();
516
+
517
+ style.onHover.background = hover;
518
+ style.onHover.scaledBackgrounds = Array.Empty<Texture2D>();
519
+
520
+ style.onActive.background = active;
521
+ style.onActive.scaledBackgrounds = Array.Empty<Texture2D>();
522
+
523
+ style.onFocused.background = active;
524
+ style.onFocused.scaledBackgrounds = Array.Empty<Texture2D>();
525
+ onCreate?.Invoke(style);
210
526
  });
211
- tex.Apply();
212
- return tex;
213
527
  }
214
528
 
215
-
216
- public static void SetStyleStateColor(GUIStyle style, Color normal, Color hover, Color active)
529
+ private static Texture2D LoadIcon2D(string name)
217
530
  {
218
- style.normal = new GUIStyleState();
219
- style.hover = new GUIStyleState();
220
- style.active = new GUIStyleState();
221
- style.focused = new GUIStyleState();
222
- style.onNormal = new GUIStyleState();
223
- style.onHover = new GUIStyleState();
224
- style.onActive = new GUIStyleState();
225
- style.onFocused = new GUIStyleState();
226
- var normalTex = MakeColorTex(normal);
227
- var hoverTex = MakeColorTex(hover);
228
- var activeTex = MakeColorTex(active);
229
- style.normal.background = normalTex;
230
- style.hover.background = hoverTex;
231
- style.active.background = activeTex;
232
- style.focused.background = activeTex;
233
- style.onNormal.background = normalTex;
234
- style.onHover.background = hoverTex;
235
- style.onActive.background = activeTex;
236
- style.onFocused.background = activeTex;
237
- }
531
+ var tex = Get2D(name);
532
+ if (tex == null)
533
+ {
534
+ var path = $"{UniEditor.PathRoot}/Editor/Texture/icon/{name}";
535
+ tex = AssetDatabase.LoadAssetAtPath<Texture2D>(path);
536
+ _texture2Ds.Add(name, tex);
537
+ }
238
538
 
539
+ return tex;
540
+ }
239
541
 
240
- public static void SetStyleStateOutlineColor(GUIStyle style, Color normal, Color hover, Color active,
241
- Color outline)
542
+ private static Texture2D LoadTheme2D(string name)
242
543
  {
243
- style.normal = new GUIStyleState();
244
- style.hover = new GUIStyleState();
245
- style.active = new GUIStyleState();
246
- style.focused = new GUIStyleState();
247
- style.onNormal = new GUIStyleState();
248
- style.onHover = new GUIStyleState();
249
- style.onActive = new GUIStyleState();
250
- style.onFocused = new GUIStyleState();
251
- var normalTex = MakeOutlineTex(normal, outline);
252
- var hoverTex = MakeOutlineTex(hover, outline);
253
- var activeTex = MakeOutlineTex(active, outline);
254
- style.normal.background = normalTex;
255
- style.hover.background = hoverTex;
256
- style.active.background = activeTex;
257
- style.focused.background = activeTex;
258
- style.onNormal.background = normalTex;
259
- style.onHover.background = hoverTex;
260
- style.onActive.background = activeTex;
261
- style.onFocused.background = activeTex;
544
+ var tex = Get2D(name);
545
+ if (tex == null)
546
+ {
547
+ var path = EditorGUIUtility.isProSkin
548
+ ? $"{UniEditor.PathRoot}/Editor/Texture/dark/{name}"
549
+ : $"{UniEditor.PathRoot}/Editor/Texture/light/{name}";
550
+ tex = AssetDatabase.LoadAssetAtPath<Texture2D>(path);
551
+ _texture2Ds.Add(name, tex);
552
+ }
553
+
554
+ return tex;
262
555
  }
263
556
  }
264
557
  }