private Rect BaseType(Rect full, Rect previous) { if ((ObjectKind)kind.value == ObjectKind.Class) { var genericsHeight = GetGenericArgumentsHeight(GenericBaseTypeConstruct.Base, full.width, 14); var baseTypeRect = previous; baseTypeRect.y += previous.height - 1; baseTypeRect.height = genericsHeight + 40 + 9; // Draw a rectangle that contains a border and is light grey. Color usage for differentiating sections. UtilityGUI.Container(baseTypeRect, Color.black, 0.6f.Grey(), 1, 10, (container) => { UtilityGUI.Container(container, Color.black, 0.8f.Grey(), 1, 4, (_container) => { var icon = UAliveIcons.SetWhenNull("Type", UAliveIcons.IconFromPathLudiq("System.Type", UAliveIcons.IconSize.Large)); UtilityGUI.BorderRect(new Rect(container.x, container.y, container.width, 24), 1, 0.3f.Grey(), Color.black, UtilityGUI.BorderDrawPlacement.Inside); Graphics.DrawTexture(new Rect(container.x + 5, container.y + 4, 16, 16), icon); EditorGUI.LabelField(new Rect(_container.x + 20, _container.y, _container.width - 26, 16), "Base Type", new GUIStyle(EditorStyles.boldLabel) { normal = new GUIStyleState() { textColor = Color.white } }); LudiqGUI.Inspector(baseType, new Rect(_container.x + 14, _container.y + 32, _container.width - 20, genericsHeight - 6), GUIContent.none); }); }); return(baseTypeRect); } return(previous); }
private void Header(Rect container) { var indexGreaterThanOne = (accessor.parent.IndexOf(accessor.value) > 0); UtilityGUI.Container(new Rect(container.x, container.y + (indexGreaterThanOne ? 1 : 0), container.width, 26), Color.black, 0.6f.Grey(), 1, 5, (_container) => { var headerRect = new Rect(container.x, container.y + (indexGreaterThanOne ? 1 : 0), container.width, 26); Texture2D arrow = (bool)isOpenMeta.value ? UAliveResources.arrowDownDark : UAliveResources.arrowRightDark; Graphics.DrawTexture(new Rect(container.x + container.width - 20, container.y + 9, 10, 10), arrow); nameMeta.value = EditorGUI.TextField(new Rect(container.x + 32, container.y + (indexGreaterThanOne ? 5 : 4), container.width - 64, 18), (string)nameMeta.value); var type = (typeMeta.value as TypeValue).type; var _icon = type.FindIcon(); if (_icon != null) { Graphics.DrawTexture(new Rect(container.x + 8, container.y + 5, 16, 16), _icon); } if (_container.Contains(e.mousePosition) && e.type == EventType.MouseDown && e.button == 0) { isOpenMeta.value = !(bool)isOpenMeta.value; } // We are using a control that is invisible, so we cant prevent that area of the list from trying to be moved. GUI.Button(headerRect, GUIContent.none, GUIStyle.none); y += 20; }); }
private Rect Accessibility(Rect position) { // Set the surrounding box around scope and special. var accessibilityRect = position; accessibilityRect.y -= 1; accessibilityRect.height = 82; // Draw a rectangle that contains a border and is light grey. Color usage for differentiating sections. UtilityGUI.Container(accessibilityRect, Color.black, 0.6f.Grey(), 1, 10, (container) => { var scopeFullRect = container; scopeFullRect.height = container.height / 2 - 4; var kindRect = scopeFullRect; kindRect.y = scopeFullRect.y + scopeFullRect.height + 8; UtilityGUI.Container(scopeFullRect, Color.black, 0.7f.Grey(), 1, 6, (scopeContainer) => { // Set the rectangle for the scopes label var scopeRectLabel = scopeContainer; scopeRectLabel.width = 60; // Set the rectangle for the scopes control var scopeRect = scopeContainer; scopeRect.x += 60; scopeRect.width = (scopeContainer.width / 2) - 64; // Set the rectangle for the specials label var specialLabelRect = scopeRect; specialLabelRect.x += scopeRect.width + 10; specialLabelRect.width = 60; // Set the rectangle for the specials control var specialRect = scopeRect; specialRect.x += scopeRect.width + specialLabelRect.width + 4; specialRect.width = (accessibilityRect.width / 2) - 80; // Draw the scopes label GUI.Label(scopeRectLabel, new GUIContent("Scope")); Graphics.DrawTexture(new Rect(scopeRectLabel.x + 40, scopeRectLabel.y, 16, 16), UAliveResources.scope); // Draw the scope drop down LudiqGUI.Inspector(scope, scopeRect, GUIContent.none); // Draw the special label GUI.Label(specialLabelRect, new GUIContent("Modifier")); // Draw the special control LudiqGUI.Inspector(classModifier, specialRect, GUIContent.none); }); Kind(kindRect); }); return(accessibilityRect); }
protected override void OnGUIBlock(Rect position, GUIContent label) { var baseTypeRect = position; UtilityGUI.Container(baseTypeRect, Color.black, 0.6f.Grey(), 1, 4, (container) => { LudiqGUI.Inspector(accessor["type"], container, GUIContent.none); }); height = accessor["type"].Inspector().GetCachedHeight(position.width, GUIContent.none, accessor.Inspector()); }
private Rect Kind(Rect container) { Rect output = Rect.zero; UtilityGUI.Container(container, Color.black, 0.7f.Grey(), 1, 6, (kindContainer) => { // Set the rectangle for the scopes label var kindRectLabel = kindContainer; kindRectLabel.width = 60; // Set the rectangle for the scopes control var _kindRect = kindContainer; _kindRect.x += 60; _kindRect.width = (kindContainer.width / 2) - 64; ObjectKind _kind = (ObjectKind)kind.value; Texture2D kindIcon = null; switch (_kind) { case ObjectKind.Class: kindIcon = UAliveResources.@class; break; case ObjectKind.Struct: kindIcon = UAliveResources.@struct; break; case ObjectKind.Interface: kindIcon = UAliveResources.@interface; break; case ObjectKind.Enum: kindIcon = UAliveResources.@enum; break; case ObjectKind.Event: kindIcon = UAliveResources.@event; break; } GUI.Label(kindRectLabel, new GUIContent("Kind")); Graphics.DrawTexture(new Rect(kindRectLabel.x + 40, kindRectLabel.y, 16, 16), kindIcon); // Draw the special control LudiqGUI.Inspector(kind, _kindRect, GUIContent.none); output = _kindRect; }); return(output); }
public static Rect DrawSection(Rect position, Accessor _accessor, Accessor @base, Event e, string title, Texture2D icon, int heightModifier, bool togglable, Accessor isOpen) { var accessorHeight = _accessor.Inspector().GetCachedHeight(position.width, GUIContent.none, @base.Inspector()); var sectionRect = position; sectionRect.y = position.height + position.y - 2; sectionRect.height = (bool)isOpen.value ? accessorHeight + heightModifier : heightModifier; // Draw a rectangle that contains a border and is light grey. Color usage for differentiating sections. UtilityGUI.Container(sectionRect, Color.black, 0.6f.Grey(), 1, 10, (rootContainer) => { UtilityGUI.Container(rootContainer, Color.black, 0.8f.Grey(), 1, 4, (container) => { if (new Rect(container.x, container.y, container.width, 24).Contains(e.mousePosition)) { if (e.type == EventType.MouseDown && e.button == 0) { isOpen.value = !(bool)isOpen.value; } } UtilityGUI.BorderRect(new Rect(rootContainer.x, rootContainer.y, rootContainer.width, 24), 1, 0.3f.Grey(), Color.black, UtilityGUI.BorderDrawPlacement.Inside); Graphics.DrawTexture(new Rect(rootContainer.x + 5, rootContainer.y + 4, 16, 16), icon); EditorGUI.LabelField(new Rect(container.x + 20, container.y, container.width - 26, 16), title, new GUIStyle(EditorStyles.boldLabel) { normal = new GUIStyleState() { textColor = Color.white } }); var accessorRect = new Rect(container.x, container.y + 24, container.width, accessorHeight); if (togglable) { if ((bool)isOpen.value) { LudiqGUI.Inspector(_accessor, accessorRect, GUIContent.none); } Texture2D arrow = (bool)isOpen.value ? UAliveResources.arrowDownWhite : UAliveResources.arrowRightWhite; Graphics.DrawTexture(new Rect(container.x + container.width - 14, rootContainer.y + 6, 10, 10), arrow); return; } LudiqGUI.Inspector(_accessor, accessorRect, GUIContent.none); }); }); return(sectionRect); }
protected override void OnGUIBlock(Rect position, GUIContent label) { height = accessor["type"].Inspector().GetCachedHeight(position.width, GUIContent.none, accessor.Inspector()) + 4; var dropDownRect = position; dropDownRect.x += 15; dropDownRect.height = height; dropDownRect.width -= 18; dropDownRect.y += 8; UtilityGUI.Container(dropDownRect, Color.black, 0.6f.Grey(), 1, 2, (container) => { LudiqGUI.Inspector(accessor["type"], container, GUIContent.none); }); }
public Rect Options(Rect typeLabel, Rect typeDropDown, float heightModifier) { var fullRect = typeLabel; fullRect.height = 78; fullRect.x += 15; fullRect.width += typeDropDown.width - 40; fullRect.y += heightModifier + 8; UtilityGUI.Container(fullRect, Color.black, 0.7f.Grey(), 1, 4, (readContainer) => { var scopeRect = readContainer; scopeRect.height = 22; var modifierRect = scopeRect; modifierRect.y += 24; var readOnlyRect = modifierRect; readOnlyRect.y += 24; UtilityGUI.Container(scopeRect, Color.black, 0.8f.Grey(), 1, 2, (scopeContainer) => { GUI.Label(new Rect(scopeContainer.x, scopeContainer.y + 1, 70, scopeContainer.height), "Scope"); LudiqGUI.Inspector(scopeMeta, new Rect(scopeContainer.x + 70, scopeContainer.y + 1, scopeContainer.width - 70, scopeContainer.height), GUIContent.none); }); UtilityGUI.Container(modifierRect, Color.black, 0.8f.Grey(), 1, 2, (modifierContainer) => { GUI.Label(new Rect(modifierContainer.x, modifierContainer.y + 1, 70, modifierContainer.height), "Modifier"); LudiqGUI.Inspector(modifierMeta, new Rect(modifierContainer.x + 70, modifierContainer.y + 1, modifierContainer.width - 70, modifierContainer.height), GUIContent.none); }); UtilityGUI.Container(readOnlyRect, Color.black, 0.8f.Grey(), 1, 2, (readOnlyContainer) => { GUI.Label(new Rect(readOnlyContainer.x, readOnlyContainer.y + 1, 70, readOnlyContainer.height), "Read Only"); LudiqGUI.Inspector(accessor["isReadOnly"], new Rect(readOnlyContainer.x + 70, readOnlyContainer.y + 1, readOnlyContainer.width - 70, readOnlyContainer.height), GUIContent.none); }); }); return(fullRect); }
private Rect Header(Rect position) { var borderRect = position; borderRect.y += position.height; borderRect.height = 60; height += 60; UtilityGUI.Container(borderRect, Color.black, new Color(0.35f, 0.35f, 0.35f), 1, 10, (container) => { var nameLabelRect = new Rect(container.x + 64, container.y, 80, 16); EditorGUI.LabelField(nameLabelRect, "Name", new GUIStyle(EditorStyles.boldLabel) { normal = new GUIStyleState() { textColor = Color.white } }); var nameTextRect = new Rect(nameLabelRect.x + nameLabelRect.width + 6, container.y, container.width - nameLabelRect.width - 70, 16); name.value = EditorGUI.TextField(nameTextRect, GUIContent.none, (string)name.value); var categoryLabelRect = new Rect(container.x + 64, nameLabelRect.y + nameLabelRect.height + 6, 80, 16); EditorGUI.LabelField(categoryLabelRect, "Namespace", new GUIStyle(EditorStyles.boldLabel) { normal = new GUIStyleState() { textColor = Color.white } }); var categoryTextRect = new Rect(categoryLabelRect.x + categoryLabelRect.width + 6, categoryLabelRect.y, container.width - categoryLabelRect.width - 70, 16); @namespace.value = EditorGUI.TextField(categoryTextRect, GUIContent.none, (string)@namespace.value); }); return(new Rect(position.x, borderRect.y + borderRect.height, position.width, 60)); }
protected override void OnGUIBlock(Rect position, GUIContent label) { y = 0f; var containerRect = position; containerRect.x += 15; containerRect.height = height; containerRect.width -= 18; containerRect.y += 4; var backgroundColor = GUI.color; UtilityGUI.Container(containerRect, Color.black, 0.8f.Grey(), 1, 0, (container) => { Header(container); OpenContents(position, containerRect); }); height = y; }
public static Rect NestedSection(Rect position, Event e, string title, Texture2D icon, int heightModifier, Action <Rect> draw, Accessor conditional = null) { var sectionRect = position; sectionRect.y = position.y; sectionRect.height = position.height - 24 + heightModifier; Rect output = new Rect(); // Draw a rectangle that contains a border and is light grey. Color usage for differentiating sections. UtilityGUI.Container(sectionRect, Color.black, 0.6f.Grey(), 1, 0, (rootContainer) => { UtilityGUI.Container(rootContainer, Color.black, 0.8f.Grey(), 1, 4, (container) => { var header = new Rect(rootContainer.x, rootContainer.y, rootContainer.width, 24); UtilityGUI.BorderRect(new Rect(rootContainer.x, rootContainer.y, rootContainer.width, 24), 1, 0.3f.Grey(), Color.black, UtilityGUI.BorderDrawPlacement.Inside); Graphics.DrawTexture(new Rect(rootContainer.x + 5, rootContainer.y + 4, 16, 16), icon); EditorGUI.LabelField(new Rect(rootContainer.x + 20 + (conditional != null ? 20 : 4), rootContainer.y + 4, container.width - 26, 16), title, EditorStyles.whiteBoldLabel); var accessorRect = new Rect(container.x + 30, container.y + 42, container.width - 45, container.height); if (conditional != null) { LudiqGUI.Inspector(conditional, new Rect(container.x + 22, container.y, 16, 16), GUIContent.none); } GUI.Button(header, GUIContent.none, GUIStyle.none); output = accessorRect; draw(output); }); }); return(output); }
private void OpenContents(Rect position, Rect container) { if ((bool)isOpenMeta.value) { var typeHeight = LudiqGUI.GetInspectorHeight(typeMeta.Inspector(), typeMeta["type"], position.width, GUIContent.none); var valueHeight = LudiqGUI.GetInspectorHeight(typeMeta.Inspector(), typeMeta["value"], position.width, GUIContent.none); var typeLabel = new Rect(container.x + 5, container.y + y + 10, 60, 16); var typeRect = new Rect(container.x + 50, container.y + typeLabel.height + 16, container.width - 60, typeHeight); var defaultRect = new Rect(container.x + 50, typeRect.y + typeRect.height + 4, container.width - 60, typeHeight); var valueRect = new Rect(container.x + 10, typeRect.y + typeRect.height + defaultRect.height + 8, container.width - 20, valueHeight + 8); EditorGUI.LabelField(typeLabel, new GUIContent("Type")); LudiqGUI.Inspector(typeMeta["type"], typeRect, GUIContent.none); var addedHeight = 0; if (!((System.Type)typeMeta["type"].value).InheritsType(typeof(UnityEngine.Object))) { addedHeight += 16; LudiqGUI.Inspector(typeMeta["hasDefault"], defaultRect, new GUIContent("Default")); if ((bool)typeMeta["hasDefault"].value) { UtilityGUI.Container(valueRect, Color.black, 0.7f.Grey(), 1, 4, (valueContainer) => { if (typeMeta["value"].value != null || ((System.Type)typeMeta["type"].value).InheritsType(typeof(UnityEngine.Object))) { LudiqGUI.Inspector(typeMeta["value"], valueContainer, GUIContent.none); if ((System.Type)typeMeta["type"].value == typeof(bool)) { var boolLabel = valueContainer; boolLabel.x += 18; GUI.Label(boolLabel, (nameMeta.value as string).Prettify()); } } }); addedHeight += (int)valueRect.height + 10; } } var optionsRect = Options(typeLabel, typeRect, addedHeight + defaultRect.height); var propertiesRect = optionsRect; propertiesRect.width = typeLabel.width + typeRect.width; propertiesRect.x -= 20; propertiesRect.y += 86; propertiesRect.height = 56; var propertyHeight = propertyMeta.Inspector().GetCachedHeight(lastPosition.width, GUIContent.none, accessor.Inspector()) + addedHeight; var prop = ((Property)propertyMeta.value); var propName = string.Empty; UAliveGUI.NestedSection(propertiesRect, e, "Property", UAliveResources.properties, addedHeight, (propertiesContainer) => { LudiqGUI.Inspector(propertyMeta, new Rect(propertiesContainer.x, propertiesContainer.y, propertiesContainer.width - 40, propertyHeight)); }, isPropertyMeta); addedHeight += 30; y += typeHeight + defaultRect.height + optionsRect.height + propertiesRect.height + addedHeight + 4; } }
public static Rect DrawSection(Rect position, Accessor _accessor, Accessor @base, Event e, string title, Texture2D icon, int heightModifier, bool togglable, int items, Accessor isOpen, bool isEditor = false, List <Rect> untouchableAreas = null) { var accessorHeight = isEditor ? _accessor.Editor().GetCachedHeight(position.width, GUIContent.none, @base.Editor()) : _accessor.Inspector().GetCachedHeight(position.width, GUIContent.none, @base.Inspector()); var sectionRect = position; sectionRect.y = position.height + position.y - 2; sectionRect.height = (bool)isOpen.value ? accessorHeight + heightModifier : heightModifier; // Draw a rectangle that contains a border and is light grey. Color usage for differentiating sections. UtilityGUI.Container(sectionRect, Color.black, 0.6f.Grey(), 1, 10, (rootContainer) => { UtilityGUI.Container(rootContainer, Color.black, 0.8f.Grey(), 1, 4, (container) => { var canTouch = true; if (untouchableAreas != null) { foreach (Rect rect in untouchableAreas) { if (rect.Contains(e.mousePosition)) { canTouch = false; break; } } } if (canTouch && new Rect(container.x, container.y, container.width, 24).Contains(e.mousePosition)) { if (e.type == EventType.MouseDown && e.button == 0) { isOpen.value = !(bool)isOpen.value; } } UtilityGUI.BorderRect(new Rect(rootContainer.x, rootContainer.y, rootContainer.width, 24), 1, 0.3f.Grey(), Color.black, UtilityGUI.BorderDrawPlacement.Inside); Graphics.DrawTexture(new Rect(rootContainer.x + 5, rootContainer.y + 4, 16, 16), icon); EditorGUI.LabelField(new Rect(container.x + 20, container.y, container.width - 26, 16), title, new GUIStyle(EditorStyles.boldLabel) { normal = new GUIStyleState() { textColor = Color.white } }); var accessorRect = new Rect(container.x, container.y + 24, container.width, accessorHeight); UtilityGUI.BorderRect(new Rect(rootContainer.x + 100, rootContainer.y + 3, 20, 18), 1, 0.4f.Grey(), Color.black, UtilityGUI.BorderDrawPlacement.Inside); EditorGUI.LabelField(new Rect(rootContainer.x + 100, rootContainer.y + 3, 20, 18), items.ToString(), new GUIStyle(EditorStyles.whiteBoldLabel) { alignment = TextAnchor.MiddleCenter, normal = new GUIStyleState() { textColor = 0.85f.Grey() } }); if (togglable) { if ((bool)isOpen.value) { LudiqGUI.Inspector(_accessor, accessorRect, GUIContent.none); } Texture2D arrow = (bool)isOpen.value ? UAliveResources.arrowDownWhite : UAliveResources.arrowRightWhite; Graphics.DrawTexture(new Rect(container.x + container.width - 14, rootContainer.y + 6, 10, 10), arrow); return; } if (!isEditor) { LudiqGUI.Inspector(_accessor, accessorRect, GUIContent.none); } else { LudiqGUI.Editor(_accessor, accessorRect); } }); }); return(sectionRect); }