|
|
|
|
|
|
using UnityEngine.Experimental.VFX; |
|
|
|
using UnityEditor; |
|
|
|
using GameplayIngredients; |
|
|
|
using UnityEngine.Playables; |
|
|
|
|
|
|
|
namespace GameplayIngredients.Editor |
|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
static void HierarchyOnGUI(int instanceID, Rect selectionRect) |
|
|
|
{ |
|
|
|
var fullRect = selectionRect; |
|
|
|
fullRect.xMin = 0; |
|
|
|
fullRect.xMax = EditorGUIUtility.currentViewWidth; |
|
|
|
|
|
|
|
var c = GUI.color; |
|
|
|
if (o.isStatic) |
|
|
|
{ |
|
|
|
GUI.Label(fullRect, "(s)"); |
|
|
|
EditorGUI.DrawRect(fullRect, Colors.dimGray); |
|
|
|
} |
|
|
|
var c = GUI.color; |
|
|
|
if (o.isStatic) selectionRect = DrawLabel(selectionRect, "#", Color.gray); |
|
|
|
if (o.GetComponents<MonoBehaviour>().Length > 0) selectionRect = DrawLabel(selectionRect, "*", Colors.green); |
|
|
|
if (o.GetComponents<Camera>().Length > 0) selectionRect = DrawContent(selectionRect, Contents.cameraIcon, Color.white); |
|
|
|
if (o.GetComponents<Light>().Length > 0) selectionRect = DrawLabel(selectionRect, "L", Colors.yellow); |
|
|
|
if (o.GetComponents<MeshRenderer>().Length > 0) selectionRect = DrawLabel(selectionRect, "M", Colors.purple); |
|
|
|
if (o.GetComponents<AudioSource>().Length > 0) selectionRect = DrawLabel(selectionRect, "S", Colors.orange); |
|
|
|
if (o.GetComponents<VisualEffect>().Length > 0) selectionRect = DrawLabel(selectionRect, "fx", Colors.red, 16); |
|
|
|
if (o.GetComponents<MonoBehaviour>().Length > 0) selectionRect = DrawconContent(selectionRect, Contents.monoBehaviourIcon, Color.white); |
|
|
|
if (o.GetComponents<MeshRenderer>().Length > 0) selectionRect = DrawconContent(selectionRect, Contents.meshIcon, Color.white); |
|
|
|
if (o.GetComponents<Collider>().Length > 0) selectionRect = DrawconContent(selectionRect, Contents.colliderIcon, Color.white); |
|
|
|
if (o.GetComponents<Camera>().Length > 0) selectionRect = DrawconContent(selectionRect, Contents.cameraIcon, Color.white); |
|
|
|
if (o.GetComponents<Light>().Length > 0) selectionRect = DrawconContent(selectionRect, Contents.lightIcon, Color.white); |
|
|
|
if (o.GetComponents<Animation>().Length > 0) selectionRect = DrawconContent(selectionRect, Contents.animationIcon, Color.white); |
|
|
|
if (o.GetComponents<Animator>().Length > 0) selectionRect = DrawconContent(selectionRect, Contents.animatorIcon, Color.white); |
|
|
|
if (o.GetComponents<PlayableDirector>().Length > 0) selectionRect = DrawconContent(selectionRect, Contents.directorIcon, Color.white); |
|
|
|
if (o.GetComponents<AudioSource>().Length > 0) selectionRect = DrawconContent(selectionRect, Contents.audioIcon, Color.white); |
|
|
|
if (o.GetComponents<VisualEffect>().Length > 0) selectionRect = DrawconContent(selectionRect, Contents.vfxIcon, Color.white); |
|
|
|
if (o.GetComponents<ParticleSystem>().Length > 0) selectionRect = DrawconContent(selectionRect, Contents.shurikenIcon, Color.white); |
|
|
|
|
|
|
|
static Rect DrawLabel(Rect rect, string label, Color color, int size = 12) |
|
|
|
static Rect DrawLabel(Rect rect, string label, Color color, int size = 16) |
|
|
|
{ |
|
|
|
GUI.color = color; |
|
|
|
GUI.Label(rect, label, Styles.rightLabel); |
|
|
|
|
|
|
|
|
|
|
static Rect DrawContent(Rect rect, GUIContent content, Color color, int size = 12) |
|
|
|
static Rect DrawconContent(Rect rect, GUIContent content, Color color, int size = 16) |
|
|
|
GUI.Label(rect, content, Styles.rightLabel); |
|
|
|
GUI.Label(rect, content, Styles.icon); |
|
|
|
rect.width = rect.width - size; |
|
|
|
return rect; |
|
|
|
} |
|
|
|
|
|
|
public static GUIContent cameraIcon = EditorGUIUtility.IconContent("Camera Icon"); |
|
|
|
public static GUIContent cameraIcon = EditorGUIUtility.IconContent("Camera Icon"); |
|
|
|
public static GUIContent meshIcon = EditorGUIUtility.IconContent("MeshRenderer Icon"); |
|
|
|
public static GUIContent colliderIcon = EditorGUIUtility.IconContent("BoxCollider Icon"); |
|
|
|
public static GUIContent audioIcon = EditorGUIUtility.IconContent("AudioSource Icon"); |
|
|
|
public static GUIContent animationIcon = EditorGUIUtility.IconContent("Animation Icon"); |
|
|
|
public static GUIContent animatorIcon = EditorGUIUtility.IconContent("Animator Icon"); |
|
|
|
public static GUIContent directorIcon = EditorGUIUtility.IconContent("PlayableDirector Icon"); |
|
|
|
public static GUIContent monoBehaviourIcon = EditorGUIUtility.IconContent("cs Script Icon"); |
|
|
|
public static GUIContent shurikenIcon = EditorGUIUtility.IconContent("ParticleSystem Icon"); |
|
|
|
public static GUIContent vfxIcon = EditorGUIUtility.IconContent("VisualEffect Icon"); |
|
|
|
public static GUIContent lightIcon = EditorGUIUtility.IconContent("Light Icon"); |
|
|
|
} |
|
|
|
|
|
|
|
static class Colors |
|
|
|
|
|
|
public static Color blue = new Color(0.5f, 0.8f, 1.0f); |
|
|
|
public static Color violet = new Color(0.8f, 0.5f, 1.0f); |
|
|
|
public static Color purple = new Color(1.0f, 0.5f, 0.8f); |
|
|
|
public static Color dimGray = new Color(0.4f, 0.4f, 0.4f, 0.2f); |
|
|
|
public static GUIStyle icon; |
|
|
|
|
|
|
|
static Styles() |
|
|
|
{ |
|
|
|
rightLabel = new GUIStyle(EditorStyles.label); |
|
|
|
|
|
|
|
|
|
|
rightLabel.active.textColor = Color.white; |
|
|
|
rightLabel.onActive.textColor = Color.white; |
|
|
|
|
|
|
|
icon = new GUIStyle(rightLabel); |
|
|
|
icon.padding = new RectOffset(); |
|
|
|
icon.margin = new RectOffset(); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|