Last active
October 17, 2020 17:17
-
-
Save giacomelli/096005d0d0df79b94321f950138220a3 to your computer and use it in GitHub Desktop.
#unitytips: Hierarchy Window Layer Info: http://diegogiacomelli.com.br/unitytips-hierarchy-window-layer-info/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEditor; | |
using UnityEngine; | |
// <summary> | |
/// Hierarchy Window Layer Info | |
/// http://diegogiacomelli.com.br/unitytips-hierarchy-window-layer-info/ | |
/// </summary> | |
[InitializeOnLoad] | |
public static class HierarchyWindowLayerInfo | |
{ | |
static readonly int IgnoreLayer = LayerMask.NameToLayer("Default"); | |
static readonly GUIStyle _style = new GUIStyle() | |
{ | |
fontSize = 9, | |
alignment = TextAnchor.MiddleRight | |
}; | |
static HierarchyWindowLayerInfo() | |
{ | |
EditorApplication.hierarchyWindowItemOnGUI += HandleHierarchyWindowItemOnGUI; | |
} | |
static void HandleHierarchyWindowItemOnGUI(int instanceID, Rect selectionRect) | |
{ | |
var gameObject = EditorUtility.InstanceIDToObject(instanceID) as GameObject; | |
if (gameObject != null && gameObject.layer != IgnoreLayer) | |
{ | |
EditorGUI.LabelField(selectionRect, LayerMask.LayerToName(gameObject.layer), _style); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment