Add locking scene selection in properties window.
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
using FlaxEditor.Actions;
|
using FlaxEditor.Actions;
|
||||||
using FlaxEditor.CustomEditors.Editors;
|
using FlaxEditor.CustomEditors.Editors;
|
||||||
using FlaxEditor.CustomEditors.Elements;
|
using FlaxEditor.CustomEditors.Elements;
|
||||||
@@ -9,6 +10,7 @@ using FlaxEditor.GUI;
|
|||||||
using FlaxEditor.GUI.ContextMenu;
|
using FlaxEditor.GUI.ContextMenu;
|
||||||
using FlaxEditor.GUI.Tree;
|
using FlaxEditor.GUI.Tree;
|
||||||
using FlaxEditor.Scripting;
|
using FlaxEditor.Scripting;
|
||||||
|
using FlaxEditor.Windows;
|
||||||
using FlaxEngine;
|
using FlaxEngine;
|
||||||
using FlaxEngine.GUI;
|
using FlaxEngine.GUI;
|
||||||
using FlaxEngine.Json;
|
using FlaxEngine.Json;
|
||||||
@@ -111,6 +113,22 @@ namespace FlaxEditor.CustomEditors.Dedicated
|
|||||||
var actor = (Actor)Values[0];
|
var actor = (Actor)Values[0];
|
||||||
var scriptType = TypeUtils.GetType(actor.TypeName);
|
var scriptType = TypeUtils.GetType(actor.TypeName);
|
||||||
var item = scriptType.ContentItem;
|
var item = scriptType.ContentItem;
|
||||||
|
if (Presenter.Owner is PropertiesWindow pw)
|
||||||
|
{
|
||||||
|
var lockButton = cm.AddButton(pw.LockObjects ? "Unlock" : "Lock");
|
||||||
|
lockButton.ButtonClicked += button =>
|
||||||
|
{
|
||||||
|
pw.LockObjects = !pw.LockObjects;
|
||||||
|
|
||||||
|
// Reselect current selection
|
||||||
|
if (!pw.LockObjects && Editor.Instance.SceneEditing.SelectionCount > 0)
|
||||||
|
{
|
||||||
|
var cachedSelection = Editor.Instance.SceneEditing.Selection.ToArray();
|
||||||
|
Editor.Instance.SceneEditing.Select(null);
|
||||||
|
Editor.Instance.SceneEditing.Select(cachedSelection);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
cm.AddButton("Copy ID", OnClickCopyId);
|
cm.AddButton("Copy ID", OnClickCopyId);
|
||||||
cm.AddButton("Edit actor type", OnClickEditActorType).Enabled = item != null;
|
cm.AddButton("Edit actor type", OnClickEditActorType).Enabled = item != null;
|
||||||
var showButton = cm.AddButton("Show in content window", OnClickShowActorType);
|
var showButton = cm.AddButton("Show in content window", OnClickShowActorType);
|
||||||
|
|||||||
@@ -37,6 +37,11 @@ namespace FlaxEditor.Windows
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public bool UIPivotRelative = true;
|
public bool UIPivotRelative = true;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Indication of if the properties window is locked on specific objects.
|
||||||
|
/// </summary>
|
||||||
|
public bool LockObjects = false;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="PropertiesWindow"/> class.
|
/// Initializes a new instance of the <see cref="PropertiesWindow"/> class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -62,6 +67,9 @@ namespace FlaxEditor.Windows
|
|||||||
|
|
||||||
private void OnSelectionChanged()
|
private void OnSelectionChanged()
|
||||||
{
|
{
|
||||||
|
if (LockObjects)
|
||||||
|
return;
|
||||||
|
|
||||||
// Update selected objects
|
// Update selected objects
|
||||||
// TODO: use cached collection for less memory allocations
|
// TODO: use cached collection for less memory allocations
|
||||||
undoRecordObjects = Editor.SceneEditing.Selection.ConvertAll(x => x.UndoRecordObject).Distinct();
|
undoRecordObjects = Editor.SceneEditing.Selection.ConvertAll(x => x.UndoRecordObject).Distinct();
|
||||||
|
|||||||
Reference in New Issue
Block a user