Skip to content

Commit d796256

Browse files
committed
Cleanup todos, fixup clipping when showing status icon, bump version and update changelog
1 parent 7be3c1d commit d796256

5 files changed

Lines changed: 64 additions & 52 deletions

File tree

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@ 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.6] - 2022-10-17
8+
9+
### Added
10+
- Status icon which shown in Scene Manager indicating if a collection is added to Build Settings.
11+
- Warnings on `ScriptableSceneCollection` and `ScriptableScene` assets which will be if a scene is not added to Build Settings.
12+
- Button in `ScriptableScene` editor to add scene to Build Settings.
13+
714
## [0.0.5] - 2022-10-16
815

916
### Added

Editor/ScriptableSceneManagerWindow.cs

Lines changed: 29 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -111,11 +111,8 @@ private static void DrawPlayModeControls()
111111

112112
private static void DrawStopGameButton()
113113
{
114-
// TODO: use scene utils.
115-
var iconContent = EditorGUIUtility.IconContent(
116-
"PreMatQuad",
117-
"Stop game"
118-
);
114+
var icon = ScriptableSceneEditorUtilities.GetStopButtonIcon();
115+
var iconContent = new GUIContent(icon, "Stop Game");
119116

120117
if (ScriptableSceneGUI.Button(iconContent, PlayModeButtonWidth))
121118
{
@@ -125,33 +122,28 @@ private static void DrawStopGameButton()
125122

126123
private static void DrawPauseGameButton()
127124
{
128-
// TODO: use scene utils.
129-
var iconContent = EditorGUIUtility.IconContent(
130-
"PauseButton",
131-
"Pause game"
132-
);
125+
var icon = ScriptableSceneEditorUtilities.GetPauseButtonIcon();
126+
var iconContent = new GUIContent(icon, "Pause Game");
127+
128+
EditorGUI.BeginChangeCheck();
133129

134-
var isPausedOld = EditorApplication.isPaused;
135-
var isPausedNew = ScriptableSceneGUI.Toggle(
136-
isPausedOld,
130+
var isPaused = ScriptableSceneGUI.Toggle(
131+
EditorApplication.isPaused,
137132
iconContent,
138133
"Button",
139134
PlayModeButtonWidth
140135
);
141136

142-
if (isPausedOld != isPausedNew)
137+
if (EditorGUI.EndChangeCheck())
143138
{
144-
ScriptableSceneEditorUtilities.SetPausedGame(isPausedNew);
139+
ScriptableSceneEditorUtilities.SetPausedGame(isPaused);
145140
}
146141
}
147142

148143
private static void DrawStepGameButton()
149144
{
150-
// TODO: use scene utils.
151-
var iconContent = EditorGUIUtility.IconContent(
152-
"StepButton",
153-
"Step game forward by one frame"
154-
);
145+
var icon = ScriptableSceneEditorUtilities.GetStepButtonIcon();
146+
var iconContent = new GUIContent(icon, "Step one frame");
155147

156148
if (ScriptableSceneGUI.Button(iconContent, PlayModeButtonWidth))
157149
{
@@ -271,26 +263,24 @@ private static void DrawSceneCollection(Rect rect, BaseScriptableSceneCollection
271263
fieldRect.y += fieldYOffset;
272264
DrawSceneCountField(fieldRect, collection);
273265

274-
// TODO: unsure if wanna show controls inside the foldout or next to it.
275-
// fieldRect.y += fieldYOffset + CollectionListControlsExtraMargin;
276-
// DrawControls(EditorGUI.IndentedRect(fieldRect), collection);
277-
278266
EditorGUI.indentLevel--;
279267
}
280268

281269
private static bool DrawTitle(Rect rect, BaseScriptableSceneCollection collection)
282270
{
283-
var name = collection.Name;
284-
var prettyName = ObjectNames.NicifyVariableName(name);
285-
286-
var isExpanded = collection.IsExpanded();
287-
288271
EditorGUI.BeginChangeCheck();
289272

290-
var style = GetFoldoutTitleStyle();
273+
var titleTextWidth = rect.width - CollectionTitleActionsWidth;
274+
var titleText = ObjectNames.NicifyVariableName(collection.Name);
275+
var titleStyle = GetFoldoutTitleStyle(titleTextWidth);
291276

292-
rect.width -= CollectionTitleActionsWidth;
293-
isExpanded = EditorGUI.Foldout(rect, isExpanded, prettyName, true, style);
277+
rect.width = titleTextWidth;
278+
var isExpanded = ScriptableSceneGUI.Foldout(
279+
rect,
280+
collection.IsExpanded(),
281+
titleText,
282+
titleStyle
283+
);
294284

295285
rect.x += rect.width;
296286
DrawStatusIndicator(rect, collection);
@@ -324,7 +314,9 @@ private static void DrawControls(Rect rect, BaseScriptableSceneCollection collec
324314
var isAddedScenes = collection.Scenes.Any();
325315
var isEnabled = GUI.enabled;
326316

327-
GUI.enabled = isEnabled && isAddedScenes && Application.isPlaying == false;
317+
GUI.enabled = isEnabled
318+
&& isAddedScenes
319+
&& EditorApplication.isPlayingOrWillChangePlaymode == false;
328320

329321
rect.width = CollectionTitleButtonWidth;
330322
DrawOpenButton(rect, collection);
@@ -357,12 +349,6 @@ private static void DrawSceneCountField(Rect rect, BaseScriptableSceneCollection
357349

358350
private static void DrawOpenButton(Rect rect, BaseScriptableSceneCollection collection)
359351
{
360-
// TODO: unsure if wanna use icons or not
361-
// var iconContent = EditorGUIUtility.IconContent(
362-
// "Folder Icon",
363-
// "Open scene collection"
364-
// );
365-
366352
var content = new GUIContent(
367353
"Open",
368354
"Open all scenes in selected Scene Collection"
@@ -376,11 +362,6 @@ private static void DrawOpenButton(Rect rect, BaseScriptableSceneCollection coll
376362

377363
private static void DrawPlayButton(Rect rect, BaseScriptableSceneCollection collection)
378364
{
379-
// var iconContent = EditorGUIUtility.IconContent(
380-
// "PlayButton",
381-
// "Run game in selected scene collection"
382-
// );
383-
384365
var content = new GUIContent(
385366
"Play",
386367
"Play the game in selected Scene Collection"
@@ -394,11 +375,6 @@ private static void DrawPlayButton(Rect rect, BaseScriptableSceneCollection coll
394375

395376
private static void DrawLoadButton(Rect rect, BaseScriptableSceneCollection collection)
396377
{
397-
// var iconContent = EditorGUIUtility.IconContent(
398-
// "SceneLoadIn",
399-
// "Load scene collection (runtime)"
400-
// );
401-
402378
var content = new GUIContent(
403379
"Load",
404380
"Load scene collection through the Scene Controller (runtime)"
@@ -410,11 +386,13 @@ private static void DrawLoadButton(Rect rect, BaseScriptableSceneCollection coll
410386
}
411387
}
412388

413-
private static GUIStyle GetFoldoutTitleStyle()
389+
private static GUIStyle GetFoldoutTitleStyle(float width)
414390
{
415391
return new GUIStyle(EditorStyles.foldout)
416392
{
417-
fontStyle = FontStyle.Bold
393+
fontStyle = FontStyle.Bold,
394+
clipping = TextClipping.Clip,
395+
fixedWidth = width
418396
};
419397
}
420398

Editor/Utilities/ScriptableSceneEditorUtilities.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,22 @@ internal static bool IsAddedToBuildSettings(this BaseScriptableScene scene)
242242
return buildIndex >= 0;
243243
}
244244

245+
internal static Texture GetStopButtonIcon()
246+
{
247+
return GetIcon("PreMatQuad");
248+
}
249+
250+
internal static Texture GetPauseButtonIcon()
251+
{
252+
return GetIcon("PauseButton");
253+
}
254+
255+
internal static Texture GetStepButtonIcon()
256+
{
257+
return GetIcon("StepButton");
258+
}
259+
260+
245261
internal static Texture GetBuildStatusSuccessIcon()
246262
{
247263
return GetIcon("P4_CheckOutRemote@2x");

Editor/Utilities/ScriptableSceneGUI.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,17 @@ internal static class ScriptableSceneGUI
1212
{
1313
#region Internal Methods
1414

15+
internal static bool Foldout(Rect rect, bool isExpanded, string text, GUIStyle style)
16+
{
17+
return EditorGUI.Foldout(
18+
rect,
19+
isExpanded,
20+
text,
21+
true,
22+
style
23+
);
24+
}
25+
1526
internal static void WarningHelpBox(string message)
1627
{
1728
EditorGUILayout.HelpBox(message, MessageType.Warning);

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.5",
8+
"version": "0.0.6",
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)