void HighlightInHierarchy() { selection = Selection.activeTransform; if (selection) { HierarchyHighlighterComponent hh = selection.GetComponent <HierarchyHighlighterComponent>(); if (hh == null) { selection.gameObject.AddComponent <HierarchyHighlighterComponent>(); hh = selection.gameObject.GetComponent <HierarchyHighlighterComponent>(); } else { DestroyImmediate(hh); return; } var floorValue = 0.2f; var restValue = 1 - floorValue; hh.color = new Color(floorValue + restValue * Random.value, floorValue + restValue * Random.value, floorValue + restValue * Random.value, 0.3f); hh.type = HierarchyHighlighterComponent.HighlightOn.Always; } else { Debug.Log("Select object first"); } }
private static void HierarchyWindowItem_CB(int selectionID, Rect selectionRect) { var o = EditorUtility.InstanceIDToObject(selectionID); if (o == null) { return; } h = ((GameObject)o).GetComponent <HierarchyHighlighterComponent>(); if (h == null) { return; } if (SkipHighlight()) { return; } if (Event.current.type != EventType.Repaint) { return; } EditorGUI.DrawRect(selectionRect, h.color); EditorApplication.RepaintHierarchyWindow(); }
static void AddGameLogicObjects() { GameObject playableBase = new GameObject("###PlayableBase###"); playableBase.tag = "PlayBase"; playableBase.AddComponent <MainManager>(); HierarchyHighlighterComponent hhc = playableBase.AddComponent <HierarchyHighlighterComponent>(); hhc.color = Color.red; hhc.highlight = true; playableBase.transform.position = new Vector3(0, 0, 0); VirtualController vc = GameObject.Instantiate(AssetDatabase.LoadAssetAtPath <VirtualController>("Assets/Prefabs/Runtime/VirtualController.prefab")); ManagerBase mb = GameObject.Instantiate(AssetDatabase.LoadAssetAtPath <ManagerBase>("Assets/Prefabs/Runtime/ManagerBase.prefab")); DialogueBoxManager dbm = GameObject.Instantiate(AssetDatabase.LoadAssetAtPath <DialogueBoxManager>("Assets/Prefabs/Runtime/DialogueBoxManager.prefab")); GameObject coreLogic = GameObject.Instantiate(AssetDatabase.LoadAssetAtPath <GameObject>("Assets/Prefabs/Runtime/CoreLogic.prefab")); vc.name = "###VIRTUALCONTROLLER###"; mb.name = "###MANAGERBASE###"; dbm.name = "###DIALOGUEBOXMANAGER###"; coreLogic.transform.SetParent(playableBase.transform); vc.transform.SetParent(playableBase.transform); mb.transform.SetParent(playableBase.transform); dbm.transform.SetParent(playableBase.transform); mb.dialogueBoxManager = dbm; }
private static void HierarchyWindowItem_CB(int selectionID, Rect selectionRect) { Object o = EditorUtility.InstanceIDToObject(selectionID); if (o != null) { if ((o as GameObject).GetComponent <HierarchyHighlighterComponent>() != null) { HierarchyHighlighterComponent h = (o as GameObject).GetComponent <HierarchyHighlighterComponent>(); if (h.highlight) { GUIStyle style = new GUIStyle(); style.normal.textColor = h.color; style.alignment = TextAnchor.UpperRight; if (Event.current.type == EventType.Repaint) { style.Draw(selectionRect, new GUIContent("LE "), selectionID); EditorApplication.RepaintHierarchyWindow(); } } } } }