//private HierarchyProEditorRenderers renderers; //private HierarchyProEditorColliders colliders; public HierarchyProEditor(GameObject gameObject) { this.gameObject = gameObject; this.staticFlags = new HierarchyProEditorStaticFlags(this); this.components = new HierarchyProEditorComponents(this); this.prefabs = new HierarchyProEditorPrefabs(this); this.layersTags = new HierarchyProEditorLayersTags(this); //this.colliders = new HierarchyProEditorColliders(this); //this.renderers = new HierarchyProEditorRenderers(this); }
private Rect DrawStack(Rect rect, KeyValuePair <Texture, List <KeyValuePair <Component, Behaviour> > > stack) { Texture icon = stack.Key; int stackCount = stack.Value.Count; bool stackMultiple = stackCount > 1; Component[] components = stack.Value.Select(x => x.Key).ToArray(); Behaviour[] behaviours = stack.Value.Select(x => x.Value).ToArray(); bool disabled = behaviours.Any(x => (x != null) && !x.enabled); Rect right = new Rect(rect) { xMin = rect.xMax - 16, width = 16 }; GUI.color = disabled ? new Color(1, 1, 1, 0.2f) : Color.white; GUI.DrawTexture(right, icon); GUI.color = Color.white; if (stackMultiple) { Rect rectNumber = new Rect(right); rectNumber.x -= 1; GUIContent content = new GUIContent(stackCount.ToString()); GUI.color = new Color(0, 0, 0, 0.5f); GUI.Label(new Rect(rectNumber) { x = rectNumber.x - 2 }, content, HierarchyProEditorStyles.LabelNumber); GUI.Label(new Rect(rectNumber) { x = rectNumber.x + 2 }, content, HierarchyProEditorStyles.LabelNumber); GUI.Label(new Rect(rectNumber) { x = rectNumber.x - 1, y = rectNumber.y - 1 }, content, HierarchyProEditorStyles.LabelNumber); GUI.Label(new Rect(rectNumber) { x = rectNumber.x + 1, y = rectNumber.y - 1 }, content, HierarchyProEditorStyles.LabelNumber); GUI.Label(new Rect(rectNumber) { x = rectNumber.x - 1, y = rectNumber.y + 1 }, content, HierarchyProEditorStyles.LabelNumber); GUI.Label(new Rect(rectNumber) { x = rectNumber.x + 1, y = rectNumber.y + 1 }, content, HierarchyProEditorStyles.LabelNumber); GUI.Label(new Rect(rectNumber) { x = rectNumber.x - 1 }, content, HierarchyProEditorStyles.LabelNumber); GUI.Label(new Rect(rectNumber) { x = rectNumber.x + 1 }, content, HierarchyProEditorStyles.LabelNumber); GUI.Label(new Rect(rectNumber) { y = rectNumber.y - 1 }, content, HierarchyProEditorStyles.LabelNumber); GUI.Label(new Rect(rectNumber) { y = rectNumber.y + 1 }, content, HierarchyProEditorStyles.LabelNumber); GUI.color = Color.white; GUI.Label(rectNumber, content, HierarchyProEditorStyles.LabelNumber); } if (GUI.Button(right, GUIContent.none, GUIStyle.none)) { if (Event.current.button == 0) { if (stackMultiple) { if (Event.current.shift) { if (icon == HierarchyProEditorIcons.ScriptCS) { MonoScript[] scripts = behaviours.Select(x => MonoScript.FromMonoBehaviour(x as MonoBehaviour)).Where(x => x != null).ToArray(); if (!scripts.Any()) { HierarchyProEditorWindow.EditorWindow.ShowNotification(new GUIContent("No MonoScripts")); } else { GenericMenu menu = new GenericMenu(); menu.AddDisabledItem(new GUIContent("Open Script")); menu.AddSeparator(""); foreach (MonoScript script in scripts) { menu.AddItem(new GUIContent(string.Format("{0}.cs", script.GetClass().Name)), false, this.OpenScript, script); } menu.ShowAsContext(); Event.current.Use(); } } } else { MonoBehaviour[] monoBehaviours = behaviours.OfType <MonoBehaviour>().ToArray(); if (!monoBehaviours.Any()) { HierarchyProEditorWindow.EditorWindow.ShowNotification(new GUIContent("No Behaviours")); } else { GenericMenu menu = new GenericMenu(); menu.AddDisabledItem(new GUIContent("Enable \u2215 Disable")); menu.AddSeparator(""); foreach (Behaviour behaviour in behaviours) { MonoBehaviour monoBehvaiour = behaviour as MonoBehaviour; if (monoBehvaiour == null) { continue; } MonoScript script = MonoScript.FromMonoBehaviour(monoBehvaiour); menu.AddItem(new GUIContent(script.GetClass().Name), behaviour.enabled, this.ToggleScript, behaviour); } menu.AddSeparator(""); menu.AddItem(new GUIContent("Enable All"), false, this.EnableAllScripts, behaviours); menu.AddItem(new GUIContent("Disable All"), false, this.DisableAllScripts, behaviours); menu.ShowAsContext(); Event.current.Use(); } } } else { Component singleComponent = components.First(); Behaviour singleBehaviour = behaviours.First(); if (Event.current.shift) { if (icon == HierarchyProEditorIcons.ScriptCS) { MonoScript script = MonoScript.FromMonoBehaviour(singleComponent as MonoBehaviour); AssetDatabase.OpenAsset(script, 1); } else if (singleComponent is Light) { EditorWindow lightingWindow = HierarchyProEditorComponents.GetLightingWindow(); lightingWindow.Show(); } } else { if (singleBehaviour != null) { singleBehaviour.enabled = !singleBehaviour.enabled; } } } } } right.x -= 16; return(right); }