Skip to content

Commit f27b326

Browse files
Merge pull request #9 from Synesthesias/main
2.0.0-alpha release
2 parents 4634af2 + 0088326 commit f27b326

File tree

4,009 files changed

+344163
-145312
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

4,009 files changed

+344163
-145312
lines changed
104 KB
16.9 KB
-75.3 KB
129 KB

PlateauToolkit.Foundation/Editor/PlateauToolkit.Foundation.Editor.asmdef

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
"rootNamespace": "PlateauToolkit.Foundation.Editor",
44
"references": [
55
"GUID:5583122765da9804d8b3e6f2dccd809b",
6-
"GUID:2f611b55791fe6e49aafec04e8adcb97"
6+
"GUID:2f611b55791fe6e49aafec04e8adcb97",
7+
"GUID:33a64a05e6961c84c910a8057df1e46a"
78
],
89
"includePlatforms": [
910
"Editor"

PlateauToolkit.Foundation/Editor/PlateauToolkitEditorGUILayout.cs

Lines changed: 168 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,11 @@ public static IDisposable BackgroundColorScope(Color color)
8484

8585
public static void HeaderLogo(float windowWidth)
8686
{
87-
EditorGUILayout.Space(6f);
87+
EditorGUILayout.Space(25f);
8888

8989
var logoTexture =(Texture2D)AssetDatabase.LoadAssetAtPath(
9090
PlateauToolkitPaths.PlateauLogo, typeof(Texture2D));
91-
float width = Mathf.Min(windowWidth - 20, 260f);
91+
float width = Mathf.Min(windowWidth - 20, 170f);
9292
float height = (float)logoTexture.height / logoTexture.width * width;
9393

9494
using (new EditorGUILayout.HorizontalScope())
@@ -99,7 +99,7 @@ public static void HeaderLogo(float windowWidth)
9999
GUILayout.FlexibleSpace();
100100
}
101101

102-
EditorGUILayout.Space(10f);
102+
EditorGUILayout.Space(15f);
103103
}
104104

105105
public static void BorderLine()
@@ -108,52 +108,98 @@ public static void BorderLine()
108108
EditorGUI.DrawRect(borderRect, PlateauToolkitGUIStyles.k_LineColor);
109109
}
110110

111-
public static void Header(string label)
111+
public static void Title(float windowWidth, string label)
112112
{
113-
EditorGUILayout.Space(8);
113+
EditorGUILayout.Space(15);
114114

115-
BorderLine();
115+
float imageWidth = 40f;
116+
float imageHeight = 1f;
117+
float imageOffset = 3f;
118+
float textWidth = 120f;
119+
float textHeight = 17f;
120+
121+
Texture2D titleImage = AssetDatabase.LoadAssetAtPath<Texture2D>(PlateauToolkitPaths.PlateauTitleBackground);
122+
Rect imageRect = EditorGUILayout.GetControlRect(GUILayout.Width(imageWidth), GUILayout.Height(imageHeight));
123+
imageRect.y += (textHeight / 2) + imageOffset;
116124

117-
using (var scope = new EditorGUILayout.VerticalScope(PlateauToolkitGUIStyles.HeaderBoxStyle, GUILayout.Height(24)))
125+
using (new EditorGUILayout.HorizontalScope(GUILayout.Height(textHeight)))
118126
{
119-
EditorGUI.DrawRect(scope.rect, PlateauToolkitGUIStyles.k_HeaderBackgroundColor);
127+
GUILayout.FlexibleSpace();
128+
129+
imageRect.x = (windowWidth / 2) - (textWidth / 2) - imageWidth;
130+
GUI.DrawTexture(imageRect, titleImage);
120131

132+
EditorGUILayout.LabelField(label,
133+
PlateauToolkitGUIStyles.TitleTextStyle,
134+
GUILayout.Height(textHeight),
135+
GUILayout.Width(textWidth));
136+
137+
imageRect.x = (windowWidth / 2) + (textWidth / 2);
138+
139+
// Draw the image upside down
140+
GUIUtility.RotateAroundPivot (180f, imageRect.center);
141+
GUI.DrawTexture(imageRect, titleImage);
142+
GUI.matrix = Matrix4x4.identity;
143+
144+
GUILayout.FlexibleSpace();
145+
}
146+
}
147+
148+
public static void Header(string label, int topMargin = 15, int bottomMargin = 15)
149+
{
150+
EditorGUILayout.Space(topMargin);
151+
152+
BorderLine();
153+
using (var scope = new EditorGUILayout.VerticalScope(PlateauToolkitGUIStyles.HeaderBoxStyle, GUILayout.Height(28)))
154+
{
121155
GUILayout.FlexibleSpace();
122156
using (new EditorGUILayout.HorizontalScope(PlateauToolkitGUIStyles.HeaderContentStyle))
123157
{
124-
GUILayout.FlexibleSpace();
125-
GUILayout.Label(label, GUILayout.ExpandWidth(false));
158+
EditorGUI.DrawRect(scope.rect, PlateauToolkitGUIStyles.k_HeaderBackgroundColor);
159+
GUILayout.Label(label, PlateauToolkitGUIStyles.HeaderTextStyle, GUILayout.ExpandWidth(false));
126160
GUILayout.FlexibleSpace();
127161
}
128162
GUILayout.FlexibleSpace();
129163
}
130164

131-
BorderLine();
165+
EditorGUILayout.Space(bottomMargin);
166+
}
132167

133-
EditorGUILayout.Space(8);
168+
public static EditorGUILayout.HorizontalScope TabScope(float width)
169+
{
170+
var scope = new EditorGUILayout.HorizontalScope(PlateauToolkitGUIStyles.TabBoxStyle,
171+
GUILayout.Height(64));
172+
GUILayoutUtility.GetRect(width, 64);
173+
return scope;
134174
}
135175

136176
public static EditorGUILayout.VerticalScope FooterScope()
137177
{
138-
BorderLine();
139-
140-
var scope = new EditorGUILayout.VerticalScope(PlateauToolkitGUIStyles.FooterBoxStyle, GUILayout.Height(24));
141-
EditorGUI.DrawRect(scope.rect, PlateauToolkitGUIStyles.k_FooterBackgroundColor);
142-
178+
var scope = new EditorGUILayout.VerticalScope( GUILayout.Height(24));
143179
return scope;
144180
}
145181
}
146182

147183
public static class PlateauToolkitGUIStyles
148184
{
149-
public static readonly Color k_LineColor = new Color(40 / 255f, 40 / 255f, 40 / 255f, 1);
150-
public static readonly Color k_HeaderBackgroundColor = new Color(51 / 255f, 51 / 255f, 51 / 255f, 1);
185+
public static readonly Color k_LineColor = new Color(33 / 255f, 33 / 255f, 33 / 255f, 1);
186+
public static readonly Color k_HeaderBackgroundColor = new Color(62 / 255f, 62 / 255f, 62 / 255f, 1);
151187
public static readonly Color k_FooterBackgroundColor = new Color(51 / 255f, 51 / 255f, 51 / 255f, 1);
188+
public static readonly Color k_TabBackgroundColor = new Color(0, 0, 0, 0.5f);
189+
public static readonly Color k_TabActiveColor = new Color(88 / 255f, 88 / 255f, 88 / 255f, 1);
190+
public static readonly Color k_ButtonNormalColor = new Color(103 / 255f, 103 / 255f, 103 / 255f, 1);
191+
public static readonly Color k_ButtonPrimaryColor = new Color(0, 88 / 255f, 88 / 255f, 1);
192+
public static readonly Color k_ButtonDisableColor = new Color(0, 88 / 255f, 88 / 255f, 0.25f);
193+
public static readonly Color k_ButtonCancelColor = new Color(183 / 255f, 0, 0, 0.25f);
152194

153195
public static GUIStyle BorderStyle { get; }
154196
public static GUIStyle HeaderBoxStyle { get; }
155197
public static GUIStyle HeaderContentStyle { get; }
156198
public static GUIStyle FooterBoxStyle { get; }
199+
public static GUIStyle TabBoxStyle { get; }
200+
public static GUIStyle ButtonStyle { get; }
201+
public static GUIStyle TitleTextStyle { get; }
202+
public static GUIStyle HeaderTextStyle { get; }
157203

158204
static PlateauToolkitGUIStyles()
159205
{
@@ -173,47 +219,136 @@ static PlateauToolkitGUIStyles()
173219

174220
HeaderContentStyle = new GUIStyle(GUI.skin.box);
175221
HeaderContentStyle.normal.textColor = Color.white;
176-
HeaderContentStyle.alignment = TextAnchor.MiddleCenter;
222+
HeaderContentStyle.alignment = TextAnchor.MiddleLeft;
177223
HeaderContentStyle.margin = new RectOffset(0, 0, 0, 0);
178-
HeaderContentStyle.padding = new RectOffset(5, 5, 5, 5);
224+
HeaderContentStyle.padding = new RectOffset(15, 15, 10, 10);
225+
226+
TabBoxStyle = new GUIStyle( GUIStyle.none);
227+
TabBoxStyle.normal.textColor = Color.white;
228+
TabBoxStyle.alignment = TextAnchor.MiddleCenter;
229+
TabBoxStyle.margin = new RectOffset(15, 15, 0, 0);
230+
TabBoxStyle.padding = new RectOffset(20, 20, 0, 0);
231+
232+
ButtonStyle = new GUIStyle(GUIStyle.none)
233+
{
234+
fontSize = 12,
235+
alignment = TextAnchor.MiddleCenter,
236+
normal = { textColor = Color.white}
237+
};
238+
239+
TitleTextStyle = new GUIStyle(EditorStyles.boldLabel)
240+
{
241+
fontSize = 14,
242+
alignment = TextAnchor.MiddleCenter,
243+
normal = { textColor = Color.white }
244+
};
245+
246+
HeaderTextStyle = new GUIStyle()
247+
{
248+
fontSize = 12,
249+
normal = { textColor = Color.white }
250+
};
179251
}
180252
}
181253

182254
public readonly struct PlateauToolkitImageButtonGUI
183255
{
256+
static Texture2D s_WhiteTexture;
257+
static Texture2D WhiteTexture
258+
{
259+
get
260+
{
261+
if (s_WhiteTexture == null)
262+
{
263+
Color[] pixels = { Color.white };
264+
var texture = new Texture2D(1, 1);
265+
texture.SetPixels(pixels);
266+
texture.Apply();
267+
268+
s_WhiteTexture = texture;
269+
}
270+
return s_WhiteTexture;
271+
}
272+
}
273+
184274
readonly float m_Width;
185275
readonly float m_Height;
276+
readonly Color m_Color;
277+
readonly bool m_IsPositionCenter;
186278

187-
public PlateauToolkitImageButtonGUI(float width, float height)
279+
public PlateauToolkitImageButtonGUI(float width, float height, Color color, bool isPositionCenter = true)
188280
{
189281
m_Width = width;
190282
m_Height = height;
283+
m_Color = color;
284+
m_IsPositionCenter = isPositionCenter;
191285
}
192286

193-
public bool Button(string iconTexturePath, Color? buttonColor = null)
287+
public bool TabButton(
288+
string iconTexturePath,
289+
Rect rect,
290+
bool isActive)
194291
{
195-
Color defaultColor = GUI.backgroundColor;
196-
using (PlateauToolkitEditorGUILayout.BackgroundColorScope(buttonColor.GetValueOrDefault(defaultColor)))
292+
if (isActive)
197293
{
294+
GUI.DrawTexture(rect, WhiteTexture, ScaleMode.StretchToFill, true, 0, m_Color, 0, 4);
295+
}
296+
297+
var buttonStyle = new GUIStyle(GUIStyle.none);
298+
bool button = GUI.Button(
299+
rect,
300+
(Texture2D)AssetDatabase.LoadAssetAtPath(iconTexturePath, typeof(Texture2D)),
301+
buttonStyle);
302+
303+
return button;
304+
}
305+
306+
public bool Button(string label)
307+
{
308+
float scopeWidth = m_IsPositionCenter ? 0 : m_Width;
309+
using (var scope = new EditorGUILayout.HorizontalScope(GUILayout.Height(m_Height), GUILayout.Width(scopeWidth)))
310+
{
311+
GUILayout.FlexibleSpace();
312+
313+
float centerY = (scope.rect.height - m_Height) / 2;
314+
float centerX = (scope.rect.width - m_Width) / 2;
315+
var buttonRect = new Rect(scope.rect.x + centerX, scope.rect.y + centerY, m_Width, m_Height);
316+
317+
GUI.DrawTexture(buttonRect, WhiteTexture, ScaleMode.StretchToFill, true, 0, m_Color, 0, 5);
318+
198319
bool button = GUILayout.Button(
199-
(Texture2D)AssetDatabase.LoadAssetAtPath(iconTexturePath, typeof(Texture2D)),
200-
GUILayout.Width(m_Width),
201-
GUILayout.Height(m_Height));
320+
label,
321+
PlateauToolkitGUIStyles.ButtonStyle,
322+
GUILayout.Height(m_Height),
323+
GUILayout.Width(m_Width));
202324

325+
GUILayout.FlexibleSpace();
203326
return button;
204327
}
205328
}
206329

207-
public bool Button(Texture2D texture2D, Color? buttonColor = null)
330+
public bool Button(Texture2D texture2D, RectOffset padding)
208331
{
209-
Color defaultColor = GUI.backgroundColor;
210-
using (PlateauToolkitEditorGUILayout.BackgroundColorScope(buttonColor.GetValueOrDefault(defaultColor)))
332+
using (var scope = new EditorGUILayout.HorizontalScope(GUILayout.Height(m_Height)))
211333
{
334+
GUILayout.FlexibleSpace();
335+
336+
float centerY = (scope.rect.height - m_Height) / 2;
337+
float centerX = (scope.rect.width - m_Width) / 2;
338+
var buttonRect = new Rect(scope.rect.x + centerX, scope.rect.y + centerY, m_Width, m_Height);
339+
340+
GUI.DrawTexture(buttonRect, WhiteTexture, ScaleMode.StretchToFill, true, 0, m_Color, 0, 5);
341+
342+
var style = PlateauToolkitGUIStyles.ButtonStyle;
343+
style.padding = padding;
344+
212345
bool button = GUILayout.Button(
213346
texture2D,
214-
GUILayout.Width(m_Width),
215-
GUILayout.Height(m_Height));
347+
style,
348+
GUILayout.Height(m_Height),
349+
GUILayout.Width(m_Width));
216350

351+
GUILayout.FlexibleSpace();
217352
return button;
218353
}
219354
}

PlateauToolkit.Foundation/Editor/PlateauToolkitPaths.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@ namespace PlateauToolkit.Editor
22
{
33
public static class PlateauToolkitPaths
44
{
5-
const string k_SpritesFolder = "Packages/com.unity.plateautoolkit/PlateauToolkit.Foundation/Editor/Sprites";
6-
const string k_UIFolder = "Packages/com.unity.plateautoolkit/PlateauToolkit.Foundation/Editor/UI";
5+
const string k_SpritesFolder = "Packages/com.synesthesias.plateau-unity-toolkit/PlateauToolkit.Foundation/Editor/Sprites";
6+
const string k_UIFolder = "Packages/com.synesthesias.plateau-unity-toolkit/PlateauToolkit.Foundation/Editor/UI";
77
public static string PlateauLogo { get; } = $"{k_SpritesFolder}/PlateauLogo.png";
8+
public static string PlateauTitleBackground { get; } = $"{k_SpritesFolder}/PlateauTitleBackground.png";
89
public static string SavePointOverlayUxml { get; } = $"{k_UIFolder}/SavePointOverlay.uxml";
910

1011
}

0 commit comments

Comments
 (0)