public static void Open() { EditorWindowView window = CreateInstance <EditorWindowView>(); window.position = new Rect(HUMEditor.ScreenCenter(new Vector2(400, 400)).position, new Vector2(400, 400)); window.showReferencePicker = true; window.titleContent = new GUIContent("Editor Window View"); window.Show(); }
public static EditorWindowView CreateWindow(EditorWindowAsset windowType, bool showReferencePicker = false) { EditorWindowView window = CreateInstance <EditorWindowView>(); window.position = new Rect(HUMEditor.ScreenCenter(new Vector2(400, 400)).position, new Vector2(400, 400)); window.asset = windowType; window.showReferencePicker = showReferencePicker; window.titleContent = new GUIContent("Editor Window View"); return(window); }
protected override void BeforePreview() { Target.itemsOpen = HUMEditor.Foldout(Target.itemsOpen, HUMEditorColor.DefaultEditorBackground.Darken(0.1f), Color.black, 2, () => { GUILayout.Label("Items"); }, () => { HUMEditor.Vertical().Box(HUMEditorColor.DefaultEditorBackground.Darken(0.1f), Color.black, new RectOffset(4, 4, 4, 4), new RectOffset(2, 2, 0, 2), () => { LudiqGUI.InspectorLayout(items, GUIContent.none); }); }); }
private void OnGUI() { for (int i = 0; i < this.tools.Count; i++) { var tool = this.tools[i]; if (tool != null) { tool.opened = HUMEditor.Foldout(tool.opened, new GUIContent(tool.DisplayName, tool.Icon()), Styles.backgroundColor, Styles.borderColor, 1, () => { HUMEditor.Vertical().Box(Styles.backgroundColor.Brighten(0.06f), Styles.borderColor, new RectOffset(6, 6, 6, 6), new RectOffset(1, 1, 0, 1), () => { tool.OnGUI(); }); }); } } }
public static void IconFoldout(ref bool isOpen, string label, Texture2D icon, Action content, int padding = 4) { isOpen = HUMEditor.Foldout(isOpen, new GUIContent(label, icon), Styles.backgroundColor.Brighten(0.05f), Color.black, 1, () => { HUMEditor.Vertical().Box(Styles.backgroundColor, Color.black, new RectOffset(padding, padding, padding, padding), new RectOffset(1, 1, 0, 1), () => { content?.Invoke(); }); }); }
protected override void OnTypeHeaderGUI() { HUMEditor.Horizontal(() => { HUMEditor.Vertical().Box(HUMEditorColor.DefaultEditorBackground, Color.black, new RectOffset(7, 7, 7, 7), new RectOffset(1, 1, 1, 1), () => { Target.icon = (Texture2D)EditorGUILayout.ObjectField(GUIContent.none, Target.icon, typeof(Texture2D), false, GUILayout.Width(32), GUILayout.Height(32)); }, false, false); GUILayout.Space(2); HUMEditor.Vertical(() => { base.OnTypeHeaderGUI(); }); }); }
private void OnGUI() { if (!positionSet) { mousePosition = Event.current.mousePosition.Add(new Vector2(10, 0)); minSize = new Vector2(140, 24); maxSize = new Vector2(140, 24); positionSet = true; } position = new Rect(mousePosition, new Vector2(100, 24)); HUMEditor.Horizontal(() => { GUILayout.Label("//", GUILayout.Width(12)); GUI.SetNextControlName("commentPopupField"); text = GUILayout.TextField(text); }); if (!focused) { EditorGUI.FocusTextInControl("commentPopupField"); focused = true; } if (Event.current.keyCode == KeyCode.Return && Event.current.rawType == EventType.KeyUp) { var canvas = GraphWindow.activeContext?.canvas as FlowCanvas; canvas?.AddUnit(new CommentNode() { comment = text, color = new Color(Random.Range(0.1f, 0.6f), Random.Range(0.1f, 0.6f), Random.Range(0.1f, 0.6f)) }, placement); Close(); } else { if (Event.current.keyCode == KeyCode.Escape && Event.current.rawType == EventType.KeyUp) { Close(); } } if (focusedWindow != this) { Close(); } }
public override void OnInspectorGUI() { HUMEditor.Changed(() => { base.OnInspectorGUI(); }, () => { refreshed = false; }); if (CSharpPreview.instance != null) { if (generator == null) { generator = EnumAssetGenerator.GetDecorator(target as EnumAsset) as ICodeGenerator; } CSharpPreview.instance.code = generator; if (!refreshed) { CSharpPreview.instance.Refresh(); refreshed = true; } } }
private void Variables() { Target.propertiesOpen = HUMEditor.Foldout(Target.propertiesOpen, HUMEditorColor.DefaultEditorBackground.Darken(0.1f), Color.black, 2, () => { HUMEditor.Image(PathUtil.Load("variables_16", CommunityEditorPath.Code).Single(), 16, 16, new RectOffset(), new RectOffset(4, 8, 4, 4)); GUILayout.Label("Variables"); }, () => { HUMEditor.Vertical().Box(HUMEditorColor.DefaultEditorBackground.Darken(0.1f), Color.black, new RectOffset(4, 4, 4, 4), new RectOffset(2, 2, 0, 2), () => { Inspector.BeginBlock(variables, new Rect()); LudiqGUI.InspectorLayout(variables, GUIContent.none); if (Inspector.EndBlock(variables)) { shouldUpdate = true; } }); }); }
protected virtual void OnTypeHeaderGUI() { if (showTitle) { HUMEditor.Horizontal().Box(HUMEditorColor.DefaultEditorBackground, Color.black, new RectOffset(0, 0, 0, 0), new RectOffset(1, 1, 1, 1), () => { EditorGUILayout.LabelField("Title", GUILayout.Width(80)); Target.title = EditorGUILayout.TextField(Target.title); }); } if (showCategory) { HUMEditor.Horizontal().Box(HUMEditorColor.DefaultEditorBackground, Color.black, new RectOffset(0, 0, 0, 0), new RectOffset(1, 1, 1, 1), () => { EditorGUILayout.LabelField("Category", GUILayout.Width(80)); Target.category = EditorGUILayout.TextField(Target.category); }); } }
private void Methods() { Target.methodsOpened = HUMEditor.Foldout(Target.methodsOpened, HUMEditorColor.DefaultEditorBackground.Darken(0.1f), Color.black, 2, () => { HUMEditor.Image(PathUtil.Load("method_16", CommunityEditorPath.Code).Single(), 16, 16, new RectOffset(), new RectOffset(4, 8, 4, 4)); GUILayout.Label("Methods"); }, () => { HUMEditor.Vertical().Box(HUMEditorColor.DefaultEditorBackground.Darken(0.1f), Color.black, new RectOffset(4, 4, 4, 4), new RectOffset(2, 2, 0, 2), () => { var listOfMethods = methods.value as List <TMethodDeclaration>; for (int i = 0; i < listOfMethods.Count; i++) { var index = i; listOfMethods[index].opened = HUMEditor.Foldout(listOfMethods[index].opened, HUMEditorColor.DefaultEditorBackground.Darken(0.15f), Color.black, 1, () => { HUMEditor.Changed(() => { listOfMethods[index].methodName = GUILayout.TextField(listOfMethods[index].methodName); }, () => { listOfMethods[index].name = listOfMethods[index].methodName.LegalMemberName(); var funcionUnit = (listOfMethods[index].graph.units[0] as FunctionNode); funcionUnit.Define(); funcionUnit.Describe(); }); if (GUILayout.Button("Edit", GUILayout.Width(60))) { GraphWindow.OpenActive(listOfMethods[index].GetReference() as GraphReference); } if (GUILayout.Button("...", GUILayout.Width(19))) { GenericMenu menu = new GenericMenu(); menu.AddItem(new GUIContent("Delete"), false, (obj) => { methods.Remove(obj as TMethodDeclaration); AssetDatabase.RemoveObjectFromAsset(obj as TMethodDeclaration); }, listOfMethods[index]); if (index > 0) { menu.AddItem(new GUIContent("Move Up"), false, (obj) => { // To Do }, listOfMethods[index]); } if (index < methods.Count - 1) { menu.AddItem(new GUIContent("Move Down"), false, (obj) => { // To Do }, listOfMethods[index]); } menu.ShowAsContext(); } }, () => { HUMEditor.Vertical().Box(HUMColor.Grey(0.15f), Color.black, new RectOffset(6, 6, 6, 6), new RectOffset(1, 1, 0, 1), () => { listOfMethods[index].scope = (AccessModifier)EditorGUILayout.EnumPopup("Scope", listOfMethods[index].scope); listOfMethods[index].modifier = (MethodModifier)EditorGUILayout.EnumPopup("Modifier", listOfMethods[index].modifier); Inspector.BeginBlock(methods[index]["returnType"], new Rect()); LudiqGUI.InspectorLayout(methods[index]["returnType"], new GUIContent("Returns")); if (Inspector.EndBlock(methods[index]["returnType"])) { shouldUpdate = true; } GUILayout.Space(4); listOfMethods[index].parametersOpened = HUMEditor.Foldout(listOfMethods[index].parametersOpened, HUMEditorColor.DefaultEditorBackground.Darken(0.15f), Color.black, 1, () => { GUILayout.Label("Parameters"); }, () => { var paramMeta = methods[index]["parameters"]; Inspector.BeginBlock(paramMeta, new Rect()); LudiqGUI.InspectorLayout(paramMeta, GUIContent.none); if (Inspector.EndBlock(paramMeta)) { shouldUpdate = true; var funcionUnit = (listOfMethods[index].graph.units[0] as FunctionNode); funcionUnit.Define(); funcionUnit.Describe(); } }); }, true, false); }); GUILayout.Space(4); } if (GUILayout.Button("+ Add Method")) { var declaration = CreateInstance <TMethodDeclaration>(); if (Target.GetType() == typeof(ClassAsset)) { declaration.classAsset = Target as ClassAsset; } if (Target.GetType() == typeof(StructAsset)) { declaration.structAsset = Target as StructAsset; } declaration.hideFlags = HideFlags.HideInHierarchy; AssetDatabase.AddObjectToAsset(declaration, Target); listOfMethods.Add(declaration); var functionUnit = new FunctionNode(FunctionType.Method); functionUnit.methodDeclaration = declaration; declaration.graph.units.Add(functionUnit); AssetDatabase.SaveAssets(); AssetDatabase.Refresh(); } if (methods.Count != methodsCount) { if (Target is ClassAsset) { for (int i = 0; i < methods.Count; i++) { ((TMethodDeclaration)methods[i].value).classAsset = Target as ClassAsset; } } else { if (Target is StructAsset) { for (int i = 0; i < methods.Count; i++) { ((TMethodDeclaration)methods[i].value).structAsset = Target as StructAsset; } } } methodsCount = methods.Count; } }); }); }
private void Variables() { Target.fieldsOpened = HUMEditor.Foldout(Target.fieldsOpened, HUMEditorColor.DefaultEditorBackground.Darken(0.1f), Color.black, 2, () => { HUMEditor.Image(PathUtil.Load("variables_16", CommunityEditorPath.Code).Single(), 16, 16, new RectOffset(), new RectOffset(4, 8, 4, 4)); GUILayout.Label("Variables"); }, () => { HUMEditor.Vertical().Box(HUMEditorColor.DefaultEditorBackground.Darken(0.1f), Color.black, new RectOffset(4, 4, 4, 4), new RectOffset(2, 2, 0, 2), () => { var listOfVariables = variables.value as List <TFieldDeclaration>; for (int i = 0; i < listOfVariables.Count; i++) { var index = i; listOfVariables[index].opened = HUMEditor.Foldout(listOfVariables[index].opened, HUMEditorColor.DefaultEditorBackground.Darken(0.15f), Color.black, 1, () => { HUMEditor.Changed(() => { listOfVariables[index].name = GUILayout.TextField(listOfVariables[index].name); }, () => { listOfVariables[index].name = listOfVariables[index].name.LegalMemberName(); var getterFunctionUnit = (listOfVariables[index].getter.graph.units[0] as FunctionNode); var setterFunctionUnit = (listOfVariables[index].setter.graph.units[0] as FunctionNode); listOfVariables[index].getter.name = listOfVariables[index].name + " Getter"; listOfVariables[index].setter.name = listOfVariables[index].name + " Setter"; getterFunctionUnit.Define(); getterFunctionUnit.Describe(); setterFunctionUnit.Define(); setterFunctionUnit.Describe(); }); if (GUILayout.Button("...", GUILayout.Width(19))) { GenericMenu menu = new GenericMenu(); menu.AddItem(new GUIContent("Delete"), false, (obj) => { variables.Remove(obj as TFieldDeclaration); }, listOfVariables[index]); if (index > 0) { menu.AddItem(new GUIContent("Move Up"), false, (obj) => { // To Do }, listOfVariables[index]); } if (index < methods.Count - 1) { menu.AddItem(new GUIContent("Move Down"), false, (obj) => { // To Do }, listOfVariables[index]); } menu.ShowAsContext(); } }, () => { HUMEditor.Vertical().Box(HUMColor.Grey(0.15f), Color.black, new RectOffset(6, 6, 6, 6), new RectOffset(1, 1, 0, 1), () => { listOfVariables[index].scope = (AccessModifier)EditorGUILayout.EnumPopup("Scope", listOfVariables[index].scope); Inspector.BeginBlock(variables[index]["type"], new Rect()); LudiqGUI.InspectorLayout(variables[index]["type"], new GUIContent("Type")); if (Inspector.EndBlock(variables[index]["type"])) { shouldUpdate = true; } GUILayout.Space(4); listOfVariables[index].attributesOpened = HUMEditor.Foldout(listOfVariables[index].attributesOpened, HUMEditorColor.DefaultEditorBackground.Darken(0.15f), Color.black, 1, () => { HUMEditor.Image(PathUtil.Load("attributes_16", CommunityEditorPath.Code).Single(), 16, 16); GUILayout.Label("Attributes"); }, () => { HUMEditor.Vertical().Box(HUMEditorColor.DefaultEditorBackground, Color.black, new RectOffset(4, 4, 4, 4), new RectOffset(1, 1, 0, 1), () => { for (int attrIndex = 0; attrIndex < listOfVariables[index].attributes.Count; attrIndex++) { var attributeMeta = variables[index]["attributes"][attrIndex]["attributeType"]; var attribute = listOfVariables[index].attributes[attrIndex]; attribute.opened = HUMEditor.Foldout(attribute.opened, HUMEditorColor.DefaultEditorBackground.Darken(0.15f), Color.black, 1, () => { attributeMeta.Block(() => { AttributeTypeField(attribute, AttributeUsageType.Field); }, () => { shouldUpdate = true; }, false); if (GUILayout.Button("...", GUILayout.Width(19))) { GenericMenu menu = new GenericMenu(); menu.AddItem(new GUIContent("Delete"), false, (obj) => { listOfVariables[index].attributes.Remove(obj as AttributeDeclaration); }, attribute); //if (index > 0) //{ // menu.AddItem(new GUIContent("Move Up"), false, (obj) => // { // // To Do // }, listOfConstructors[index]); //} //if (index < methods.Count - 1) //{ // menu.AddItem(new GUIContent("Move Down"), false, (obj) => // { // // To Do // }, listOfConstructors[index]); //} menu.ShowAsContext(); } }, () => { var parameters = attribute.parameters; for (int attrParamIndex = 0; attrParamIndex < parameters.Count; attrParamIndex++) { } }); } if (listOfVariables[index].attributes.Count > 0) { GUILayout.Space(4); } if (GUILayout.Button("+ Add Attributes")) { listOfVariables[index].attributes.Add(new AttributeDeclaration()); } }); }); GUILayout.Space(4); listOfVariables[index].propertyOpened = HUMEditor.Foldout(listOfVariables[index].propertyOpened, HUMEditorColor.DefaultEditorBackground.Darken(0.15f), Color.black, 1, () => { listOfVariables[index].isProperty = EditorGUILayout.ToggleLeft("Property", listOfVariables[index].isProperty); }, () => { HUMEditor.Disabled(!listOfVariables[index].isProperty, () => { HUMEditor.Vertical().Box(HUMEditorColor.DefaultEditorBackground, Color.black, new RectOffset(4, 4, 4, 4), new RectOffset(1, 1, 0, 1), () => { HUMEditor.Horizontal(() => { HUMEditor.Changed(() => { listOfVariables[index].get = EditorGUILayout.ToggleLeft("Get", listOfVariables[index].get); }, () => { if (!listOfVariables[index].set) { listOfVariables[index].get = true; } }); HUMEditor.Disabled(!listOfVariables[index].get, () => { if (GUILayout.Button("Edit", GUILayout.Width(60))) { GraphWindow.OpenActive(listOfVariables[index].getter.GetReference() as GraphReference); } }); }); HUMEditor.Horizontal(() => { HUMEditor.Changed(() => { listOfVariables[index].set = EditorGUILayout.ToggleLeft("Set", listOfVariables[index].set); }, () => { if (!listOfVariables[index].set) { listOfVariables[index].get = true; } }); HUMEditor.Disabled(!listOfVariables[index].set, () => { if (GUILayout.Button("Edit", GUILayout.Width(60))) { GraphWindow.OpenActive(listOfVariables[index].setter.GetReference() as GraphReference); } }); }); }, true, false); }); }); }, true, false); }); GUILayout.Space(4); } if (GUILayout.Button("+ Add Variable")) { var declaration = CreateInstance <TFieldDeclaration>(); if (Target.GetType() == typeof(ClassAsset)) { declaration.classAsset = Target as ClassAsset; } if (Target.GetType() == typeof(StructAsset)) { declaration.structAsset = Target as StructAsset; } var getter = CreateInstance <PropertyGetterMacro>(); var setter = CreateInstance <PropertySetterMacro>(); AssetDatabase.AddObjectToAsset(declaration, Target); AssetDatabase.AddObjectToAsset(getter, Target); AssetDatabase.AddObjectToAsset(setter, Target); listOfVariables.Add(declaration); var functionGetterUnit = new FunctionNode(FunctionType.Getter); var functionSetterUnit = new FunctionNode(FunctionType.Setter); functionGetterUnit.fieldDeclaration = declaration; functionSetterUnit.fieldDeclaration = declaration; declaration.getter = getter; declaration.setter = setter; declaration.getter.graph.units.Add(functionGetterUnit); declaration.setter.graph.units.Add(functionSetterUnit); declaration.hideFlags = HideFlags.HideInHierarchy; getter.hideFlags = HideFlags.HideInHierarchy; setter.hideFlags = HideFlags.HideInHierarchy; AssetDatabase.SaveAssets(); AssetDatabase.Refresh(); } }); }); }
private void OnGUI() { view?.Update(); if (!cached) { if (!isInstance && !isDefinition) { isInstance = true; } cached = true; } if (!locked && (!focused && FuzzyWindow.instance == null || !focused && focusedWindow != FuzzyWindow.instance)) { Close(); } HUMEditor.Draw(new Rect(new Vector2(0, 0), position.size)).Box(HUMEditorColor.DefaultEditorBackground, Color.black, BorderDrawPlacement.Inside, 1); HUMEditor.Horizontal(() => { var instance = isInstance; isInstance = EditorGUILayout.Toggle(isInstance, new GUIStyle(GUI.skin.button), GUILayout.Height(24)); var lastRect = GUILayoutUtility.GetLastRect(); GUI.Label(lastRect, new GUIContent("Instance"), new GUIStyle(GUI.skin.label) { alignment = TextAnchor.MiddleCenter }); if (isInstance != instance) { isDefinition = false; } var definition = isDefinition; isDefinition = EditorGUILayout.Toggle(isDefinition, new GUIStyle(GUI.skin.button), GUILayout.Height(24)); lastRect = GUILayoutUtility.GetLastRect(); GUI.Label(lastRect, new GUIContent("Definition"), new GUIStyle(GUI.skin.label) { alignment = TextAnchor.MiddleCenter }); if (isDefinition != definition) { isInstance = false; } locked = EditorGUILayout.Toggle(locked, new GUIStyle(GUI.skin.button), GUILayout.Width(48), GUILayout.Height(24)); lastRect = GUILayoutUtility.GetLastRect(); GUI.Label(lastRect, new GUIContent("Locked"), new GUIStyle(GUI.skin.label) { alignment = TextAnchor.MiddleCenter }); }); scrollPosition = HUMEditor.Draw().ScrollView(scrollPosition, () => { if (isInstance) { LudiqGUI.InspectorLayout(windowVariablesMetadata); } if (isDefinition) { LudiqGUI.InspectorLayout(variablesMetadata); } }); view?.ApplyModifiedProperties(); if (locked) { Repaint(); } }
public override void OnInspectorGUI() { serializedObject.Update(); CSharpPreviewWindow.instance?.preview.Refresh(); HUMEditor.Vertical(() => { HUMEditor.Changed(() => { HUMEditor.Vertical().Box(HUMEditorColor.DefaultEditorBackground.Darken(0.1f), Color.black, new RectOffset(4, 4, 4, 4), new RectOffset(2, 2, 2, 2), () => { OnTypeHeaderGUI(); AfterCategoryGUI(); }); EditorGUILayout.Space(4); if (warningPresent) { EditorGUILayout.HelpBox("Code Assets are an in preview feature. " + "Not all functionality is present, and not all nodes have working generators. " + "There is no guarentee assets will remain in tact. " + "You may move the output scipts somewhere else for safe keeping.", MessageType.Warning); EditorGUILayout.Space(4); if (GUILayout.Button("Understood. Hide this warning.")) { EditorPrefs.SetBool("Bolt.Addons.Community.Code.Warning_Present", false); warningPresent = false; } } EditorGUILayout.Space(4); if (showOptions) { Target.optionsOpened = HUMEditor.Foldout(Target.optionsOpened, HUMEditorColor.DefaultEditorBackground.Darken(0.1f), Color.black, 2, () => { GUILayout.Label("Options"); }, () => { HUMEditor.Vertical().Box(HUMEditorColor.DefaultEditorBackground.Darken(0.1f), Color.black, new RectOffset(4, 4, 4, 4), new RectOffset(2, 2, 0, 2), () => { OptionsGUI(); }); }); EditorGUILayout.Space(4); } BeforePreview(); EditorGUILayout.Space(4); }, () => { shouldUpdate = true; }); }); if (CSharpPreviewWindow.instance != null) { if (shouldUpdate) { CSharpPreviewWindow.instance.preview.code = CodeGenerator.GetSingleDecorator <TAssetGenerator>(Target); CSharpPreviewWindow.instance.preview.Refresh(); } } shouldUpdate = false; EditorUtility.SetDirty(Target); serializedObject.ApplyModifiedProperties(); }
private void Methods() { Target.methodsOpen = HUMEditor.Foldout(Target.methodsOpen, HUMEditorColor.DefaultEditorBackground.Darken(0.1f), Color.black, 2, () => { HUMEditor.Image(PathUtil.Load("method_16", CommunityEditorPath.Code).Single(), 16, 16, new RectOffset(), new RectOffset(4, 8, 4, 4)); GUILayout.Label("Methods"); }, () => { HUMEditor.Vertical().Box(HUMEditorColor.DefaultEditorBackground.Darken(0.1f), Color.black, new RectOffset(4, 4, 4, 4), new RectOffset(2, 2, 0, 2), () => { var listOfMethods = methods.value as List <InterfaceMethodItem>; for (int i = 0; i < listOfMethods.Count; i++) { var index = i; listOfMethods[index].opened = HUMEditor.Foldout(listOfMethods[index].opened, HUMEditorColor.DefaultEditorBackground.Darken(0.15f), Color.black, 1, () => { HUMEditor.Changed(() => { listOfMethods[index].name = GUILayout.TextField(listOfMethods[index].name); }, () => { listOfMethods[index].name = listOfMethods[index].name.LegalMemberName(); shouldUpdate = true; }); if (GUILayout.Button("...", GUILayout.Width(19))) { GenericMenu menu = new GenericMenu(); menu.AddItem(new GUIContent("Delete"), false, (obj) => { methods.Remove(obj as InterfaceMethodItem); shouldUpdate = true; }, listOfMethods[index]); if (index > 0) { menu.AddItem(new GUIContent("Move Up"), false, (obj) => { // To Do }, listOfMethods[index]); } if (index < methods.Count - 1) { menu.AddItem(new GUIContent("Move Down"), false, (obj) => { // To Do }, listOfMethods[index]); } menu.ShowAsContext(); } }, () => { HUMEditor.Vertical().Box(HUMColor.Grey(0.15f), Color.black, new RectOffset(6, 6, 6, 6), new RectOffset(1, 1, 0, 1), () => { Inspector.BeginBlock(methods[index]["returnType"], new Rect()); LudiqGUI.InspectorLayout(methods[index]["returnType"], new GUIContent("Returns")); if (Inspector.EndBlock(methods[index]["returnType"])) { shouldUpdate = true; } GUILayout.Space(4); listOfMethods[index].parametersOpened = HUMEditor.Foldout(listOfMethods[index].parametersOpened, HUMEditorColor.DefaultEditorBackground.Darken(0.15f), Color.black, 1, () => { GUILayout.Label("Parameters"); }, () => { var paramMeta = methods[index]["parameters"]; Inspector.BeginBlock(paramMeta, new Rect()); LudiqGUI.InspectorLayout(paramMeta, GUIContent.none); if (Inspector.EndBlock(paramMeta)) { shouldUpdate = true; } }); }, true, false); }); GUILayout.Space(4); } if (GUILayout.Button("+ Add Methods")) { listOfMethods.Add(new InterfaceMethodItem()); } }); }); }
protected override void AfterCategoryGUI() { GUILayout.Label(" ", new GUIStyle(GUI.skin.label) { stretchWidth = true }); var lastRect = GUILayoutUtility.GetLastRect(); HUMEditor.Vertical().Box(HUMEditorColor.DefaultEditorBackground.Darken(0.1f), Color.black, new RectOffset(4, 4, 4, 4), new RectOffset(1, 1, 1, 1), () => { var isGeneric = ((Type)type.value).IsGenericType; HUMEditor.Horizontal(() => { GUILayout.Label("Delegate", GUILayout.Width(80)); if (GUILayout.Button(((Type)type.value)?.As().CSharpName(false).RemoveHighlights().RemoveMarkdown())) { LudiqGUI.FuzzyDropdown(lastRect, new TypeOptionTree(delegateTypes), type.value, (val) => { generics.value = new List <GenericDeclaration>(); if (type.value != val) { type.value = val; Type[] constraints = null; var _type = ((Type)type.value); if (((Type)type.value).IsGenericTypeDefinition) { var generic = ((Type)type.value)?.GetGenericTypeDefinition(); var _generics = generic?.GetGenericArguments(); if (_type.IsGenericParameter) { constraints = ((Type)type.value).GetGenericParameterConstraints(); } for (int i = 0; i < _generics.Length; i++) { var declaration = new GenericDeclaration(); declaration.name = _generics[i].Name; if (_type.IsGenericParameter) { declaration.constraint.type = constraints[i]; } ((List <GenericDeclaration>)generics.value).Add(declaration); } } } }); } }); HUMEditor.Vertical(() => { if (isGeneric) { var gen = ((List <GenericDeclaration>)generics.value); for (int i = 0; i < gen.Count; i++) { var index = i; HUMEditor.Horizontal(() => { GUILayout.Label(string.IsNullOrEmpty(gen[index].name) ? "T" + index.ToString() : gen[index].name); if (GUILayout.Button(gen[index].type.type?.As().CSharpName(false).RemoveHighlights().RemoveMarkdown())) { LudiqGUI.FuzzyDropdown(lastRect, new TypeOptionTree(types.Where((t) => { return(t.Inherits(gen[index].constraint.type)); })), type.value, (val) => { gen[index].type.type = (Type)val; }); } }); } } }); }); }