@@ -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
0 commit comments