Merge remote-tracking branch 'origin/master' into 1.10

This commit is contained in:
Wojtek Figat
2024-11-06 09:29:48 +01:00
34 changed files with 679 additions and 305 deletions

View File

@@ -490,6 +490,60 @@ namespace FlaxEditor.Modules
return;
}
var projects = Editor.ContentDatabase.Projects;
var contentPaths = new List<string>();
var sourcePaths = new List<string>();
foreach (var project in projects)
{
if (project.Content != null)
contentPaths.Add(project.Content.Path);
if (project.Source != null)
sourcePaths.Add(project.Source.Path);
}
// Check if moving from content to source folder. Item may lose reference in Asset Database. Warn user.
foreach (var contentPath in contentPaths)
{
if (item.Path.Contains(contentPath, StringComparison.Ordinal))
{
bool isFound = false;
foreach (var sourcePath in sourcePaths)
{
if (newParent.Path.Contains(sourcePath, StringComparison.Ordinal))
{
isFound = true;
var result = MessageBox.Show(Editor.Windows.MainWindow, "Moving item from \"Content\" to \"Source\" folder may lose asset database reference.\nDo you want to continue?", "Moving item", MessageBoxButtons.OKCancel);
if (result == DialogResult.Cancel)
return;
break;
}
}
if (isFound)
break;
}
}
// Check if moving from source to content folder. Item may lose reference in Asset Database. Warn user.
foreach (var sourcePath in sourcePaths)
{
if (item.Path.Contains(sourcePath, StringComparison.Ordinal))
{
bool isFound = false;
foreach (var contentPath in contentPaths)
{
if (newParent.Path.Contains(contentPath, StringComparison.Ordinal))
{
isFound = true;
var result = MessageBox.Show(Editor.Windows.MainWindow, "Moving item from \"Source\" to \"Content\" folder may lose asset database reference.\nDo you want to continue?", "Moving item", MessageBoxButtons.OKCancel);
if (result == DialogResult.Cancel)
return;
break;
}
}
if (isFound)
break;
}
}
// Perform renaming
{
string oldPath = item.Path;

View File

@@ -555,10 +555,20 @@ namespace FlaxEditor.Modules
/// </summary>
public void CreateParentForSelectedActors()
{
Actor actor = new EmptyActor();
Editor.SceneEditing.Spawn(actor, null, false);
List<SceneGraphNode> selection = Editor.SceneEditing.Selection;
var actors = selection.Where(x => x is ActorNode).Select(x => ((ActorNode)x).Actor);
var actorsCount = actors.Count();
if (actorsCount == 0)
return;
Vector3 center = Vector3.Zero;
foreach (var actor in actors)
center += actor.Position;
center /= actorsCount;
Actor parent = new EmptyActor
{
Position = center,
};
Editor.SceneEditing.Spawn(parent, null, false);
using (new UndoMultiBlock(Undo, actors, "Reparent actors"))
{
for (int i = 0; i < selection.Count; i++)
@@ -574,15 +584,15 @@ namespace FlaxEditor.Modules
// Put created node as child of the Parent Node of node
int parentOrder = node.Actor.OrderInParent;
actor.Parent = node.Actor.Parent;
actor.OrderInParent = parentOrder;
parent.SetParent(node.Actor.Parent, true, true);
parent.OrderInParent = parentOrder;
}
node.Actor.Parent = actor;
node.Actor.SetParent(parent, true, false);
}
}
}
Editor.SceneEditing.Select(actor);
Editor.Scene.GetActorNode(actor).TreeNode.StartRenaming(Editor.Windows.SceneWin, Editor.Windows.SceneWin.SceneTreePanel);
Editor.SceneEditing.Select(parent);
Editor.Scene.GetActorNode(parent).TreeNode.StartRenaming(Editor.Windows.SceneWin, Editor.Windows.SceneWin.SceneTreePanel);
}
/// <summary>

View File

@@ -2,6 +2,7 @@
using System;
using System.Threading;
using FlaxEditor.GUI.Docking;
using FlaxEditor.States;
using FlaxEditor.Windows;
using FlaxEngine;
@@ -20,6 +21,7 @@ namespace FlaxEditor.Modules
private bool _updateOrFixedUpdateWasCalled;
private long _breakpointHangFlag;
private EditorWindow _enterPlayFocusedWindow;
private DockWindow _previousWindow;
private Guid[] _scenesToReload;
internal SimulationModule(Editor editor)
@@ -272,23 +274,43 @@ namespace FlaxEditor.Modules
// Show Game widow if hidden
if (gameWin != null)
{
if (gameWin.FocusOnPlay)
switch (gameWin.FocusOnPlayOption)
{
case Options.InterfaceOptions.PlayModeFocus.None: break;
case Options.InterfaceOptions.PlayModeFocus.GameWindow:
gameWin.FocusGameViewport();
break;
case Options.InterfaceOptions.PlayModeFocus.GameWindowThenRestore:
_previousWindow = gameWin.ParentDockPanel.SelectedTab;
gameWin.FocusGameViewport();
break;
}
gameWin.SetWindowMode(Editor.Options.Options.Interface.DefaultGameWindowMode);
}
Editor.Log("[PlayMode] Enter");
}
/// <inheritdoc />
public override void OnPlayEnd()
{
// Restore focused window before play mode
if (_enterPlayFocusedWindow != null)
var gameWin = Editor.Windows.GameWin;
switch (gameWin.FocusOnPlayOption)
{
_enterPlayFocusedWindow.FocusOrShow();
_enterPlayFocusedWindow = null;
case Options.InterfaceOptions.PlayModeFocus.None: break;
case Options.InterfaceOptions.PlayModeFocus.GameWindow: break;
case Options.InterfaceOptions.PlayModeFocus.GameWindowThenRestore:
if (_previousWindow != null && !_previousWindow.IsDisposing)
{
if (!Editor.Windows.GameWin.ParentDockPanel.ContainsTab(_previousWindow))
break;
_previousWindow.Focus();
}
break;
}
Editor.UI.UncheckPauseButton();

View File

@@ -556,7 +556,7 @@ namespace FlaxEditor.Modules
cm.AddSeparator();
_menuEditSelectAll = cm.AddButton("Select all", inputOptions.SelectAll, Editor.SceneEditing.SelectAllScenes);
_menuEditDeselectAll = cm.AddButton("Deselect all", inputOptions.DeselectAll, Editor.SceneEditing.DeselectAllScenes);
_menuCreateParentForSelectedActors = cm.AddButton("Create parent for selected actors", Editor.SceneEditing.CreateParentForSelectedActors);
_menuCreateParentForSelectedActors = cm.AddButton("Parent to new Actor", inputOptions.GroupSelectedActors, Editor.SceneEditing.CreateParentForSelectedActors);
_menuEditFind = cm.AddButton("Find", inputOptions.Search, Editor.Windows.SceneWin.Search);
cm.AddSeparator();
cm.AddButton("Game Settings", () =>