public static void DrawWithCache(int instanceID, Rect selectionRect) { Item item; if (HierarchyEditor.cache.TryGetValue(instanceID, out item) == false) { item = new Item(); item.hasScreen = HierarchyEditor.markedScreens.Contains(instanceID); item.hasLayout = HierarchyEditor.markedLayouts.Contains(instanceID); item.hasComponent = HierarchyEditor.markedComponents.Contains(instanceID); var obj = Object.FindObjectsOfType <GameObject>().FirstOrDefault((element) => element.GetInstanceID() == instanceID); if (obj != null) { var window = obj.GetComponent <LayoutWindowType>(); if (window != null) { if (window.transition.transition != null) { item.hasTransition = true; } if (window.modules.GetModulesInfo().Count() > 0) { item.hasModule = true; } } } HierarchyEditor.cache.Add(instanceID, item); } HierarchyEditor.OnItemGUI(instanceID, selectionRect, item); }
public static void Update() { if (HierarchyEditor.updateTimer < 1f && Application.isPlaying == true) { HierarchyEditor.updateTimer += Time.deltaTime; return; } HierarchyEditor.updateTimer = 0f; HierarchyEditor.OnChanged(); }
public static void HierarchyItemGUI(int instanceID, Rect selectionRect) { HierarchyEditor.DrawWithCache(instanceID, selectionRect); }
public static void OnItemGUI(int instanceID, Rect selectionRect, Item item) { const float sizeX = 32f; const float sizeY = 16f; const float offset = 1f; const float firstElementDeltaHeight = 5f; const float leftOffset = 14f; if (HierarchyEditor.backgroundStyle == null) { HierarchyEditor.backgroundStyle = new GUIStyle(EditorStyles.label); HierarchyEditor.backgroundStyle.normal.background = Texture2D.whiteTexture; } selectionRect.width += offset; var levels = 0; var rect = new Rect(selectionRect); rect.x += rect.width - offset; rect.width = sizeX; rect.height = sizeY; if (HierarchyEditor.first != null && HierarchyEditor.first.GetInstanceID() == instanceID) { rect.y -= firstElementDeltaHeight; rect.height += firstElementDeltaHeight; CustomGUI.Splitter(new Rect(selectionRect.xMin - leftOffset, HierarchyEditor.top, selectionRect.width + leftOffset, 1f)); } // Draw background var back = GUI.backgroundColor; GUI.backgroundColor = new Color(0.7f, 0.7f, 0.7f, 0.5f); GUI.Label(new Rect(HierarchyEditor.left - offset, rect.yMin, sizeX * HierarchyEditor.levels + offset, rect.height), string.Empty, HierarchyEditor.backgroundStyle); GUI.backgroundColor = back; if (item.hasScreen == true) { rect.x -= sizeX; HierarchyEditor.DrawLabel(rect, HierarchyEditor.colors.screens, "SCR"); ++levels; if (item.hasTransition == true) { rect.x -= sizeX; HierarchyEditor.DrawLabel(rect, HierarchyEditor.colors.transitions, "TR"); ++levels; } if (item.hasModule == true) { rect.x -= sizeX; HierarchyEditor.DrawLabel(rect, HierarchyEditor.colors.modules, "MOD"); ++levels; } } if (item.hasLayoutElement == true) { rect.x -= sizeX; HierarchyEditor.DrawLabel(rect, HierarchyEditor.colors.layoutElements, "LE"); ++levels; } if (item.hasLayout == true) { rect.x -= sizeX; HierarchyEditor.DrawLabel(rect, HierarchyEditor.colors.layouts, "LAY"); ++levels; } if (item.hasLinker == true) { rect.x -= sizeX; HierarchyEditor.DrawLabel(rect, HierarchyEditor.colors.linkers, "LNK"); ++levels; } else if (item.hasComponent == true) { rect.x -= sizeX; HierarchyEditor.DrawLabel(rect, HierarchyEditor.colors.components, "COM"); ++levels; } CustomGUI.Splitter(new Rect(HierarchyEditor.left - offset, rect.yMin, 1f, rect.height)); if (levels > HierarchyEditor.levels) { HierarchyEditor.levels = levels; } if (rect.xMin < HierarchyEditor.left || HierarchyEditor.left <= 0f) { HierarchyEditor.left = rect.xMin; } if (rect.yMax > HierarchyEditor.top || HierarchyEditor.top == 0f) { HierarchyEditor.top = rect.yMax; } }