Skip to content

Commit 29a46a6

Browse files
authored
Update HierarchyEditor.cs
1 parent 9ba3fde commit 29a46a6

File tree

1 file changed

+29
-15
lines changed

1 file changed

+29
-15
lines changed

Assets/Hierarchy 2/Editor/HierarchyEditor.cs

Lines changed: 29 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -194,11 +194,14 @@ static void InternalReflection()
194194
.GetFields(BindingFlags.NonPublic | BindingFlags.Instance)
195195
.Single(field => field.Name.Contains(nameof(m_Rows)));
196196
}
197+
197198
public static IEnumerable GetAllSceneHierarchyWindows() => GetAllSceneHierarchyWindowsDelegate();
198199

199-
public static void DisplayObjectContextMenu(Rect rect, UnityEngine.Object unityObject, int value) => DisplayObjectContextMenuDelegate(rect, unityObject, value);
200+
public static void DisplayObjectContextMenu(Rect rect, UnityEngine.Object unityObject, int value) =>
201+
DisplayObjectContextMenuDelegate(rect, unityObject, value);
200202

201-
public static bool IconSelectorShowAtPosition(GameObject gameObject, Rect rect, bool value) => IconSelectorShowAtPositionDelegate(gameObject, rect, value);
203+
public static bool IconSelectorShowAtPosition(GameObject gameObject, Rect rect, bool value) =>
204+
IconSelectorShowAtPositionDelegate(gameObject, rect, value);
202205

203206
private static MethodInfo GetItemAndRowIndexMethod;
204207
private static PropertyInfo m_TreeView_IData;
@@ -695,16 +698,22 @@ void CustomRowBackground()
695698
if (currentEvent.type != EventType.Repaint)
696699
return;
697700

698-
HierarchySettings.InstantBackgroundColor instantBackgroundColor = new HierarchySettings.InstantBackgroundColor();
701+
HierarchySettings.InstantBackgroundColor instantBackgroundColor =
702+
new HierarchySettings.InstantBackgroundColor();
699703
bool contain = false;
700704
for (int i = 0; i < settings.instantBackgroundColors.Count; ++i)
701705
{
702706
if (!settings.instantBackgroundColors[i].active) continue;
703707
if
704708
(
705-
(settings.instantBackgroundColors[i].useTag && !string.IsNullOrEmpty(settings.instantBackgroundColors[i].tag) && rowItem.gameObject.CompareTag(settings.instantBackgroundColors[i].tag)) ||
706-
(settings.instantBackgroundColors[i].useLayer && (1 << rowItem.gameObject.layer & settings.instantBackgroundColors[i].layer) != 0) ||
707-
(settings.instantBackgroundColors[i].useStartWith && !string.IsNullOrEmpty(settings.instantBackgroundColors[i].startWith) && rowItem.name.StartsWith(settings.instantBackgroundColors[i].startWith))
709+
(settings.instantBackgroundColors[i].useTag &&
710+
!string.IsNullOrEmpty(settings.instantBackgroundColors[i].tag) &&
711+
rowItem.gameObject.CompareTag(settings.instantBackgroundColors[i].tag)) ||
712+
(settings.instantBackgroundColors[i].useLayer &&
713+
(1 << rowItem.gameObject.layer & settings.instantBackgroundColors[i].layer) != 0) ||
714+
(settings.instantBackgroundColors[i].useStartWith &&
715+
!string.IsNullOrEmpty(settings.instantBackgroundColors[i].startWith) &&
716+
rowItem.name.StartsWith(settings.instantBackgroundColors[i].startWith))
708717
)
709718
{
710719
contain = true;
@@ -834,7 +843,8 @@ void DisplayCustomObjectIcon(Texture icon)
834843
if (icon == null)
835844
{
836845
icon = AssetPreview.GetMiniThumbnail(rowItem.gameObject);
837-
if (icon.name == "GameObject Icon" || icon.name == "d_GameObject Icon" || icon.name == "Prefab Icon" ||
846+
if (icon.name == "GameObject Icon" || icon.name == "d_GameObject Icon" ||
847+
icon.name == "Prefab Icon" ||
838848
icon.name == "d_Prefab Icon" || icon.name == "PrefabModel Icon" ||
839849
icon.name == "d_PrefabModel Icon")
840850
return;
@@ -1442,7 +1452,7 @@ void DirtyScene(Scene scene)
14421452

14431453
bool IsFirstRow(Rect rect) => rect.y / rect.height == 0;
14441454

1445-
int GetRowIndex(Rect rect) => (int) (rect.y / rect.height);
1455+
int GetRowIndex(Rect rect) => (int)(rect.y / rect.height);
14461456

14471457
bool InSelection(int ID) => Selection.Contains(ID) ? true : false;
14481458

@@ -1783,18 +1793,19 @@ internal static class Styles
17831793
internal static GUIStyle Header = new GUIStyle(TreeBoldLabel)
17841794
{
17851795
richText = true,
1786-
normal = new GUIStyleState() {textColor = Color.white}
1796+
normal = new GUIStyleState() { textColor = Color.white }
17871797
};
17881798

1799+
// Unity 2022+
17891800
internal static GUIStyle TreeBoldLabel
17901801
{
1791-
get { return UnityEditor.IMGUI.Controls.TreeView.DefaultStyles.boldLabel; }
1802+
get { return EditorStyles.boldLabel; } // can also use UIElementsStyleHelper.GetBoldStyle()
17921803
}
17931804

1794-
internal static GUIStyle TreeLabel = new GUIStyle(UnityEditor.IMGUI.Controls.TreeView.DefaultStyles.label)
1805+
internal static GUIStyle TreeLabel = new GUIStyle(EditorStyles.label)
17951806
{
17961807
richText = true,
1797-
normal = new GUIStyleState() {textColor = Color.white}
1808+
normal = new GUIStyleState() { textColor = Color.white }
17981809
};
17991810
}
18001811

@@ -1863,7 +1874,8 @@ static void QuickSiblingUp()
18631874
var index = gameObject.transform.GetSiblingIndex();
18641875
if (index > 0)
18651876
{
1866-
Undo.SetTransformParent(gameObject.transform, gameObject.transform.parent, string.Format("{0} Parenting", gameObject.name));
1877+
Undo.SetTransformParent(gameObject.transform, gameObject.transform.parent,
1878+
string.Format("{0} Parenting", gameObject.name));
18671879

18681880
gameObject.transform.SetSiblingIndex(--index);
18691881
}
@@ -1879,7 +1891,8 @@ static void QuickSiblingDown()
18791891
if (gameObject == null)
18801892
return;
18811893

1882-
Undo.SetTransformParent(gameObject.transform, gameObject.transform.parent, string.Format("{0} Parenting", gameObject.name));
1894+
Undo.SetTransformParent(gameObject.transform, gameObject.transform.parent,
1895+
string.Format("{0} Parenting", gameObject.name));
18831896

18841897
var index = gameObject.transform.GetSiblingIndex();
18851898
gameObject.transform.SetSiblingIndex(++index);
@@ -1891,7 +1904,8 @@ static void QuickSiblingDown()
18911904
[MenuItem("Tools/Hierarchy 2/Separator", priority = 0)]
18921905
static void CreateHeaderInstance(UnityEditor.MenuCommand command)
18931906
{
1894-
GameObject gameObject = new GameObject(string.Format("{0}Separator", HierarchyEditor.instance.settings.separatorStartWith));
1907+
GameObject gameObject = new GameObject(string.Format("{0}Separator",
1908+
HierarchyEditor.instance.settings.separatorStartWith));
18951909

18961910
Undo.RegisterCreatedObjectUndo(gameObject, "Create Separator");
18971911
// Don't create headers as children of the selected objects because only root headers are drawn with background

0 commit comments

Comments
 (0)