diff --git a/Source/Editor/Editor.cs b/Source/Editor/Editor.cs index 811599d9c..a775139a6 100644 --- a/Source/Editor/Editor.cs +++ b/Source/Editor/Editor.cs @@ -271,10 +271,14 @@ namespace FlaxEditor module.OnEndInit(); } - internal void Init(bool isHeadless, bool skipCompile) + private Guid _startupSceneArgument; + + internal void Init(bool isHeadless, bool skipCompile, Guid sceneId) { + Debug.Log("sceneId string : " + JsonSerializer.GetStringID(sceneId)); EnsureState(); _isHeadlessMode = isHeadless; + _startupSceneArgument = sceneId; Log("Editor init"); if (isHeadless) Log("Running in headless mode"); @@ -332,6 +336,17 @@ namespace FlaxEditor } // Load scene + + // scene cmd line argument + var scene = ContentDatabase.Find(_startupSceneArgument); + if (scene is SceneItem) + { + Editor.Log("Loading scene specified in command line"); + Scene.OpenScene(_startupSceneArgument); + return; + } + + // if no scene cmd line argument is provided var startupSceneMode = Options.Options.General.StartupSceneMode; if (startupSceneMode == GeneralOptions.StartupSceneModes.LastOpened && !ProjectCache.HasCustomData(ProjectDataLastScene)) { diff --git a/Source/Editor/Managed/ManagedEditor.cpp b/Source/Editor/Managed/ManagedEditor.cpp index 59475110e..cdae24a1d 100644 --- a/Source/Editor/Managed/ManagedEditor.cpp +++ b/Source/Editor/Managed/ManagedEditor.cpp @@ -210,7 +210,7 @@ ManagedEditor::~ManagedEditor() void ManagedEditor::Init() { // Note: editor modules should perform quite fast init, any longer things should be done in async during 'editor splash screen time - void* args[2]; + void* args[3]; MClass* mclass = GetClass(); if (mclass == nullptr) { @@ -231,6 +231,12 @@ void ManagedEditor::Init() bool skipCompile = CommandLine::Options.SkipCompile.IsTrue(); args[0] = &isHeadless; args[1] = &skipCompile; + Guid sceneId; + if (Guid::Parse(CommandLine::Options.Game.GetValue(), sceneId)) + { + sceneId = Guid::Empty; + } + args[2] = CommandLine::Options.Game.HasValue() ? &sceneId : nullptr; initMethod->Invoke(instance, args, &exception); if (exception) {