private void drawComponents(List <QBaseComponent> components, Rect selectionRect, ref Rect curRect, GameObject gameObject, QObjectList objectList, bool trim = false, float minX = 50) { Rect rect = new Rect(curRect); if (Event.current.type == EventType.Repaint) { for (int i = 0, n = components.Count; i < n; i++) { QBaseComponent component = components[i]; if (component.isEnabled()) { component.layout(gameObject, objectList, ref rect); if (trim && minX > rect.x) { rect.Set(curRect.x - 7, curRect.y, 7, 16); GUI.DrawTexture(rect, trimIcon); return; } component.draw(gameObject, objectList, selectionRect, rect); curRect.Set(rect.x, rect.y, rect.width, rect.height); } else { component.disabledHandler(gameObject, objectList); } } } else if (Event.current.isMouse) { for (int i = 0, n = components.Count; i < n; i++) { QBaseComponent component = components[i]; if (component.isEnabled()) { component.layout(gameObject, objectList, ref rect); if (trim && minX > rect.x) { rect.Set(curRect.x - 7, curRect.y, 7, 16); GUI.DrawTexture(rect, trimIcon); return; } component.eventHandler(gameObject, objectList, Event.current, rect); curRect.Set(rect.x, rect.y, rect.width, rect.height); } } } }
private void drawComponents(List <QBaseComponent> components, Rect selectionRect, ref Rect rect, GameObject gameObject, QObjectList objectList, bool drawBackground = false, float minX = 50) { if (Event.current.type == EventType.Repaint) { int toComponent = components.Count; QLayoutStatus layoutStatus = QLayoutStatus.Success; for (int i = 0, n = toComponent; i < n; i++) { QBaseComponent component = components[i]; if (component.isEnabled()) { layoutStatus = component.layout(gameObject, objectList, selectionRect, ref rect, rect.x - minX); if (layoutStatus != QLayoutStatus.Success) { toComponent = layoutStatus == QLayoutStatus.Failed ? i : i + 1; rect.x -= 7; break; } } else { component.disabledHandler(gameObject, objectList); } } if (drawBackground) { if (backgroundColor.a != 0) { rect.width = selectionRect.x + selectionRect.width - rect.x /*- indentation*/; EditorGUI.DrawRect(rect, backgroundColor); } drawComponents(preComponents, selectionRect, ref rect, gameObject, objectList); } for (int i = 0, n = toComponent; i < n; i++) { QBaseComponent component = components[i]; if (component is QLockComponent && gameObject.tag == "Visual Break") { } else if (component is QVisibilityComponent && gameObject.tag == "Visual Break") { } else { if (component.isEnabled()) { component.draw(gameObject, objectList, selectionRect); } } } if (layoutStatus != QLayoutStatus.Success) { rect.width = 7; QColorUtils.setColor(inactiveColor); GUI.DrawTexture(rect, trimIcon); QColorUtils.clearColor(); } } else if (Event.current.isMouse) { if (gameObject.tag == "Visual Break") { return; } for (int i = 0, n = components.Count; i < n; i++) { QBaseComponent component = components[i]; if (component.isEnabled()) { if (component.layout(gameObject, objectList, selectionRect, ref rect, rect.x - minX) != QLayoutStatus.Failed) { component.eventHandler(gameObject, objectList, Event.current); } } } } }