Minor improvements and fixes for Editor
This commit is contained in:
@@ -219,6 +219,11 @@ namespace FlaxEditor.CustomEditors
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public event Action<LayoutElementsContainer> AfterLayout;
|
public event Action<LayoutElementsContainer> AfterLayout;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The Editor context that owns this presenter. Can be <see cref="FlaxEditor.Windows.PropertiesWindow"/> or <see cref="FlaxEditor.Windows.Assets.PrefabWindow"/> or other window/panel - custom editor scan use it for more specific features.
|
||||||
|
/// </summary>
|
||||||
|
public object Owner;
|
||||||
|
|
||||||
private bool _buildOnUpdate;
|
private bool _buildOnUpdate;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -226,9 +231,11 @@ namespace FlaxEditor.CustomEditors
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="undo">The undo. It's optional.</param>
|
/// <param name="undo">The undo. It's optional.</param>
|
||||||
/// <param name="noSelectionText">The custom text to display when no object is selected. Default is No selection.</param>
|
/// <param name="noSelectionText">The custom text to display when no object is selected. Default is No selection.</param>
|
||||||
public CustomEditorPresenter(Undo undo, string noSelectionText = null)
|
/// <param name="owner">The owner of the presenter.</param>
|
||||||
|
public CustomEditorPresenter(Undo undo, string noSelectionText = null, object owner = null)
|
||||||
{
|
{
|
||||||
Undo = undo;
|
Undo = undo;
|
||||||
|
Owner = owner;
|
||||||
Panel = new PresenterPanel(this);
|
Panel = new PresenterPanel(this);
|
||||||
Editor = new RootEditor(noSelectionText);
|
Editor = new RootEditor(noSelectionText);
|
||||||
Editor.Initialize(this, this, null);
|
Editor.Initialize(this, this, null);
|
||||||
|
|||||||
@@ -46,6 +46,11 @@ namespace FlaxEditor.GUI
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public event Action<Item> Clicked;
|
public event Action<Item> Clicked;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The tint color of the text.
|
||||||
|
/// </summary>
|
||||||
|
public Color TintColor = Color.White;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="Item"/> class.
|
/// Initializes a new instance of the <see cref="Item"/> class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -129,7 +134,7 @@ namespace FlaxEditor.GUI
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Draw name
|
// Draw name
|
||||||
Render2D.DrawText(style.FontSmall, Name, textRect, Enabled ? style.Foreground : style.ForegroundDisabled, TextAlignment.Near, TextAlignment.Center);
|
Render2D.DrawText(style.FontSmall, Name, textRect, TintColor * (Enabled ? style.Foreground : style.ForegroundDisabled), TextAlignment.Near, TextAlignment.Center);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
|
|||||||
@@ -179,12 +179,12 @@ namespace FlaxEditor.SceneGraph
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets a value indicating whether this actor can be used to create prefab from it (as a root).
|
/// Gets a value indicating whether this actor can be used to create prefab from it (as a root).
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public virtual bool CanCreatePrefab => (Actor.HideFlags & HideFlags.DontSave) != HideFlags.DontSave;
|
public virtual bool CanCreatePrefab => (_actor.HideFlags & HideFlags.DontSave) != HideFlags.DontSave;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets a value indicating whether this actor has a valid linkage to the prefab asset.
|
/// Gets a value indicating whether this actor has a valid linkage to the prefab asset.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public virtual bool HasPrefabLink => Actor.HasPrefabLink;
|
public virtual bool HasPrefabLink => _actor.HasPrefabLink;
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override string Name => _actor.Name;
|
public override string Name => _actor.Name;
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ namespace FlaxEditor.SceneGraph.GUI
|
|||||||
{
|
{
|
||||||
for (int i = 0; i < parent.ChildrenCount; i++)
|
for (int i = 0; i < parent.ChildrenCount; i++)
|
||||||
{
|
{
|
||||||
if (parent.Children[i] is ActorTreeNode child)
|
if (parent.Children[i] is ActorTreeNode child && child.Actor)
|
||||||
child._orderInParent = child.Actor.OrderInParent;
|
child._orderInParent = child.Actor.OrderInParent;
|
||||||
}
|
}
|
||||||
parent.SortChildren();
|
parent.SortChildren();
|
||||||
@@ -193,7 +193,7 @@ namespace FlaxEditor.SceneGraph.GUI
|
|||||||
{
|
{
|
||||||
// Update hidden state
|
// Update hidden state
|
||||||
var actor = Actor;
|
var actor = Actor;
|
||||||
if (actor != null && !_hasSearchFilter)
|
if (actor && !_hasSearchFilter)
|
||||||
{
|
{
|
||||||
Visible = (actor.HideFlags & HideFlags.HideInHierarchy) == 0;
|
Visible = (actor.HideFlags & HideFlags.HideInHierarchy) == 0;
|
||||||
}
|
}
|
||||||
@@ -209,23 +209,26 @@ namespace FlaxEditor.SceneGraph.GUI
|
|||||||
{
|
{
|
||||||
Color color = Style.Current.Foreground;
|
Color color = Style.Current.Foreground;
|
||||||
var actor = Actor;
|
var actor = Actor;
|
||||||
if (actor != null && actor.HasPrefabLink)
|
if (actor)
|
||||||
|
{
|
||||||
|
if (actor.HasPrefabLink)
|
||||||
{
|
{
|
||||||
// Prefab
|
// Prefab
|
||||||
color = Style.Current.ProgressNormal;
|
color = Style.Current.ProgressNormal;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (actor != null && !actor.IsActiveInHierarchy)
|
if (!actor.IsActiveInHierarchy)
|
||||||
{
|
{
|
||||||
// Inactive
|
// Inactive
|
||||||
return Style.Current.ForegroundGrey;
|
return Style.Current.ForegroundGrey;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (actor?.Scene != null && Editor.Instance.StateMachine.IsPlayMode && actor.IsStatic)
|
if (actor.Scene != null && Editor.Instance.StateMachine.IsPlayMode && actor.IsStatic)
|
||||||
{
|
{
|
||||||
// Static
|
// Static
|
||||||
return color * 0.85f;
|
return color * 0.85f;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Default
|
// Default
|
||||||
return color;
|
return color;
|
||||||
|
|||||||
@@ -33,6 +33,8 @@ namespace FlaxEditor
|
|||||||
/// <param name="customActionAfter">Custom action to append to the undo block action after recorded modifications apply.</param>
|
/// <param name="customActionAfter">Custom action to append to the undo block action after recorded modifications apply.</param>
|
||||||
public UndoBlock(Undo undo, object snapshotInstance, string actionString, IUndoAction customActionBefore = null, IUndoAction customActionAfter = null)
|
public UndoBlock(Undo undo, object snapshotInstance, string actionString, IUndoAction customActionBefore = null, IUndoAction customActionAfter = null)
|
||||||
{
|
{
|
||||||
|
if (undo == null)
|
||||||
|
return;
|
||||||
_snapshotUndoInternal = snapshotInstance;
|
_snapshotUndoInternal = snapshotInstance;
|
||||||
_undo = undo;
|
_undo = undo;
|
||||||
_undo.RecordBegin(_snapshotUndoInternal, actionString);
|
_undo.RecordBegin(_snapshotUndoInternal, actionString);
|
||||||
@@ -43,7 +45,7 @@ namespace FlaxEditor
|
|||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
_undo.RecordEnd(_snapshotUndoInternal, _customActionBefore, _customActionAfter);
|
_undo?.RecordEnd(_snapshotUndoInternal, _customActionBefore, _customActionAfter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -270,9 +270,12 @@ namespace FlaxEditor.Windows.Assets
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void Update(ActorNode actorNode)
|
private void Update(ActorNode actorNode)
|
||||||
|
{
|
||||||
|
if (actorNode.Actor)
|
||||||
{
|
{
|
||||||
actorNode.TreeNode.OnNameChanged();
|
actorNode.TreeNode.OnNameChanged();
|
||||||
actorNode.TreeNode.OnOrderInParentChanged();
|
actorNode.TreeNode.OnOrderInParentChanged();
|
||||||
|
}
|
||||||
|
|
||||||
for (int i = 0; i < actorNode.ChildNodes.Count; i++)
|
for (int i = 0; i < actorNode.ChildNodes.Count; i++)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -148,7 +148,7 @@ namespace FlaxEditor.Windows.Assets
|
|||||||
_viewport.TransformGizmo.ModeChanged += UpdateToolstrip;
|
_viewport.TransformGizmo.ModeChanged += UpdateToolstrip;
|
||||||
|
|
||||||
// Prefab properties editor
|
// Prefab properties editor
|
||||||
_propertiesEditor = new CustomEditorPresenter(_undo);
|
_propertiesEditor = new CustomEditorPresenter(_undo, null, this);
|
||||||
_propertiesEditor.Panel.Parent = _split2.Panel2;
|
_propertiesEditor.Panel.Parent = _split2.Panel2;
|
||||||
_propertiesEditor.Modified += MarkAsEdited;
|
_propertiesEditor.Modified += MarkAsEdited;
|
||||||
|
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ namespace FlaxEditor.Windows
|
|||||||
Title = "Properties";
|
Title = "Properties";
|
||||||
AutoFocus = true;
|
AutoFocus = true;
|
||||||
|
|
||||||
Presenter = new CustomEditorPresenter(editor.Undo);
|
Presenter = new CustomEditorPresenter(editor.Undo, null, this);
|
||||||
Presenter.Panel.Parent = this;
|
Presenter.Panel.Parent = this;
|
||||||
Presenter.GetUndoObjects += GetUndoObjects;
|
Presenter.GetUndoObjects += GetUndoObjects;
|
||||||
Presenter.CacheExpandedGroups = true;
|
Presenter.CacheExpandedGroups = true;
|
||||||
|
|||||||
@@ -1515,6 +1515,8 @@ bool Actor::ToBytes(const Array<Actor*>& actors, MemoryWriteStream& output)
|
|||||||
// By default we collect actors and scripts (they are ManagedObjects recognized by the id)
|
// By default we collect actors and scripts (they are ManagedObjects recognized by the id)
|
||||||
|
|
||||||
auto actor = actors[i];
|
auto actor = actors[i];
|
||||||
|
if (!actor)
|
||||||
|
continue;
|
||||||
ids.Add(actor->GetID());
|
ids.Add(actor->GetID());
|
||||||
for (int32 j = 0; j < actor->Scripts.Count(); j++)
|
for (int32 j = 0; j < actor->Scripts.Count(); j++)
|
||||||
{
|
{
|
||||||
@@ -1534,6 +1536,8 @@ bool Actor::ToBytes(const Array<Actor*>& actors, MemoryWriteStream& output)
|
|||||||
for (int32 i = 0; i < actors.Count(); i++)
|
for (int32 i = 0; i < actors.Count(); i++)
|
||||||
{
|
{
|
||||||
Actor* actor = actors[i];
|
Actor* actor = actors[i];
|
||||||
|
if (!actor)
|
||||||
|
continue;
|
||||||
|
|
||||||
WriteObjectToBytes(actor, buffer, output);
|
WriteObjectToBytes(actor, buffer, output);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user