Skip to content

Commit 527f3b1

Browse files
committed
Update UX
1 parent b95ce57 commit 527f3b1

4 files changed

Lines changed: 103 additions & 53 deletions

File tree

CHANGELOG.md

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,22 @@ All notable changes to this project will be documented in this file.
44

55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7-
## [0.0.4] - 2022-09-28
7+
## [0.0.5] - 2022-10-17
8+
9+
### Added
10+
- Button tooltips.
11+
12+
### Changed
13+
- Changed global control buttons to use icons in Scriptable Scene Manager.
14+
- Moved collection controls next to title in Scriptable Scene Manager.
15+
- Updated package.json with new version.
16+
17+
## [0.0.4] - 2022-10-16
818

919
### Added
1020
- Added more initial scene load options to `ScriptableSceneController`.
1121
- Added more guards when loading invalid scenes.
12-
-
22+
1323
### Changed
1424
- Updated package.json with new version.
1525

Editor/ScriptableSceneManagerWindow.cs

Lines changed: 81 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,17 @@ internal sealed class ScriptableSceneManagerWindow : EditorWindow
2222

2323
#region Private Fields
2424

25+
private static readonly GUILayoutOption PlayModeButtonWidth = GUILayout.Width(30f);
26+
2527
private const float CollectionListFieldMargin = 2f;
2628
private const float CollectionListMargin = 8f;
2729
private const float CollectionListControlsExtraMargin = 2f;
28-
private const float CollectionListControlButtonMargin = 9f;
30+
private const float CollectionListControlButtonWidth = 50f;
31+
32+
private const float CollectionListControlsWidth =
33+
CollectionListControlButtonWidth * 3f + CollectionListControlsExtraMargin * 2f;
2934

30-
private const int CollectionFieldCount = 4;
35+
private const int CollectionFieldCount = 3;
3136

3237
private List<BaseScriptableSceneCollection> sceneCollections;
3338
private ReorderableList sceneCollectionsList;
@@ -87,16 +92,15 @@ private static void DrawPlayModeControls()
8792
var isEnabled = GUI.enabled;
8893
GUI.enabled = Application.isPlaying && isEnabled;
8994

90-
// EditorGUILayout.BeginHorizontal(new GUIStyle
91-
// {
92-
// alignment = TextAnchor.MiddleCenter
93-
// });
95+
EditorGUILayout.BeginHorizontal();
96+
GUILayout.FlexibleSpace();
9497

9598
DrawStopGameButton();
9699
DrawPauseGameButton();
97100
DrawStepGameButton();
98101

99-
// EditorGUILayout.EndHorizontal();
102+
GUILayout.FlexibleSpace();
103+
EditorGUILayout.EndHorizontal();
100104

101105
GUI.enabled = isEnabled;
102106
}
@@ -108,7 +112,7 @@ private static void DrawStopGameButton()
108112
"Stop game"
109113
);
110114

111-
if (ScriptableSceneGUI.Button(iconContent))
115+
if (ScriptableSceneGUI.Button(iconContent, PlayModeButtonWidth))
112116
{
113117
ScriptableSceneEditorUtilities.StopGame();
114118
}
@@ -122,7 +126,13 @@ private static void DrawPauseGameButton()
122126
);
123127

124128
var isPausedOld = EditorApplication.isPaused;
125-
var isPausedNew = ScriptableSceneGUI.Toggle(isPausedOld, iconContent, "Button");
129+
var isPausedNew = ScriptableSceneGUI.Toggle(
130+
isPausedOld,
131+
iconContent,
132+
"Button",
133+
PlayModeButtonWidth
134+
);
135+
126136
if (isPausedOld != isPausedNew)
127137
{
128138
ScriptableSceneEditorUtilities.SetPausedGame(isPausedNew);
@@ -136,7 +146,7 @@ private static void DrawStepGameButton()
136146
"Step game forward by one frame"
137147
);
138148

139-
if (ScriptableSceneGUI.Button(iconContent))
149+
if (ScriptableSceneGUI.Button(iconContent, PlayModeButtonWidth))
140150
{
141151
ScriptableSceneEditorUtilities.StepGame();
142152
}
@@ -184,12 +194,14 @@ List<BaseScriptableSceneCollection> collections
184194
drawElementCallback = OnDrawElement
185195
};
186196

197+
// ReSharper disable once InconsistentNaming
187198
float OnGetElementHeight(int index)
188199
{
189200
var collection = collections[index];
190201
return GetElementHeight(collection);
191202
}
192203

204+
// ReSharper disable once InconsistentNaming
193205
void OnReorder(ReorderableList reorderableList)
194206
{
195207
for (var index = 0; index < collections.Count; index++)
@@ -199,6 +211,7 @@ void OnReorder(ReorderableList reorderableList)
199211
}
200212
}
201213

214+
// ReSharper disable once InconsistentNaming
202215
void OnDrawElement(Rect rect, int index, bool isActive, bool isFocused)
203216
{
204217
var collection = collections[index];
@@ -251,32 +264,13 @@ private static void DrawSceneCollection(Rect rect, BaseScriptableSceneCollection
251264
fieldRect.y += fieldYOffset;
252265
DrawSceneCountField(fieldRect, collection);
253266

254-
fieldRect.y += fieldYOffset + CollectionListControlsExtraMargin;
255-
DrawControls(EditorGUI.IndentedRect(fieldRect), collection);
267+
// TODO: unsure if wanna show controls inside the foldout or next to it.
268+
// fieldRect.y += fieldYOffset + CollectionListControlsExtraMargin;
269+
// DrawControls(EditorGUI.IndentedRect(fieldRect), collection);
256270

257271
EditorGUI.indentLevel--;
258272
}
259273

260-
private static void DrawControls(Rect rect, BaseScriptableSceneCollection collection)
261-
{
262-
var isAddedScenes = collection.Scenes.Any();
263-
var isEnabled = GUI.enabled;
264-
265-
GUI.enabled = isEnabled && isAddedScenes && Application.isPlaying == false;
266-
267-
rect.width = rect.width / 3f - CollectionListControlButtonMargin / 3f;
268-
DrawOpenButton(rect, collection);
269-
270-
rect.x += rect.width + CollectionListControlButtonMargin / 2f;
271-
DrawPlayButton(rect, collection);
272-
273-
GUI.enabled = isEnabled && isAddedScenes && Application.isPlaying;
274-
rect.x += rect.width + CollectionListControlButtonMargin / 2f;
275-
DrawLoadButton(rect, collection);
276-
277-
GUI.enabled = isEnabled;
278-
}
279-
280274
private static bool DrawTitle(Rect rect, BaseScriptableSceneCollection collection)
281275
{
282276
var name = collection.Name;
@@ -287,8 +281,13 @@ private static bool DrawTitle(Rect rect, BaseScriptableSceneCollection collectio
287281
EditorGUI.BeginChangeCheck();
288282

289283
var style = GetFoldoutTitleStyle();
284+
285+
rect.width -= CollectionListControlsWidth;
290286
isExpanded = EditorGUI.Foldout(rect, isExpanded, prettyName, true, style);
291287

288+
rect.x += rect.width;
289+
DrawControls(rect, collection);
290+
292291
if (EditorGUI.EndChangeCheck())
293292
{
294293
collection.SetExpanded(isExpanded);
@@ -297,6 +296,27 @@ private static bool DrawTitle(Rect rect, BaseScriptableSceneCollection collectio
297296
return isExpanded;
298297
}
299298

299+
private static void DrawControls(Rect rect, BaseScriptableSceneCollection collection)
300+
{
301+
var isAddedScenes = collection.Scenes.Any();
302+
var isEnabled = GUI.enabled;
303+
304+
GUI.enabled = isEnabled && isAddedScenes && Application.isPlaying == false;
305+
306+
rect.width = CollectionListControlButtonWidth;
307+
DrawOpenButton(rect, collection);
308+
309+
rect.x += CollectionListControlButtonWidth + CollectionListControlsExtraMargin;
310+
DrawPlayButton(rect, collection);
311+
312+
GUI.enabled = isEnabled && isAddedScenes && Application.isPlaying;
313+
314+
rect.x += CollectionListControlButtonWidth + CollectionListControlsExtraMargin;
315+
DrawLoadButton(rect, collection);
316+
317+
GUI.enabled = isEnabled;
318+
}
319+
300320
private static void DrawAssetField(Rect rect, BaseScriptableSceneCollection collection)
301321
{
302322
ScriptableSceneGUI.ObjectField(rect, "Scene Collection", collection, false);
@@ -314,38 +334,54 @@ private static void DrawSceneCountField(Rect rect, BaseScriptableSceneCollection
314334

315335
private static void DrawOpenButton(Rect rect, BaseScriptableSceneCollection collection)
316336
{
317-
var iconContent = EditorGUIUtility.IconContent(
318-
"Folder Icon",
319-
"Open scene collection"
337+
// TODO: unsure if wanna use icons or not
338+
// var iconContent = EditorGUIUtility.IconContent(
339+
// "Folder Icon",
340+
// "Open scene collection"
341+
// );
342+
343+
var content = new GUIContent(
344+
"Open",
345+
"Open all scenes in selected Scene Collection"
320346
);
321347

322-
if (ScriptableSceneGUI.Button(rect, iconContent))
348+
if (ScriptableSceneGUI.Button(rect, content))
323349
{
324350
collection.Open();
325351
}
326352
}
327353

328354
private static void DrawPlayButton(Rect rect, BaseScriptableSceneCollection collection)
329355
{
330-
var iconContent = EditorGUIUtility.IconContent(
331-
"PlayButton",
332-
"Run game in selected scene collection"
356+
// var iconContent = EditorGUIUtility.IconContent(
357+
// "PlayButton",
358+
// "Run game in selected scene collection"
359+
// );
360+
361+
var content = new GUIContent(
362+
"Play",
363+
"Play the game in selected Scene Collection"
333364
);
334365

335-
if (ScriptableSceneGUI.Button(rect, iconContent))
366+
if (ScriptableSceneGUI.Button(rect, content))
336367
{
337368
collection.Play();
338369
}
339370
}
340371

341372
private static void DrawLoadButton(Rect rect, BaseScriptableSceneCollection collection)
342373
{
343-
var iconContent = EditorGUIUtility.IconContent(
344-
"SceneLoadIn",
345-
"Load scene collection (runtime)"
374+
// var iconContent = EditorGUIUtility.IconContent(
375+
// "SceneLoadIn",
376+
// "Load scene collection (runtime)"
377+
// );
378+
379+
var content = new GUIContent(
380+
"Load",
381+
"Load scene collection through the Scene Controller (runtime)"
346382
);
347383

348-
if (ScriptableSceneGUI.Button(rect, iconContent))
384+
if (ScriptableSceneGUI.Button(rect, content))
349385
{
350386
collection.Load();
351387
}
@@ -355,8 +391,7 @@ private static GUIStyle GetFoldoutTitleStyle()
355391
{
356392
return new GUIStyle(EditorStyles.foldout)
357393
{
358-
fontStyle = FontStyle.Bold,
359-
clipping = TextClipping.Clip
394+
fontStyle = FontStyle.Bold
360395
};
361396
}
362397

Editor/Utilities/ScriptableSceneGUI.cs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,14 @@ internal static bool Toggle(bool isToggled, string label, GUIStyle style)
1717
return GUILayout.Toggle(isToggled, label, style);
1818
}
1919

20-
internal static bool Toggle(bool isToggled, GUIContent content, GUIStyle style)
20+
internal static bool Toggle(
21+
bool isToggled,
22+
GUIContent content,
23+
GUIStyle style,
24+
params GUILayoutOption[] options
25+
)
2126
{
22-
return GUILayout.Toggle(isToggled, content, style);
27+
return GUILayout.Toggle(isToggled, content, style, options);
2328
}
2429

2530
internal static T ObjectField<T>(
@@ -60,9 +65,9 @@ internal static bool Button(Rect rect, string text)
6065
return GUI.Button(rect, text);
6166
}
6267

63-
internal static bool Button(GUIContent content)
68+
internal static bool Button(GUIContent content, params GUILayoutOption[] options)
6469
{
65-
return GUILayout.Button(content, GUILayout.Width(20f));
70+
return GUILayout.Button(content, options);
6671
}
6772

6873
internal static bool Button(string text)

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"name": "CHARK",
66
"url": "https://chark.io"
77
},
8-
"version": "0.0.4",
8+
"version": "0.0.5",
99
"unity": "2020.3",
1010
"description": "Simple scene loading and management system for Unity Engine, implemented via scriptable objects.",
1111
"keywords": [

0 commit comments

Comments
 (0)