Skip to content

Commit dfd3bcd

Browse files
committed
Minor improvements for play mode
1 parent 3f1d851 commit dfd3bcd

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

Source/Editor/Modules/SimulationModule.cs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public sealed class SimulationModule : EditorModule
2020
private bool _updateOrFixedUpdateWasCalled;
2121
private long _breakpointHangFlag;
2222
private EditorWindow _enterPlayFocusedWindow;
23-
private Scene[] _scenesToReload;
23+
private Guid[] _scenesToReload;
2424

2525
internal SimulationModule(Editor editor)
2626
: base(editor)
@@ -138,8 +138,15 @@ public void RequestStartPlayGame()
138138
Editor.Simulation.RequestStartPlayScenes();
139139
return;
140140
}
141+
if (!FlaxEngine.Content.GetAssetInfo(firstScene.ID, out var info))
142+
{
143+
Editor.LogWarning("Invalid First Scene in Game Settings.");
144+
}
141145

142-
_scenesToReload = Level.Scenes;
146+
// Load scenes after entering the play mode
147+
_scenesToReload = new Guid[Level.ScenesCount];
148+
for (int i = 0; i < _scenesToReload.Length; i++)
149+
_scenesToReload[i] = Level.GetScene(i).ID;
143150
Level.UnloadAllScenes();
144151
Level.LoadScene(firstScene);
145152

@@ -153,8 +160,8 @@ private void OnPlayGameEnd()
153160

154161
Level.UnloadAllScenes();
155162

156-
foreach (var scene in _scenesToReload)
157-
Level.LoadScene(scene.ID);
163+
foreach (var sceneId in _scenesToReload)
164+
Level.LoadScene(sceneId);
158165
}
159166

160167
/// <summary>

0 commit comments

Comments
 (0)