// Copyright (c) Wojciech Figat. All rights reserved. using System.Collections.Generic; using FlaxEditor.SceneGraph; using FlaxEditor.Viewport; using FlaxEngine; using FlaxEngine.GUI; namespace FlaxEditor.Windows { /// /// Base class for editor windows dedicated to scene editing. /// /// public abstract class SceneEditorWindow : EditorWindow, ISceneEditingContext { /// /// Initializes a new instance of the class. /// /// The editor. /// True if hide window on closing, otherwise it will be destroyed. /// The scroll bars. protected SceneEditorWindow(Editor editor, bool hideOnClose, ScrollBars scrollBars) : base(editor, hideOnClose, scrollBars) { FlaxEditor.Utilities.Utils.SetupCommonInputActions(this); } /// public void DeleteSelection() { Editor.SceneEditing.Delete(); } /// public void FocusSelection() { Editor.Windows.EditWin.Viewport.FocusSelection(); } /// public void Spawn(Actor actor, Actor parent = null, int orderInParent = -1, bool autoSelect = true) { Editor.SceneEditing.Spawn(actor, parent, orderInParent, autoSelect); } /// public EditorViewport Viewport => Editor.Windows.EditWin.Viewport; /// public List Selection => Editor.SceneEditing.Selection; /// public void Select(SceneGraphNode node, bool additive = false) { Editor.SceneEditing.Select(node, additive); } /// public void Deselect(SceneGraphNode node) { Editor.SceneEditing.Deselect(node); } /// public void RenameSelection() { var selection = Editor.SceneEditing.Selection; var selectionCount = selection.Count; // Show a window with options to rename multiple actors. if (selectionCount > 1) { var selectedActors = new Actor[selectionCount]; for (int i = 0; i < selectionCount; i++) if (selection[i] is ActorNode actorNode) selectedActors[i] = actorNode.Actor; RenameWindow.Show(selectedActors, Editor); return; } if (selectionCount != 0 && selection[0] is ActorNode actor) { Editor.SceneEditing.Select(actor); var sceneWindow = Editor.Windows.SceneWin; actor.TreeNode.StartRenaming(sceneWindow, sceneWindow.SceneTreePanel); } } } }