Skip to content

Commit 8ec94d4

Browse files
authored
Merge pull request #127 from 5unad0ke1/main
Hierarchy Rendering Fix: Resolve Prefab Active Toggle / Expand Button Overlap
2 parents d9f5a2b + 9221dec commit 8ec94d4

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

Alchemy/Assets/Alchemy/Editor/Hierarchy/HierarchyToggleDrawer.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ public override void OnGUI(int instanceID, Rect selectionRect)
2121
rect.x = rect.xMax - 2.7f;
2222
rect.width = 16f;
2323

24+
if (IsNewPrefabWorkflow() && IsPrefab(gameObject))
25+
rect.x -= 16.7f;
26+
2427
var active = GUI.Toggle(rect, gameObject.activeSelf, string.Empty);
2528
if (active != gameObject.activeSelf)
2629
{
@@ -34,6 +37,10 @@ public override void OnGUI(int instanceID, Rect selectionRect)
3437
{
3538
var rect = selectionRect;
3639
rect.x = rect.xMax - (settings.ShowHierarchyToggles ? 18.7f : 2.7f);
40+
41+
if (IsNewPrefabWorkflow() && IsPrefab(gameObject))
42+
rect.x -= 16.7f;
43+
3744
rect.y += 1f;
3845
rect.width = 14f;
3946
rect.height = 14f;
@@ -76,6 +83,21 @@ static bool IsEnabled(Component component)
7683
var property = component.GetType().GetProperty("enabled", typeof(bool));
7784
return (bool)(property?.GetValue(component, null) ?? true);
7885
}
86+
private static bool IsPrefab(GameObject gameObj)
87+
{
88+
if (gameObj == null)
89+
return false;
90+
var prefabType = PrefabUtility.GetPrefabAssetType(gameObj);
91+
return prefabType != PrefabAssetType.NotAPrefab;
92+
}
93+
private static bool IsNewPrefabWorkflow()
94+
{
95+
#if UNITY_2018_3_OR_NEWER
96+
return true;
97+
#else
98+
return false;
99+
#endif
100+
}
79101
}
80102

81103
}

0 commit comments

Comments
 (0)