diff --git a/Source/Editor/Modules/ContentDatabaseModule.cs b/Source/Editor/Modules/ContentDatabaseModule.cs index 5d30d3c41..944f1dce6 100644 --- a/Source/Editor/Modules/ContentDatabaseModule.cs +++ b/Source/Editor/Modules/ContentDatabaseModule.cs @@ -21,6 +21,7 @@ namespace FlaxEditor.Modules private bool _enableEvents; private bool _isDuringFastSetup; private bool _rebuildFlag; + private bool _rebuildInitFlag; private int _itemsCreated; private int _itemsDeleted; private readonly HashSet _dirtyNodes = new HashSet(); @@ -820,6 +821,7 @@ namespace FlaxEditor.Modules Profiler.BeginEvent("ContentDatabase.Rebuild"); var startTime = Platform.TimeSeconds; _rebuildFlag = false; + _rebuildInitFlag = false; _enableEvents = false; // Load all folders @@ -1240,6 +1242,15 @@ namespace FlaxEditor.Modules FlaxEngine.Scripting.InvokeOnUpdate(() => OnImportFileDone(path)); }; _enableEvents = true; + _rebuildInitFlag = true; + } + + /// + public override void OnEndInit() + { + // Handle init when project was loaded without scripts loading () + if (_rebuildInitFlag) + RebuildInternal(); } private void OnImportFileDone(string path) diff --git a/Source/Editor/Modules/SceneModule.cs b/Source/Editor/Modules/SceneModule.cs index a144d6f4c..f1fae600d 100644 --- a/Source/Editor/Modules/SceneModule.cs +++ b/Source/Editor/Modules/SceneModule.cs @@ -58,7 +58,7 @@ namespace FlaxEditor.Modules : base(editor) { // After editor cache but before the windows - InitOrder = -900; + InitOrder = -800; } /// diff --git a/Source/Editor/Modules/UIModule.cs b/Source/Editor/Modules/UIModule.cs index a16dedef5..1dc1d0bba 100644 --- a/Source/Editor/Modules/UIModule.cs +++ b/Source/Editor/Modules/UIModule.cs @@ -160,7 +160,7 @@ namespace FlaxEditor.Modules internal UIModule(Editor editor) : base(editor) { - InitOrder = -90; + InitOrder = -70; VisjectSurfaceBackground = FlaxEngine.Content.LoadAsyncInternal("Editor/VisjectSurface"); ColorValueBox.ShowPickColorDialog += ShowPickColorDialog; } diff --git a/Source/Editor/Modules/WindowsModule.cs b/Source/Editor/Modules/WindowsModule.cs index 186ae1405..530a788a8 100644 --- a/Source/Editor/Modules/WindowsModule.cs +++ b/Source/Editor/Modules/WindowsModule.cs @@ -816,15 +816,31 @@ namespace FlaxEditor.Modules internal void AddToRestore(AssetEditorWindow win) { - var type = win.GetType(); - var winData = new WindowRestoreData(); + AddToRestore(win, win.GetType(), new WindowRestoreData + { + AssetItemID = win.Item.ID, + }); + } + + internal void AddToRestore(CustomEditorWindow win) + { + AddToRestore(win.Window, win.GetType(), new WindowRestoreData()); + } + + private void AddToRestore(EditorWindow win, Type type, WindowRestoreData winData) + { + // Validate if can restore type + var constructor = type.GetConstructor(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, Type.EmptyTypes, null); + if (constructor == null || type.IsGenericType) + return; + var panel = win.ParentDockPanel; // Ensure that this window is only selected following recompilation // if it was the active tab in its dock panel. Otherwise, there is a // risk of interrupting the user's workflow by potentially selecting // background tabs. - var window = win.RootWindow?.Window; + var window = win.RootWindow.Window; winData.SelectOnShow = panel.SelectedTab == win; winData.DockedTabIndex = 0; if (panel is FloatWindowDockPanel && window != null && panel.TabsCount == 1) @@ -860,52 +876,6 @@ namespace FlaxEditor.Modules } winData.AssemblyName = type.Assembly.GetName().Name; winData.TypeName = type.FullName; - winData.AssetItemID = win.Item.ID; - _restoreWindows.Add(winData); - } - - internal void AddToRestore(CustomEditorWindow win) - { - var type = win.GetType(); - - // Validate if can restore type - var constructor = type.GetConstructor(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, Type.EmptyTypes, null); - if (constructor == null || type.IsGenericType) - return; - - var winData = new WindowRestoreData(); - var panel = win.Window.ParentDockPanel; - - // Ensure that this window is only selected following recompilation - // if it was the active tab in its dock panel. Otherwise, there is a - // risk of interrupting the user's workflow by potentially selecting - // background tabs. - winData.SelectOnShow = panel.SelectedTab == win.Window; - if (panel is FloatWindowDockPanel) - { - winData.DockState = DockState.Float; - var window = win.Window.RootWindow.Window; - winData.FloatPosition = window.Position; - winData.FloatSize = window.ClientSize; - winData.Maximize = window.IsMaximized; - winData.Minimize = window.IsMinimized; - } - else - { - if (panel.TabsCount > 1) - { - winData.DockState = DockState.DockFill; - winData.DockedTo = panel; - } - else - { - winData.DockState = panel.TryGetDockState(out var splitterValue); - winData.DockedTo = panel.ParentDockPanel; - winData.SplitterValue = splitterValue; - } - } - winData.AssemblyName = type.Assembly.GetName().Name; - winData.TypeName = type.FullName; _restoreWindows.Add(winData); }