From 22e34cb2b4458b16dfb95961484959e0475705fb Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Sat, 4 Nov 2023 19:30:16 +0100 Subject: [PATCH] Fix crash on editor startup without code editor selected #1872 --- Source/Editor/States/LoadingState.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Source/Editor/States/LoadingState.cs b/Source/Editor/States/LoadingState.cs index 698dc192f..d48918e1b 100644 --- a/Source/Editor/States/LoadingState.cs +++ b/Source/Editor/States/LoadingState.cs @@ -56,12 +56,14 @@ namespace FlaxEditor.States else if (Editor.Options.Options.General.ForceScriptCompilationOnStartup && !skipCompile) { // Generate project files when Cache is missing or was cleared previously - if (!Directory.Exists(Path.Combine(Editor.GameProject?.ProjectFolderPath, "Cache", "Intermediate")) || - !Directory.Exists(Path.Combine(Editor.GameProject?.ProjectFolderPath, "Cache", "Projects"))) + var projectFolderPath = Editor.GameProject?.ProjectFolderPath; + if (!Directory.Exists(Path.Combine(projectFolderPath, "Cache", "Intermediate")) || + !Directory.Exists(Path.Combine(projectFolderPath, "Cache", "Projects"))) { - var customArgs = Editor.Instance.CodeEditing.SelectedEditor.GenerateProjectCustomArgs; + var customArgs = Editor.CodeEditing.SelectedEditor?.GenerateProjectCustomArgs; ScriptsBuilder.GenerateProject(customArgs); } + // Compile scripts before loading any scenes, then we load them and can open scenes ScriptsBuilder.Compile(); }