Created
August 14, 2020 06:07
-
-
Save heppoko/e0f753a3001a982157bdbb793a725182 to your computer and use it in GitHub Desktop.
CustomHierarchy
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 UnityEngine; | |
using UnityEditor; | |
public class CustomHierarchy : MonoBehaviour | |
{ | |
[InitializeOnLoadMethod] | |
private static void AddHierarchyItemOnGUI() | |
{ | |
EditorApplication.hierarchyWindowItemOnGUI += HierarchyWindowItemOnGUI; | |
} | |
private static void HierarchyWindowItemOnGUI(int instanceID, Rect selectionRect) | |
{ | |
var gameObject = EditorUtility.InstanceIDToObject(instanceID) as GameObject; | |
if (gameObject == null) return; | |
Rect leftRect = new Rect(selectionRect.x - 10, selectionRect.y, 10, selectionRect.height); | |
var originalBgColor = GUI.backgroundColor; | |
if (gameObject.GetComponent<Light>() != null) | |
{ | |
GUI.backgroundColor = new Color(1.0f, 1.0f, 0.0f, 0.2f); | |
GUI.Box(selectionRect, ""); | |
EditorGUI.DrawRect(leftRect, new Color(1.0f, 1.0f, 0.0f, 1.0f)); | |
} | |
else if (gameObject.GetComponent<Camera>() != null) | |
{ | |
GUI.backgroundColor = new Color(1.0f, 0.0f, 0.0f, 0.2f); | |
GUI.Box(selectionRect, ""); | |
EditorGUI.DrawRect(leftRect, new Color(1.0f, 0.0f, 0.0f, 1.0f)); | |
} | |
else | |
{ | |
GUI.backgroundColor = new Color(0.0f, 0.0f, 1.0f, 0.2f); | |
GUI.Box(selectionRect, ""); | |
EditorGUI.DrawRect(leftRect, new Color(0.0f, 0.0f, 1.0f, 1.0f)); | |
} | |
GUI.backgroundColor = originalBgColor; | |
} | |
} |
Author
heppoko
commented
Aug 14, 2020
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment