Forked from giacomelli/HierarchyWindowGameObjectIcon.cs
Created
August 22, 2019 14:19
-
-
Save belzecue/83f3c97ec31d8ac791db515e5b66edff 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