Merge branch 'unload_alc_fix' into wip

# Conflicts:
#	Source/Editor/Modules/WindowsModule.cs
This commit is contained in:
2025-02-26 20:31:07 +02:00
4 changed files with 32 additions and 51 deletions

View File

@@ -21,6 +21,7 @@ namespace FlaxEditor.Modules
private bool _enableEvents; private bool _enableEvents;
private bool _isDuringFastSetup; private bool _isDuringFastSetup;
private bool _rebuildFlag; private bool _rebuildFlag;
private bool _rebuildInitFlag;
private int _itemsCreated; private int _itemsCreated;
private int _itemsDeleted; private int _itemsDeleted;
private readonly HashSet<MainContentTreeNode> _dirtyNodes = new HashSet<MainContentTreeNode>(); private readonly HashSet<MainContentTreeNode> _dirtyNodes = new HashSet<MainContentTreeNode>();
@@ -820,6 +821,7 @@ namespace FlaxEditor.Modules
Profiler.BeginEvent("ContentDatabase.Rebuild"); Profiler.BeginEvent("ContentDatabase.Rebuild");
var startTime = Platform.TimeSeconds; var startTime = Platform.TimeSeconds;
_rebuildFlag = false; _rebuildFlag = false;
_rebuildInitFlag = false;
_enableEvents = false; _enableEvents = false;
// Load all folders // Load all folders
@@ -1240,6 +1242,15 @@ namespace FlaxEditor.Modules
FlaxEngine.Scripting.InvokeOnUpdate(() => OnImportFileDone(path)); FlaxEngine.Scripting.InvokeOnUpdate(() => OnImportFileDone(path));
}; };
_enableEvents = true; _enableEvents = true;
_rebuildInitFlag = true;
}
/// <inheritdoc />
public override void OnEndInit()
{
// Handle init when project was loaded without scripts loading ()
if (_rebuildInitFlag)
RebuildInternal();
} }
private void OnImportFileDone(string path) private void OnImportFileDone(string path)

View File

@@ -58,7 +58,7 @@ namespace FlaxEditor.Modules
: base(editor) : base(editor)
{ {
// After editor cache but before the windows // After editor cache but before the windows
InitOrder = -900; InitOrder = -800;
} }
/// <summary> /// <summary>

View File

@@ -160,7 +160,7 @@ namespace FlaxEditor.Modules
internal UIModule(Editor editor) internal UIModule(Editor editor)
: base(editor) : base(editor)
{ {
InitOrder = -90; InitOrder = -70;
VisjectSurfaceBackground = FlaxEngine.Content.LoadAsyncInternal<Texture>("Editor/VisjectSurface"); VisjectSurfaceBackground = FlaxEngine.Content.LoadAsyncInternal<Texture>("Editor/VisjectSurface");
ColorValueBox.ShowPickColorDialog += ShowPickColorDialog; ColorValueBox.ShowPickColorDialog += ShowPickColorDialog;
} }

View File

@@ -816,15 +816,31 @@ namespace FlaxEditor.Modules
internal void AddToRestore(AssetEditorWindow win) internal void AddToRestore(AssetEditorWindow win)
{ {
var type = win.GetType(); AddToRestore(win, win.GetType(), new WindowRestoreData
var winData = 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; var panel = win.ParentDockPanel;
// Ensure that this window is only selected following recompilation // Ensure that this window is only selected following recompilation
// if it was the active tab in its dock panel. Otherwise, there is a // if it was the active tab in its dock panel. Otherwise, there is a
// risk of interrupting the user's workflow by potentially selecting // risk of interrupting the user's workflow by potentially selecting
// background tabs. // background tabs.
var window = win.RootWindow?.Window; var window = win.RootWindow.Window;
winData.SelectOnShow = panel.SelectedTab == win; winData.SelectOnShow = panel.SelectedTab == win;
winData.DockedTabIndex = 0; winData.DockedTabIndex = 0;
if (panel is FloatWindowDockPanel && window != null && panel.TabsCount == 1) if (panel is FloatWindowDockPanel && window != null && panel.TabsCount == 1)
@@ -860,52 +876,6 @@ namespace FlaxEditor.Modules
} }
winData.AssemblyName = type.Assembly.GetName().Name; winData.AssemblyName = type.Assembly.GetName().Name;
winData.TypeName = type.FullName; 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); _restoreWindows.Add(winData);
} }