Merge branch 'add-root-tree-line-option' of https://github.com/Tryibion/FlaxEngine into Tryibion-add-root-tree-line-option

This commit is contained in:
Wojtek Figat
2025-06-02 10:17:34 +02:00
4 changed files with 9 additions and 2 deletions

View File

@@ -67,6 +67,11 @@ namespace FlaxEditor.GUI.Tree
/// Gets the first selected node or null.
/// </summary>
public TreeNode SelectedNode => Selection.Count > 0 ? Selection[0] : null;
/// <summary>
/// Allow nodes to Draw the root tree line.
/// </summary>
public bool DrawRootTreeLine = true;
/// <summary>
/// Gets or sets the margin for the child tree nodes.

View File

@@ -762,7 +762,7 @@ namespace FlaxEditor.GUI.Tree
{
TreeNode parentNode = Parent as TreeNode;
bool thisNodeIsLast = false;
while (parentNode != null && parentNode != ParentTree.Children[0])
while (parentNode != null && (parentNode != ParentTree.Children[0] || _tree.DrawRootTreeLine))
{
float bottomOffset = 0;
float topOffset = 0;
@@ -773,7 +773,7 @@ namespace FlaxEditor.GUI.Tree
if (thisNodeIsLast && parentNode.Children.Count == 1)
bottomOffset = topOffset != 0 ? 4 : 2;
if (Parent == parentNode && this == Parent.Children[Parent.Children.Count - 1] && !_opened)
if (Parent == parentNode && this == Parent.Children[^1] && !_opened)
{
thisNodeIsLast = true;
bottomOffset = topOffset != 0 ? 4 : 2;

View File

@@ -56,6 +56,7 @@ namespace FlaxEditor.Windows.Assets
public PrefabTree()
: base(true)
{
DrawRootTreeLine = false;
}
}

View File

@@ -85,6 +85,7 @@ namespace FlaxEditor.Windows
{
Margin = new Margin(0.0f, 0.0f, -16.0f, _sceneTreePanel.ScrollBarsSize), // Hide root node
IsScrollable = true,
DrawRootTreeLine = false,
};
_tree.AddChild(root.TreeNode);
_tree.SelectedChanged += Tree_OnSelectedChanged;