Concept
Staying organized and efficient is crucial. As a gamedev, I’ve often struggled with cluttered hierarchy in Unity, making it difficult to find and manage game objects. This not only slows down productivity but leads to frustration.
To tackle this issue, I modified Feddas “ColorInHierarchy” to create a custom system that lets user color-code hierarchy elements and add custom icons.
This simple tool transforms the Unity hierarchy into a visually intuitive and easy-to-navigate structure, greatly enhancing workflow.
Link to original: ColorInHierarchy

Setup
You can just create new script with that name and fill it with content below.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System;
#if UNITY_EDITOR
using UnityEditor;
[UnityEditor.InitializeOnLoad]
#endif
public class ColorInHierarchy : MonoBehaviour
{
#if UNITY_EDITOR
#region [ static - Update editor ]
private static Dictionary coloredText = new Dictionary();
private static Dictionary coloredBackground = new Dictionary();
private static Dictionary coloredIcon = new Dictionary();
private static Vector2 offset = new Vector2(18, 0);
private static Color widowBackground = new Color(0.2196079f, 0.2196079f, 0.2196079f, 1f);
static ColorInHierarchy()
{
EditorApplication.hierarchyWindowItemOnGUI += HandleHierarchyWindowItemOnGUI;
}
private static void HandleHierarchyWindowItemOnGUI(int instanceID, Rect selectionRect)
{
var obj = EditorUtility.InstanceIDToObject(instanceID);
if (obj != null && coloredBackground.ContainsKey(obj))
{
if ((obj as GameObject).GetComponent())
{
HierarchyBackground(selectionRect, coloredBackground[obj]);
}
else
{
coloredBackground.Remove(obj);
}
}
if (obj != null && coloredIcon.ContainsKey(obj))
{
if ((obj as GameObject).GetComponent())
{
HierarchyIconBg(selectionRect);
HierarchyIcon(selectionRect, coloredIcon[obj]);
}
else
{
coloredIcon.Remove(obj);
}
}
if (obj != null && coloredText.ContainsKey(obj))
{
if ((obj as GameObject).GetComponent())
{
HierarchyText(obj, selectionRect, coloredText[obj]);
}
else
{
coloredText.Remove(obj);
}
}
}
private static void HierarchyText(UnityEngine.Object obj, Rect selectionRect, Color colorText)
{
Rect offsetRect = new Rect(selectionRect.position + offset, selectionRect.size);
EditorGUI.LabelField(offsetRect, obj.name, new GUIStyle()
{
normal = new GUIStyleState() { textColor = colorText },
fontStyle = FontStyle.Normal
}
);
}
private static void HierarchyBackground(Rect selectionRect, Color colorBackground)
{
Rect bgRect = new Rect(selectionRect.x, selectionRect.y, selectionRect.width + 50, selectionRect.height);
EditorGUI.DrawRect(bgRect, colorBackground);
}
private static void HierarchyIconBg(Rect selectionRect)
{
Rect icRect = new Rect(selectionRect.x - 2, selectionRect.y, 20, 18);
Color windowBg = widowBackground;
EditorGUI.DrawRect(icRect, windowBg);
}
private static void HierarchyIcon(Rect selectionRect, Sprite colorIcon)
{
Rect icRect = new Rect(selectionRect.x - 2, selectionRect.y - 2, 20, 20);
Texture2D tex = colorIcon.texture;
GUI.Label(icRect, tex);
}
#endregion [ static - Update editor ]
public Color colorText = Color.white;
public Color colorBackground = Color.grey;
public Sprite icon;
private void Reset()
{
OnValidate();
}
private void OnValidate()
{
SetAppearance();
}
private void Awake()
{
SetAppearance();
}
private void SetAppearance()
{
if (false == coloredBackground.ContainsKey(this.gameObject))
{
coloredBackground.Add(this.gameObject, colorBackground);
}
else if (coloredBackground[this.gameObject] != colorBackground)
{
coloredBackground[this.gameObject] = colorBackground;
}
if (icon)
{
if (icon && (false == coloredIcon.ContainsKey(this.gameObject)))
{
coloredIcon.Add(this.gameObject, icon);
}
else if (coloredIcon[this.gameObject] != icon)
{
coloredIcon[this.gameObject] = icon;
}
}
if (false == coloredText.ContainsKey(this.gameObject))
{
coloredText.Add(this.gameObject, colorText);
}
else if (coloredText[this.gameObject] != colorText)
{
coloredText[this.gameObject] = colorText;
}
}
#endif
}
Note that line 19 defines the background color of the hierarchy window. For dark mode it is
new Color(0.2196079f, 0.2196079f, 0.2196079f, 1f).
If you are using light mode, please change this value. This position results from the fact that to prevent the original icon from appearing under our selected icon, it must be covered with a rect in the background color.
Unity applies a tint (e.g. in gameplay mode) over this rect, so it will look good.
I suggest also addint icon to script, so after addind component it will stand out.

You can use this one (based on Bucket icons created by Those Icons – Flaticon)
Just remember that all icons must have Texture Type set to Sprite (2D and UI).
