using UnityEditor; using UnityEngine; public static class HierarchyFontColoring { static readonly Vector2 offset = new Vector2(18f, 0); // どんなフォントカラーに変更するか static readonly Color separatorColor = new Color(1f, 0f, 0f); [InitializeOnLoadMethod] static void AddHierarchyItemOnGUI() { EditorApplication.hierarchyWindowItemOnGUI += HierarchyWindowItemOnGUI; } static void HierarchyWindowItemOnGUI(int instanceId, Rect selectionRect) { var gameObject = EditorUtility.InstanceIDToObject(instanceId) as GameObject; if (gameObject == null) { return; } // フォントカラーを変更したいコンポーネント var target = gameObject.GetComponent<Camera>(); if (target == null) { return; } var offsetRect = new Rect(selectionRect.position + offset, selectionRect.size); EditorGUI.LabelField(offsetRect, gameObject.name, new GUIStyle { normal = new GUIStyleState { textColor = separatorColor } }); } }
コメントの箇所を適宜書き換えてください。