Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Editor/HierarchyData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ public class TreeData
public bool enabled = true;
public bool drawOverlayOnColoredPrefabs = true;
[Range(0,3)] public float dividerHeigth = 1;
public bool drawBranchTails = true;
public Color baseLevelColor = Color.gray;

[System.Serializable]
Expand Down
64 changes: 46 additions & 18 deletions Editor/HierarchyDrawer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -110,24 +110,24 @@ public static void DrawHalfVerticalLineFrom(Rect originalRect, bool startsOnTop,
);
}

public static void DrawHorizontalLineFrom(Rect originalRect, int nestLevel, bool hasChilds)
public static void DrawHorizontalLineFrom(Rect originalRect, int nestLevel, bool hasChilds, bool isLastChildInNestingLevel)
{
if(currentBranch.colors.Length<=0) return;
if (currentBranch.colors.Length <= 0) return;

//Vertical rect, starts from the very left and then proceeds to te right
EditorGUI.DrawRect(
new Rect(
GetStartX(originalRect, nestLevel),
originalRect.y + originalRect.height/2f,
originalRect.height + (hasChilds ? -5 : 2),
GetStartX(originalRect, nestLevel) + (isLastChildInNestingLevel ? 0 : barWidth),
originalRect.y + originalRect.height / 2f,
originalRect.height + (hasChilds ? -5 : 2),
//originalRect.height - 5,
barWidth
),
),
GetNestColor(nestLevel)
);
}
}

#region Types

[Serializable]
Expand All @@ -143,11 +143,14 @@ struct InstanceInfo
public bool isGoActive;

public bool isLastElement;
public bool isLastChildInNestingLevel;
public bool hasChilds;
public bool topParentHasChild;

public int nestingGroup;
public int nestingLevel;

public int parentId;
}

#endregion
Expand Down Expand Up @@ -351,7 +354,8 @@ static void RetrieveDataFromScene()
nestingLevel: 0,
sceneRoots[j].transform.childCount > 0,
nestingGroup: j,
isLastChild: j == sceneRoots.Length - 1
isLastChild: j == sceneRoots.Length - 1,
-1
);
}

Expand All @@ -360,7 +364,7 @@ static void RetrieveDataFromScene()
}
}

static void AnalyzeGoWithChildren(GameObject go, int nestingLevel, bool topParentHasChild, int nestingGroup, bool isLastChild)
static void AnalyzeGoWithChildren(GameObject go, int nestingLevel, bool topParentHasChild, int nestingGroup, bool isLastChild, int parentId)
{
int instanceID = go.GetInstanceID();

Expand All @@ -369,12 +373,14 @@ static void AnalyzeGoWithChildren(GameObject go, int nestingLevel, bool topParen
InstanceInfo newInfo = new InstanceInfo();
newInfo.iconIndexes = new List<int>();
newInfo.isLastElement = isLastChild && go.transform.childCount == 0;
newInfo.isLastChildInNestingLevel = isLastChild;
newInfo.nestingLevel = nestingLevel;
newInfo.nestingGroup = nestingGroup;
newInfo.hasChilds = go.transform.childCount > 0;
newInfo.isGoActive = go.activeInHierarchy;
newInfo.topParentHasChild = topParentHasChild;
newInfo.goName = go.name;
newInfo.parentId = parentId;

if (data.prefabsData.enabled)
{
Expand Down Expand Up @@ -451,7 +457,8 @@ static void AnalyzeGoWithChildren(GameObject go, int nestingLevel, bool topParen
nestingLevel + 1,
topParentHasChild,
nestingGroup,
j == childCount - 1
j == childCount - 1,
instanceID
);
}

Expand Down Expand Up @@ -534,16 +541,37 @@ static void DrawCore(int instanceID, Rect selectionRect)
}
else
{
var nestedItem = currentItem;
//Draws a vertical line for each previous nesting level
for (int i = 0; i <= currentItem.nestingLevel; i++)
for (int i = currentItem.nestingLevel; i >= 0; i--)
{
HierarchyRenderer.DrawVerticalLineFrom(selectionRect, i);
if (data.tree.drawBranchTails)
{
HierarchyRenderer.DrawVerticalLineFrom(selectionRect, i);
}
else
{
if (!nestedItem.isLastChildInNestingLevel)
{
HierarchyRenderer.DrawVerticalLineFrom(selectionRect, i);
}
else if (i == currentItem.nestingLevel)
{
HierarchyRenderer.DrawHalfVerticalLineFrom(selectionRect, true, i);
}

if (!sceneGameObjects.ContainsKey(nestedItem.parentId))
{
break;
}
nestedItem = sceneGameObjects[nestedItem.parentId];
}
}
HierarchyRenderer.DrawHorizontalLineFrom(
selectionRect, currentItem.nestingLevel, currentItem.hasChilds
);

HierarchyRenderer.DrawHorizontalLineFrom(
selectionRect, currentItem.nestingLevel, currentItem.hasChilds, currentItem.isLastChildInNestingLevel
);

}

}
Expand Down