Forked from giacomelli/HierarchyWindowGameObjectIcon.cs
Created
July 16, 2019 22:50
-
-
Save Novack/ecfa828d0e8c57260f148302263fefc1 to your computer and use it in GitHub Desktop.
#unitytips: Hierarchy window game object icon - http://diegogiacomelli.com.br/unitytips-hierarchy-window-gameobject-icon/
This file contains hidden or 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 game object icon. | |
| /// http://diegogiacomelli.com.br/unitytips-hierarchy-window-gameobject-icon/ | |
| /// </summary> | |
| [InitializeOnLoad] | |
| public static class HierarchyWindowGameObjectIcon | |
| { | |
| const string IgnoreIcons = "GameObject Icon, Prefab Icon"; | |
| static HierarchyWindowGameObjectIcon() | |
| { | |
| EditorApplication.hierarchyWindowItemOnGUI += HandleHierarchyWindowItemOnGUI; | |
| } | |
| static void HandleHierarchyWindowItemOnGUI(int instanceID, Rect selectionRect) | |
| { | |
| var content = EditorGUIUtility.ObjectContent(EditorUtility.InstanceIDToObject(instanceID), null); | |
| if (content.image != null && !IgnoreIcons.Contains(content.image.name)) | |
| GUI.DrawTexture(new Rect(selectionRect.xMax - 16, selectionRect.yMin, 16, 16), content.image); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment