Simplify and cleanup code

#3096
This commit is contained in:
Wojtek Figat
2024-12-16 23:14:50 +01:00
parent bd4a042619
commit 222a614a2b

View File

@@ -310,38 +310,23 @@ namespace FlaxEditor.CustomEditors.Editors
if (button == MouseButton.Left) if (button == MouseButton.Left)
{ {
_isMouseDown = false; _isMouseDown = false;
// Highlight actor reference.
if (Value is Actor a && !_hasValidDragOver)
{
if (_linkedTreeNode != null && _linkedTreeNode.Actor == a)
{
_linkedTreeNode.ExpandAllParents();
_linkedTreeNode.StartHighlight();
}
else
{
_linkedTreeNode = Editor.Instance.Scene.GetActorNode(a).TreeNode;
_linkedTreeNode.ExpandAllParents();
Editor.Instance.Windows.SceneWin.SceneTreePanel.ScrollViewTo(_linkedTreeNode, true);
_linkedTreeNode.StartHighlight();
}
return true;
}
// Highlight actor with script reference. // Highlight actor or script reference
if (Value is Script s && !IsDragOver && !_hasValidDragOver) if (!_hasValidDragOver && !IsDragOver)
{ {
var scriptActor = s.Actor; Actor actor = _value as Actor;
if (scriptActor != null) if (actor == null && _value is Script script)
actor = script.Actor;
if (actor != null)
{ {
if (_linkedTreeNode != null && _linkedTreeNode.Actor == scriptActor) if (_linkedTreeNode != null && _linkedTreeNode.Actor == actor)
{ {
_linkedTreeNode.ExpandAllParents(); _linkedTreeNode.ExpandAllParents();
_linkedTreeNode.StartHighlight(); _linkedTreeNode.StartHighlight();
} }
else else
{ {
_linkedTreeNode = Editor.Instance.Scene.GetActorNode(scriptActor).TreeNode; _linkedTreeNode = Editor.Instance.Scene.GetActorNode(actor).TreeNode;
_linkedTreeNode.ExpandAllParents(); _linkedTreeNode.ExpandAllParents();
Editor.Instance.Windows.SceneWin.SceneTreePanel.ScrollViewTo(_linkedTreeNode, true); Editor.Instance.Windows.SceneWin.SceneTreePanel.ScrollViewTo(_linkedTreeNode, true);
_linkedTreeNode.StartHighlight(); _linkedTreeNode.StartHighlight();
@@ -350,7 +335,7 @@ namespace FlaxEditor.CustomEditors.Editors
} }
} }
// Reset valid drag over if still true at this point. // Reset valid drag over if still true at this point
if (_hasValidDragOver) if (_hasValidDragOver)
_hasValidDragOver = false; _hasValidDragOver = false;
} }
@@ -380,7 +365,11 @@ namespace FlaxEditor.CustomEditors.Editors
if (_value != null) if (_value != null)
{ {
if (_linkedTreeNode != null) if (_linkedTreeNode != null)
{
_linkedTreeNode.StopHighlight(); _linkedTreeNode.StopHighlight();
_linkedTreeNode = null;
}
// Select object // Select object
if (_value is Actor actor) if (_value is Actor actor)
Editor.Instance.SceneEditing.Select(actor); Editor.Instance.SceneEditing.Select(actor);