protected override void OnGUI(Rect position, GUIContent label) { try { BeginBlock(metadata, position, GUIContent.none); HUMEditor.Vertical().Box(backgroundColor.Brighten(0.05f), Color.black, new RectOffset(4, 4, 4, 4), new RectOffset(1, 1, 1, 1), () => { _target.title = EditorGUILayout.TextField(new GUIContent("Enum Name"), _target.title); _target.@namespace = EditorGUILayout.TextField(new GUIContent("Namespace"), _target.@namespace); }); GUILayout.Space(10); LudiqGUI.InspectorLayout(metadata["items"], GUIContent.none); if (EndBlock(metadata)) { metadata.RecordUndo(); } } catch (System.Exception e) { Debug.Log(e); } }
protected override void OnGUI(Rect position, GUIContent label) { base.OnGUI(position, label); GUILayout.Space(4); LudiqGUI.InspectorLayout(metadata["variables"]); }
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 Declaration(Rect position) { HUMEditor.Vertical().Box(Styles.backgroundColor.Brighten(0.05f), Color.black, new RectOffset(4, 4, 4, 4), new RectOffset(1, 1, 1, 1), () => { HUMEditor.Horizontal().Box(Styles.backgroundColor.Brighten(0.05f), Color.black, new RectOffset(4, 4, 4, 4), new RectOffset(1, 1, 1, 1), () => { HUMEditor.Horizontal(() => { EditorGUI.BeginChangeCheck(); if (_target.editorData.icon == null) { _target.editorData.icon = Images.class_32; } _target.editorData.icon = (Texture2D)EditorGUILayout.ObjectField(GUIContent.none, _target.editorData.icon, typeof(Texture2D), false, GUILayout.Width(40), GUILayout.Height(40)); if (EditorGUI.EndChangeCheck()) { DescribeActiveUnits(); var definer = _target.Definer() as ClassDefiner; definer.Define(); } }); HUMEditor.Horizontal(() => { HUMEditor.Vertical(() => { GUILayout.Label("Name"); GUILayout.Label("Namespace"); }); HUMEditor.Vertical(() => { EditorGUI.BeginChangeCheck(); _target.title = EditorGUILayout.TextField(GUIContent.none, _target.title, GUILayout.MinWidth(100)); if (EditorGUI.EndChangeCheck()) { DescribeActiveUnits(); var definer = _target.Definer() as ClassDefiner; definer.Define(); } _target.@namespace = EditorGUILayout.TextField(GUIContent.none, _target.@namespace, GUILayout.MinWidth(100)); }); }); }); EditorGUILayout.Space(6); BeginBlock(metadata, position, GUIContent.none); LudiqGUI.InspectorLayout(metadata["inheritance"]["type"]); if (EndBlock(metadata)) { var definer = _target.Definer() as ClassDefiner; definer.Define(); } }); }
private void Declaration(Rect position) { HUMEditor.Vertical().Box(Styles.backgroundColor.Brighten(0.05f), Color.black, new RectOffset(4, 4, 4, 4), new RectOffset(1, 1, 1, 1), () => { _target.title = EditorGUILayout.TextField(new GUIContent("Class Name"), _target.title); _target.@namespace = EditorGUILayout.TextField(new GUIContent("Namespace"), _target.@namespace); BeginBlock(metadata, position, GUIContent.none); LudiqGUI.InspectorLayout(metadata["inheritance"]["type"]); if (EndBlock(metadata)) { _target.Define(); } }); }
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 override void OnGUI(Rect position, GUIContent label) { BeginBlock(metadata, position, GUIContent.none); HUMEditor.Vertical().Box(backgroundColor.Brighten(0.05f), Color.black, new RectOffset(4, 4, 4, 4), new RectOffset(1, 1, 1, 1), () => { _target.title = EditorGUILayout.TextField(new GUIContent("Interface Name"), _target.title); _target.@namespace = EditorGUILayout.TextField(new GUIContent("Namespace"), _target.@namespace); }); GUILayout.Space(10); _target.propertiesOpen = HUMEditor.Foldout(_target.propertiesOpen, new GUIContent("Properties", Images.property_16), backgroundColor.Brighten(0.05f), Color.black, 1, () => { LudiqGUI.InspectorLayout(metadata["properties"], GUIContent.none); }); GUILayout.Space(10); _target.methodsOpen = HUMEditor.Foldout(_target.methodsOpen, new GUIContent("Methods", Images.flow_icon_16), backgroundColor.Brighten(0.05f), Color.black, 1, () => { LudiqGUI.InspectorLayout(metadata["methods"], GUIContent.none); }); if (EndBlock(metadata)) { metadata.RecordUndo(); } }
private void Variables(Rect position) { UAGUI.IconFoldout(ref _target.editorData.customVariablesOpen, "Variables", Images.variables_16, () => { HUMEditor.Vertical().Box(Styles.backgroundColor.Brighten(0.025f), Styles.borderColor, new RectOffset(4, 4, 4, 2), new RectOffset(1, 1, 0, 1), () => { var variables = metadata["variables"]; var variablesVal = (Variables)metadata["variables"].value; for (int i = 0; i < variablesVal.variables.Count; i++) { if (i != 0) { GUILayout.Space(2); } HUMEditor.Vertical().Box(Styles.backgroundColor.Brighten(0.075f), Styles.borderColor, new RectOffset(4, 4, 4, 2), new RectOffset(1, 1, 1, 1), () => { var variable = variables["variables"][i]; var variableVal = (Variable)variable.value; HUMEditor.Vertical(() => { HUMEditor.Horizontal(() => { BeginBlock(metadata["name"], position); HUMEditor.Vertical(() => { LudiqGUI.InspectorLayout(variable["name"], GUIContent.none); }); if (EndBlock(metadata["name"])) { variableVal.declaration.Changed(); } GUILayout.Label(GUIContent.none, new GUIStyle() { fixedWidth = 4 }); HUMEditor.Vertical(() => { LudiqGUI.InspectorLayout(variable["declaration"]["type"], GUIContent.none); }); if (GUILayout.Button("-", GUILayout.Width(16), GUILayout.Height(14))) { variablesVal.variables.Remove(variableVal); variableVal.declaration.Changed(); AssetDatabase.RemoveObjectFromAsset(variableVal.getter); AssetDatabase.RemoveObjectFromAsset(variableVal.setter); AssetDatabase.RemoveObjectFromAsset(variableVal); AssetDatabase.SaveAssets(); AssetDatabase.Refresh(); var definer = _target.Definer() as ClassDefiner; definer.Define(); } }); GUILayout.Space(2); HUMEditor.Vertical(() => { LudiqGUI.InspectorLayout(variable["declaration"]["defaultValue"].Cast(variableVal.declaration.type), GUIContent.none); }); }); GUILayout.Space(2); }); } if (GUILayout.Button("+ New Variable")) { var variable = Variable.Create(_target); AssetDatabase.AddObjectToAsset(variable, _target); variablesVal.variables.Add(variable); var definer = _target.Definer() as ClassDefiner; definer.Define(); } }); }); }
private void Methods(Rect position) { UAGUI.IconFoldout(ref _target.editorData.customMethodsOpen, "Methods", Images.flow_icon_16, () => { HUMEditor.Vertical().Box(Styles.backgroundColor.Brighten(0.025f), Styles.borderColor, new RectOffset(4, 4, 4, 2), new RectOffset(1, 1, 0, 1), () => { var methods = metadata["methods"]["custom"]; var methodsVal = (List <Method>)metadata["methods"]["custom"].value; for (int i = 0; i < methodsVal.Count; i++) { if (i != 0) { GUILayout.Space(2); } var meth = methodsVal[i]; methodsVal[i].isOpen = HUMEditor.Foldout(methodsVal[i].isOpen, Styles.backgroundColor.Brighten(0.05f), Styles.borderColor, 1, () => { BeginBlock(metadata["name"], position); meth.name = GUILayout.TextField(meth.name); meth.entry.declaration.name = meth.name; if (EndBlock(metadata["name"])) { meth.entry.declaration.Changed(); } if (GUILayout.Button("Edit", GUILayout.Width(42))) { GraphWindow.OpenActive(GraphReference.New(methodsVal[i], true)); } if (GUILayout.Button("-", GUILayout.Width(16), GUILayout.Height(18))) { methodsVal.Remove(meth); meth.entry.Define(); AssetDatabase.RemoveObjectFromAsset(meth); AssetDatabase.SaveAssets(); AssetDatabase.Refresh(); var definer = _target.Definer() as ClassDefiner; definer.Define(); } }, () => { HUMEditor.Vertical(() => { BeginBlock(methods[i], position, GUIContent.none); HUMEditor.Horizontal(() => { HUMEditor.Vertical().Box(HUMEditorColor.DefaultEditorBackground.Darken(0.025f), Styles.borderColor, new RectOffset(8, 8, 8, 8), new RectOffset(1, 1, 0, 1), () => { LudiqGUI.InspectorLayout(methods[i]["entry"]["declaration"]["type"], new GUIContent("Returns")); if ((Type)methods[i]["entry"]["declaration"]["type"].value == typeof(Lasm.UAlive.Void)) { GUILayout.Space(6); } else { LudiqGUI.InspectorLayout(methods[i]["entry"]["declaration"]["pure"], new GUIContent("Pure")); } UAGUI.IconFoldout(ref methodsVal[i].entry.declaration.parametersOpen, "Parameters", Images.parameters_16, () => { LudiqGUI.InspectorLayout(methods[i]["entry"]["declaration"]["parameters"], GUIContent.none); }, Styles.backgroundColor.Brighten(0.05f), 0); }); }); if (EndBlock(methods[i])) { meth.entry.Define(); } }); }); } if (GUILayout.Button("+ New Method")) { var meth = Method.Create(_target); methodsVal.Add(meth); AssetDatabase.SaveAssets(); AssetDatabase.Refresh(); var definer = _target.Definer() as ClassDefiner; definer.Define(); } }); }); }
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(); } }
private void OnGUI() { EditorGUI.BeginDisabledGroup(EditorApplication.isCompiling); scroll = GUILayout.BeginScrollView(scroll); LudiqGUI.BeginHorizontal(); LudiqGUI.BeginVertical(); foreach (var configuration in configurations) { if (configuration.Any(i => i.visible)) { if (configurations.Count > 1) { Header(configuration.header.Replace(label + " ", "")); } EditorGUI.BeginChangeCheck(); using (Inspector.expandTooltip.Override(true)) { foreach (var item in configuration.Where(i => i.visible)) { LudiqGUI.Space(2); LudiqGUI.BeginHorizontal(); LudiqGUI.Space(4); var iconPosition = GUILayoutUtility.GetRect(GUIContent.none, GUIStyle.none, GUILayout.Width(Styles.iconSize), GUILayout.Height(Styles.iconSize), GUILayout.ExpandHeight(false), GUILayout.ExpandWidth(false)); EditorTexture icon = null; string tooltip = null; if (item is ProjectSettingMetadata) { icon = BoltCore.Icons.projectSetting; tooltip = "Project Setting: Shared across users, local to this project. Included in version control."; } else if (item is EditorPrefMetadata) { icon = BoltCore.Icons.editorPref; tooltip = "Editor Pref: Local to this user, shared across projects. Excluded from version control."; } if (icon != null) { using (LudiqGUI.color.Override(GUI.color.WithAlpha(0.6f))) { GUI.Label(iconPosition, new GUIContent(icon[Styles.iconSize], tooltip), GUIStyle.none); } } LudiqGUI.Space(6); LudiqGUI.BeginVertical(); LudiqGUI.Space(-3); LudiqGUI.InspectorLayout(item); LudiqGUI.EndVertical(); LudiqGUI.EndHorizontal(); } } if (EditorGUI.EndChangeCheck()) { configuration.Save(); InternalEditorUtility.RepaintAllViews(); } } } LudiqGUI.Space(8); if (GUILayout.Button("Reset to Defaults")) { if (EditorUtility.DisplayDialog("Reset to Defaults", "Are you sure you want to reset your preferences and project settings to default?", "Reset")) { foreach (var configuration in configurations) { configuration.Reset(); configuration.Save(); } InternalEditorUtility.RepaintAllViews(); } } LudiqGUI.Space(8); LudiqGUI.EndVertical(); LudiqGUI.Space(8); LudiqGUI.EndHorizontal(); GUILayout.EndScrollView(); EditorGUI.EndDisabledGroup(); }
private void Overrides(Rect position) { _target.overridesOpen = HUMEditor.Foldout(_target.overridesOpen, new GUIContent("Overrides", Images.override_16), Styles.backgroundColor.Brighten(0.05f), Color.black, 1, () => { HUMEditor.Vertical().Box(Styles.backgroundColor, Color.black, new RectOffset(4, 4, 4, 4), new RectOffset(1, 1, 0, 1), () => { _target.methodOverridesOpen = HUMEditor.Foldout(_target.methodOverridesOpen, new GUIContent("Methods", Images.flow_icon_16), Styles.backgroundColor.Brighten(0.05f), Styles.borderColor, 1, () => { HUMEditor.Vertical().Box(Styles.backgroundColor.Brighten(0.025f), Styles.borderColor, new RectOffset(4, 4, 4, 2), new RectOffset(1, 1, 0, 1), () => { var overrides = metadata["methods"]["overrides"]; tempOverrides.Clear(); for (int i = 0; i < overrides.Count; i++) { var nest = ((Method)overrides.ValueMetadata(i).value); if (!nest.isSpecial || (nest.isSpecial && nest.isOverridden)) { var _name = nest.name; if (position.width - 170 < GUI.skin.label.CalcSize(new GUIContent(_name)).x) { if (_name.Length > 11) { _name = _name.Remove(11, _name.Length - 11) + ".."; } } LudiqGUI.InspectorLayout(overrides.ValueMetadata(i), new GUIContent(_name)); } else { var temp = ((KeyValuePair <string, Method>)overrides[i].value); tempOverrides.Add(temp.Key, temp.Value); } } GUILayout.Space(6); BeginBlock(metadata, position, GUIContent.none); if (GUILayout.Button("+ Message")) { GenericMenu menu = new GenericMenu(); var keys = tempOverrides.KeysToList(); var startSeparator = false; for (int i = 0; i < keys.Count; i++) { if (startSeparator) { menu.AddSeparator(""); startSeparator = false; } var key = keys[i]; menu.AddItem(new GUIContent(key), false, (obj) => { tempOverrides[(string)obj].isOverridden = true; }, key); if (keys[i] == "OnGUI") { startSeparator = true; } } menu.ShowAsContext(); } if (EndBlock(metadata)) { _target.Define(); } }); }); }); }); }
private void Variables(Rect position) { _target.customVariablesOpen = HUMEditor.Foldout(_target.customVariablesOpen, new GUIContent("Variables", Images.variables_16), Styles.backgroundColor.Brighten(0.05f), Styles.borderColor, 1, () => { HUMEditor.Vertical().Box(Styles.backgroundColor.Brighten(0.025f), Styles.borderColor, new RectOffset(4, 4, 4, 2), new RectOffset(1, 1, 0, 1), () => { var variables = metadata["variables"]; var variablesVal = (Variables)metadata["variables"].value; for (int i = 0; i < variablesVal.variables.Count; i++) { if (i != 0) { GUILayout.Space(2); } HUMEditor.Vertical().Box(Styles.backgroundColor.Brighten(0.075f), Styles.borderColor, new RectOffset(4, 4, 4, 2), new RectOffset(1, 1, 1, 1), () => { var variable = variables["variables"][i]; var variableVal = (Variable)variable.value; HUMEditor.Vertical(() => { HUMEditor.Horizontal(() => { HUMEditor.Vertical(() => { LudiqGUI.InspectorLayout(variable["name"], GUIContent.none); }); GUILayout.Label(GUIContent.none, new GUIStyle() { fixedWidth = 4 }); HUMEditor.Vertical(() => { BeginBlock(variable["type"], position, GUIContent.none); LudiqGUI.InspectorLayout(variable["type"], GUIContent.none); if (EndBlock(variable["type"])) { variablesVal.variables[i].Changed(); AssetDatabase.SaveAssets(); AssetDatabase.Refresh(); } }); BeginBlock(metadata, position, GUIContent.none); if (GUILayout.Button("-", GUILayout.Width(16), GUILayout.Height(14))) { variablesVal.variables.Remove(variableVal); AssetDatabase.RemoveObjectFromAsset(variableVal.getter.macro); AssetDatabase.RemoveObjectFromAsset(variableVal.setter.macro); AssetDatabase.SaveAssets(); AssetDatabase.Refresh(); } if (EndBlock(metadata)) { _target.Define(); } }); GUILayout.Space(2); HUMEditor.Vertical(() => { LudiqGUI.InspectorLayout(variable["value"].Cast(variableVal.type), GUIContent.none); }); }); GUILayout.Space(2); }); } BeginBlock(metadata, position, GUIContent.none); if (GUILayout.Button("+ New Variable")) { var variable = new Variable(); variable.getter.Initialize(); variable.setter.Initialize(); variable.getter.showLabel = false; variable.setter.showLabel = false; variable.getter.name = string.Empty; variable.setter.name = string.Empty; variable.getter.macro.hideFlags = HideFlags.HideInHierarchy; variable.setter.macro.hideFlags = HideFlags.HideInHierarchy; AssetDatabase.AddObjectToAsset(variable.getter.macro, _target); AssetDatabase.AddObjectToAsset(variable.setter.macro, _target); variablesVal.variables.Add(variable); AssetDatabase.SaveAssets(); AssetDatabase.Refresh(); } if (EndBlock(metadata)) { _target.Define(); } }); }); }
private void Methods(Rect position) { _target.customMethodsOpen = HUMEditor.Foldout(_target.customMethodsOpen, new GUIContent("Methods", Images.flow_icon_16), Styles.backgroundColor.Brighten(0.05f), Styles.borderColor, 1, () => { HUMEditor.Vertical().Box(Styles.backgroundColor.Brighten(0.025f), Styles.borderColor, new RectOffset(4, 4, 4, 2), new RectOffset(1, 1, 0, 1), () => { var methods = metadata["methods"]["custom"]; var methodsVal = (List <Method>)metadata["methods"]["custom"].value; for (int i = 0; i < methodsVal.Count; i++) { if (i != 0) { GUILayout.Space(2); } HUMEditor.Vertical().Box(Styles.backgroundColor.Brighten(0.075f), Styles.borderColor, new RectOffset(4, 4, 4, 2), new RectOffset(1, 1, 1, 1), () => { var meth = methodsVal[i]; meth.name = GUILayout.TextField(meth.name); meth.macro.name = meth.name; HUMEditor.Horizontal(() => { HUMEditor.Vertical(() => { LudiqGUI.InspectorLayout(methods[i], GUIContent.none); }); BeginBlock(methods, position, GUIContent.none); if (GUILayout.Button("-", GUILayout.Width(16), GUILayout.Height(18))) { methodsVal.Remove(meth); AssetDatabase.RemoveObjectFromAsset(meth.macro); AssetDatabase.SaveAssets(); AssetDatabase.Refresh(); } if (EndBlock(methods)) { _target.Define(); } }); }); } BeginBlock(metadata, position, GUIContent.none); if (GUILayout.Button("+ New Method")) { var meth = new Method(); meth.Initialize(); meth.showLabel = false; meth.name = string.Empty; meth.macro.hideFlags = HideFlags.HideInHierarchy; AssetDatabase.AddObjectToAsset(meth.macro, _target); methodsVal.Add(meth); AssetDatabase.SaveAssets(); AssetDatabase.Refresh(); } if (EndBlock(metadata)) { _target.Define(); } }); }); }
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()); } }); }); }