Skip to content
This repository was archived by the owner on Dec 5, 2024. It is now read-only.

Commit b164664

Browse files
Adding functionality to ignore a common path root
1 parent 1087add commit b164664

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

src/UnityExtension/Assets/Editor/GitHub.Unity/UI/TreeControl.cs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ public abstract class Tree
2020
[SerializeField] public Rect Margin = new Rect();
2121
[SerializeField] public Rect Padding = new Rect();
2222

23+
[SerializeField] public string PathIgnoreRoot;
2324
[SerializeField] public string PathSeparator = "/";
2425
[SerializeField] public GUIStyle FolderStyle;
2526
[SerializeField] public GUIStyle TreeNodeStyle;
@@ -51,6 +52,7 @@ private set
5152

5253
public TreeNode ActiveNode { get { return activeNode; } }
5354

55+
5456
public void Load(IEnumerable<ITreeData> data, string title)
5557
{
5658
var collapsedFoldersEnumerable = folders.Where(pair => pair.Value.IsCollapsed).Select(pair => pair.Key);
@@ -74,7 +76,17 @@ public void Load(IEnumerable<ITreeData> data, string title)
7476

7577
foreach (var d in data)
7678
{
77-
var parts = d.Name.Split(new [] {PathSeparator}, StringSplitOptions.None);
79+
var fullName = d.Name;
80+
if (PathIgnoreRoot != null)
81+
{
82+
var indexOf = fullName.IndexOf(PathIgnoreRoot);
83+
if (indexOf != -1)
84+
{
85+
fullName = fullName.Substring(indexOf + PathIgnoreRoot.Length);
86+
}
87+
}
88+
89+
var parts = fullName.Split(new [] {PathSeparator}, StringSplitOptions.None);
7890
for (int i = 0; i < parts.Length; i++)
7991
{
8092
var label = parts[i];

0 commit comments

Comments
 (0)