public void OnGUI(Rect position) { var y = position.y; EditorGUIUtility.hierarchyMode = true; // For the label width to be correct, like in the inspector if (context != null) { context.BeginEdit(); var selectionSize = context.selection.Count; if (selectionSize == 0) { var graphPanelPosition = position.VerticalSection(ref y, GetGraphPanelHeight(position.width)); LudiqGUI.Editor(context.graphMetadata, graphPanelPosition); } else if (selectionSize == 1) { var selectionPanelPosition = position.VerticalSection(ref y, GetSelectionPanelHeight(position.width)); LudiqGUI.Editor(context.selectionMetadata, selectionPanelPosition); } else if (selectionSize > 1) { var noMultiEditPosition = new Rect ( position.x, y, position.width, GetNoMultiEditHeight(position.width) ); EditorGUI.HelpBox(noMultiEditPosition, NoMultiEditMessage, MessageType.Info); } context.EndEdit(); } else { var noGraphSelectedPosition = new Rect ( position.x, y, position.width, GetNoGraphSelectedHeight(position.width) ); EditorGUI.HelpBox(noGraphSelectedPosition, NoGraphSelectedMessage, MessageType.Info); } }
protected override void OnInspectorGUI(Rect position) { LudiqGUI.Editor(nestMetadata, position); }
protected sealed override void OnGUIBlock(Rect position, GUIContent label) { var lastPosition = position; lastPosition.height = 90; lastPosition.width -= 15; lastPosition.x += 9; lastPosition.y += 2; if (accessor.Count == 0) { GUI.Box(new Rect(lastPosition.x, lastPosition.y, lastPosition.width + 6, 32), GUIContent.none); if (GUI.Button(new Rect(lastPosition.x + 5, lastPosition.y + 5, lastPosition.width - 5, 22), "+ Add Method")) { ((Methods)accessor.value).Add(null); } } for (int i = 0; i < accessor.Count; i++) { GUI.Box(lastPosition, GUIContent.none); LudiqGUI.Editor(accessor[i], new Rect(lastPosition.x + 12, lastPosition.y + 5, lastPosition.width - 50, lastPosition.height - 10)); GUI.Box(new Rect(lastPosition.x + lastPosition.width - 32, lastPosition.y, 38, lastPosition.height), GUIContent.none); if (GUI.Button(new Rect(lastPosition.x + lastPosition.width - 25, lastPosition.y + 5, 24, 18), new GUIContent(UAliveResources.removeBlack))) { var _dec = accessor[i].value as Method; ((List <Method>)accessor.value).Remove(_dec); AssetDatabase.RemoveObjectFromAsset(_dec); AssetDatabase.SaveAssets(); } EditorGUI.BeginDisabledGroup(i == 0); if (GUI.Button(new Rect(lastPosition.x + lastPosition.width - 25, lastPosition.y + (lastPosition.height / 2) - 16, 24, 18), new GUIContent(UAliveResources.arrowUpBlack))) { var list = ((List <Method>)accessor.value); var item = list[i]; list.Remove(item); list.Insert(i - 1, item); } EditorGUI.EndDisabledGroup(); EditorGUI.BeginDisabledGroup(i + 1 == accessor.Count); if (GUI.Button(new Rect(lastPosition.x + lastPosition.width - 25, lastPosition.y + (lastPosition.height / 2), 24, 18), new GUIContent(UAliveResources.arrowDownBlack))) { var list = ((List <Method>)accessor.value); var item = list[i]; list.Remove(item); list.Insert(i + 1, item); } EditorGUI.EndDisabledGroup(); if (GUI.Button(new Rect(lastPosition.x + lastPosition.width - 25, lastPosition.y + lastPosition.height - 22, 24, 18), new GUIContent(UAliveResources.addBlack))) { ((List <Method>)accessor.value).Insert(i + 1, null); } lastPosition.y += lastPosition.height; } }
protected virtual void OnNestGUI(Rect nestPosition) { LudiqGUI.Editor(nestMetadata, nestPosition); }
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); }