public void doPO(AXParametricObject po) { Color guiColorOrig = GUI.color; Color guiContentColorOrig = GUI.contentColor; GUI.color = Color.white; GUI.contentColor = Color.white; Color textColor = new Color(.82f, .80f, .85f); Color textColorSel = new Color(.98f, .95f, 1f); GUIStyle labelstyle = new GUIStyle(GUI.skin.label); //int fontSize = labelstyle.fontSize; labelstyle.fixedHeight = 30; labelstyle.alignment = TextAnchor.UpperLeft; labelstyle.normal.textColor = textColorSel; labelstyle.fontSize = 20; // GUIStyle labelstyleTmp = GUI.skin.GetStyle("Label"); // labelstyleTmp.normal.textColor = Color.red; Color bgcolorOrig = GUI.backgroundColor; //GUI.backgroundColor = Color.cyan; GUIStyle gsTest = new GUIStyle(); gsTest.normal.background = ArchimatixEngine.nodeIcons ["Blank"]; // //Color.gray; gsTest.normal.textColor = Color.white; GUIStyle foldoutStyle = new GUIStyle(EditorStyles.foldout); foldoutStyle.normal.textColor = textColor; foldoutStyle.active.textColor = textColorSel; foldoutStyle.hover.textColor = textColor; foldoutStyle.focused.textColor = textColorSel; foldoutStyle.onNormal.textColor = textColor; foldoutStyle.onActive.textColor = textColorSel; foldoutStyle.onHover.textColor = textColor; foldoutStyle.onFocused.textColor = textColorSel; GUIStyle smallFoldoutStyle = new GUIStyle(EditorStyles.foldout); smallFoldoutStyle.fixedWidth = 0; GUILayout.BeginVertical(gsTest); GUILayout.BeginHorizontal(gsTest); GUILayout.Space(40); Rect rect = GUILayoutUtility.GetLastRect(); //GUI.DrawTexture(new Rect(position.x, rect.y, EditorGUIUtility.currentViewWidth, 100), ArchimatixEngine.nodeIcons["Blank"], ScaleMode.ScaleToFit, true, 1.0F); GUILayout.Space(10); // TITLE GUILayout.Label(po.Name, labelstyle); labelstyle.fontSize = 12; GUILayout.EndHorizontal(); if (po.is2D() && po.generator.hasOutputsReady()) { AXParameter output_p = po.generator.getPreferredOutputParameter(); GUIDrawing.DrawPathsFit(output_p, new Vector2(42, rect.y + 15), 28, ArchimatixEngine.AXGUIColors ["ShapeColor"]); } else if (ArchimatixEngine.nodeIcons != null && ArchimatixEngine.nodeIcons.ContainsKey(po.Type)) { //Rect thumbRect = new Rect (28, rect.y - 0, 36, 36); //GUI.DrawTexture(thumbRect, po.renTex, ScaleMode.ScaleToFit, true, 1.0F); EditorGUI.DrawTextureTransparent(new Rect(28, rect.y - 0, 36, 36), ArchimatixEngine.nodeIcons [po.Type], ScaleMode.ScaleToFit, 1.0F); } Rect rectthumb2 = GUILayoutUtility.GetLastRect(); if (po.is3D() && po.renTex != null) { GUIStyle thumbLgStyle = new GUIStyle(); float thumbLgSize = 64; thumbLgStyle.fixedHeight = thumbLgSize; GUILayout.BeginHorizontal(thumbLgStyle); GUILayout.Space(thumbLgSize); Rect thumbRectLG = new Rect(40, rectthumb2.y + 35, thumbLgSize, thumbLgSize); EditorGUI.DrawTextureTransparent(thumbRectLG, po.renTex, ScaleMode.ScaleToFit, 1.0F); GUILayout.EndHorizontal(); } EditorGUI.indentLevel++; //GUILayout.Space(20); GUILayout.BeginHorizontal(); EditorGUIUtility.labelWidth = 35; EditorGUI.BeginChangeCheck(); //EditorGUIUtility.labelWidth = 65; po.isActive = EditorGUILayout.ToggleLeft("Enabled", po.isActive); if (EditorGUI.EndChangeCheck()) { Undo.RegisterCompleteObjectUndo(po.model, "isActive value change for " + po.Name); po.model.autobuild(); po.generator.adjustWorldMatrices(); } GUILayout.FlexibleSpace(); if (GUILayout.Button("Select in Node Graph")) { po.model.selectAndPanToPO(po); } GUILayout.EndHorizontal(); // FLAGS, TAGS & LAYERS if (po.is3D()) { po.displayFlagsTagsLayers = EditorGUILayout.Foldout(po.displayFlagsTagsLayers, "Name, Flags, Tags & Layers", true, foldoutStyle); } else { po.displayFlagsTagsLayers = EditorGUILayout.Foldout(po.displayFlagsTagsLayers, "Name", true, foldoutStyle); } if (po.displayFlagsTagsLayers) { //EDIT TITLE // if (showTitle(po)) // { //GUILayout.BeginHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Space(35); GUILayout.Label("Name: "); EditorGUIUtility.labelWidth = 65; po.Name = GUILayout.TextField(po.Name); GUILayout.EndHorizontal(); if (po.is3D()) { EditorGUIUtility.labelWidth = 75; EditorGUI.BeginChangeCheck(); po.axStaticEditorFlags = (AXStaticEditorFlags)EditorGUILayout.EnumMaskField("Static: ", po.axStaticEditorFlags); if (EditorGUI.EndChangeCheck()) { Undo.RegisterCompleteObjectUndo(po.model, "Static value change for " + po.Name); po.setUpstreamersToYourFlags(); // post dialog to change all children... ArchimatixEngine.scheduleBuild(); } GUI.backgroundColor = bgcolorOrig; EditorGUIUtility.labelWidth = 75; // TAGS EditorGUI.BeginChangeCheck(); po.tag = EditorGUILayout.TagField("Tag:", po.tag); if (EditorGUI.EndChangeCheck()) { Undo.RegisterCompleteObjectUndo(po.model, "Tag value change for " + po.Name); ArchimatixEngine.scheduleBuild(); } // LAYERS EditorGUI.BeginChangeCheck(); int intval = EditorGUILayout.LayerField("Layer:", po.layer); if (EditorGUI.EndChangeCheck()) { Undo.RegisterCompleteObjectUndo(po.model, "Layer value change for " + po.Name); po.layer = intval; ArchimatixEngine.scheduleBuild(); } bool hasMeshRenderer = !po.noMeshRenderer; EditorGUI.BeginChangeCheck(); hasMeshRenderer = EditorGUILayout.ToggleLeft("Mesh Renderer", hasMeshRenderer); if (EditorGUI.EndChangeCheck()) { Undo.RegisterCompleteObjectUndo(po.model, "hasMeshRenderer"); po.noMeshRenderer = !hasMeshRenderer; ArchimatixEngine.scheduleBuild(); } } else if (po.generator is MaterialTool) { EditorGUI.BeginChangeCheck(); //float thumbSize = 16; po.axMat.mat = (Material)EditorGUILayout.ObjectField(po.axMat.mat, typeof(Material), true); if (EditorGUI.EndChangeCheck()) { Undo.RegisterCompleteObjectUndo(po.model, "Material"); po.model.remapMaterialTools(); po.model.autobuild(); } } } // FLAGS< TAGS & LAYERS // POSITION CONTROLS if (po.positionControls != null && po.positionControls.children != null) { po.positionControls.isOpenInInspector = EditorGUILayout.Foldout(po.positionControls.isOpenInInspector, "Transform", true, foldoutStyle); if (po.positionControls.isOpenInInspector) { InspectorParameterGUI.OnGUI(po.positionControls.children); } } // GEOMETRY CONTROLS if (po.geometryControls != null && po.geometryControls.children != null) { po.geometryControls.isOpenInInspector = EditorGUILayout.Foldout(po.geometryControls.isOpenInInspector, "Geometry Controls", true, foldoutStyle); if (po.geometryControls.isOpenInInspector) { InspectorParameterGUI.OnGUI(po.geometryControls.children); } } // PROTOTYPES if (po.is3D()) { po.displayPrototypes = EditorGUILayout.Foldout(po.displayPrototypes, "Prototypes", true, foldoutStyle); if (po.displayPrototypes) { EditorGUI.BeginChangeCheck(); po.prototypeGameObject = (GameObject)EditorGUILayout.ObjectField(po.prototypeGameObject, typeof(GameObject), true); if (EditorGUI.EndChangeCheck()) { Undo.RegisterCompleteObjectUndo(po.model, "Prototype GameObject set for " + po.model.name); if (po.prototypeGameObject != null) { AXPrototype proto = (AXPrototype)po.prototypeGameObject.GetComponent("AXPrototype"); if (proto == null) { proto = po.prototypeGameObject.AddComponent <AXPrototype> (); } if (!proto.parametricObjects.Contains(po)) { proto.parametricObjects.Add(po); } } po.model.autobuild(); } } } if (po.selectedAXGO != null) { GUILayout.Label(po.selectedAXGO.consumerAddress); } // if (po.is3D() && po.renTex != null) // { // GUIStyle thumbLgStyle = new GUIStyle(); // float thumbLgSize = 194; // // thumbLgStyle.fixedHeight = thumbLgSize; // GUILayout.BeginHorizontal(thumbLgStyle); // GUILayout.Space(40); // Rect rectthumb = GUILayoutUtility.GetLastRect(); // Rect thumbRectLG = new Rect(28, rectthumb.y-0, thumbLgSize, thumbLgSize); // GUI.DrawTexture(thumbRectLG, po.renTex, ScaleMode.ScaleToFit, true, 1.0F); // // GUILayout.EndHorizontal(); // } // EditorGUI.indentLevel--; GUILayout.EndVertical(); GUILayout.Space(30); GUI.color = guiColorOrig; GUI.contentColor = guiContentColorOrig; }
public static void OnGUI(List <AXNode> parameters) { for (int i = 0; i < parameters.Count; i++) { AXParameter p = parameters [i] as AXParameter; EditorGUIUtility.labelWidth = 150; AXModel model = p.parametricObject.model; // PARAMETERS switch (p.Type) { // ANIMATION_CURVE case AXParameter.DataType.AnimationCurve: EditorGUI.BeginChangeCheck(); EditorGUILayout.CurveField(p.animationCurve); if (EditorGUI.EndChangeCheck()) { Undo.RegisterCompleteObjectUndo(model, "ModifierCurve"); model.isAltered(28); } break; case AXParameter.DataType.Color: EditorGUI.BeginChangeCheck(); p.colorVal = EditorGUILayout.ColorField(p.colorVal); if (EditorGUI.EndChangeCheck()) { Undo.RegisterCompleteObjectUndo(model, "Color"); model.isAltered(28); } break; // FLOAT case AXParameter.DataType.Float: AXEditorUtilities.assertFloatFieldKeyCodeValidity("FloatField_" + p.Name); // GUI.color = Color.white; // GUI.contentColor = Color.white; // if (p.isOpen) { EditorGUILayout.BeginHorizontal("Box"); } else { EditorGUILayout.BeginHorizontal(); } EditorGUI.BeginChangeCheck(); GUI.SetNextControlName("FloatFieldInsp_" + p.Name); p.FloatVal = EditorGUILayout.FloatField(p.Name, p.FloatVal); if (EditorGUI.EndChangeCheck()) { Undo.RegisterCompleteObjectUndo(model, "value change for " + p.Name); p.parametricObject.initiateRipple_setFloatValueFromGUIChange(p.Name, p.FloatVal); model.isAltered(27); p.parametricObject.generator.adjustWorldMatrices(); ArchimatixEngine.scheduleBuild(); } p.isOpen = EditorGUILayout.Foldout(p.isOpen, GUIContent.none); EditorGUILayout.EndHorizontal(); if (p.isOpen) { EditorGUI.indentLevel++; InspectorParameterEditGUI.OnGUI(p); EditorGUI.indentLevel--; } break; // INT case AXParameter.DataType.Int: //GUI.backgroundColor = new Color(.6f,.6f,.9f,.1f) ; // if (p.isOpen) // EditorGUILayout.BeginHorizontal ("Box"); // else EditorGUILayout.BeginHorizontal(); EditorGUI.BeginChangeCheck(); GUI.SetNextControlName("IntFieldFieldInsp_" + p.Name); p.IntVal = EditorGUILayout.IntField(p.Name, p.IntVal); if (EditorGUI.EndChangeCheck()) { Undo.RegisterCompleteObjectUndo(model, "value change for " + p.Name); p.parametricObject.initiateRipple_setIntValueFromGUIChange(p.Name, p.IntVal); model.isAltered(27); p.parametricObject.generator.adjustWorldMatrices(); ArchimatixEngine.scheduleBuild(); } p.isOpen = EditorGUILayout.Foldout(p.isOpen, GUIContent.none); EditorGUILayout.EndHorizontal(); if (p.isOpen) { EditorGUI.indentLevel++; InspectorParameterEditGUI.OnGUI(p); EditorGUI.indentLevel--; } break; // BOOL case AXParameter.DataType.Bool: //EditorGUIUtility.currentViewWidth-16; GUILayout.BeginHorizontal(); //EditorGUIUtility.labelWidth = 150; EditorGUI.BeginChangeCheck(); p.boolval = EditorGUILayout.Toggle(p.Name, p.boolval); if (EditorGUI.EndChangeCheck()) { Undo.RegisterCompleteObjectUndo(model, " value change for " + p.Name); p.parametricObject.initiateRipple_setBoolParameterValueByName(p.Name, p.boolval); //p.parametricObject.model.autobuild(); p.parametricObject.model.isAltered(27); //p.parametricObject.generator.adjustWorldMatrices(); ArchimatixEngine.scheduleBuild(); } GUILayout.FlexibleSpace(); p.isOpen = EditorGUILayout.Foldout(p.isOpen, GUIContent.none); // Expose EditorGUI.BeginChangeCheck(); p.exposeAsInterface = EditorGUILayout.Toggle(p.exposeAsInterface, GUILayout.MaxWidth(20)); if (EditorGUI.EndChangeCheck()) { Undo.RegisterCompleteObjectUndo(p.parametricObject.model, "Expose Parameter"); if (p.exposeAsInterface) { p.parametricObject.model.addExposedParameter(p); } else { p.parametricObject.model.removeExposedParameter(p); } } GUILayout.EndHorizontal(); break; case AXParameter.DataType.CustomOption: { // OPTION POPUP string[] options = p.optionLabels.ToArray(); EditorGUI.BeginChangeCheck(); GUI.SetNextControlName("CustomOptionPopup_" + p.Guid + "_" + p.Name); p.intval = EditorGUILayout.Popup( p.Name, p.intval, options); if (EditorGUI.EndChangeCheck()) { Undo.RegisterCompleteObjectUndo(p.Parent.model, "value change for " + p.Name); p.parametricObject.model.autobuild(); if (p.PType == AXParameter.ParameterType.PositionControl) { p.parametricObject.generator.adjustWorldMatrices(); } ArchimatixEngine.scheduleBuild(); } break; } } //if (p.PType != AXParameter.ParameterType.None && p.PType != AXParameter.ParameterType.GeometryControl) // continue; } }
public override void OnInspectorGUI() { //if (Event.current.type != EventType.Layout) // return; AXModel model = (AXModel)target; Event e = Event.current; //GUI.skin = axskin; //GUI.skin = null; //Debug.Log(evt.type); switch (e.type) { case EventType.Layout: if (doAutobuild) { doAutobuild = false; //model.autobuild (); ArchimatixEngine.scheduleBuild(); } break; case EventType.MouseDown: //Debug.Log("Down"); break; case EventType.MouseUp: //doAutobuild = true; break; case EventType.KeyUp: if (e.keyCode == KeyCode.Return || e.keyCode == KeyCode.KeypadEnter) { Undo.RegisterCompleteObjectUndo(model, "Enter"); doAutobuild = true; } //Debug.Log("KeyUp"); //doAutobuild = true; break; case EventType.DragUpdated: UnityEngine.Debug.Log("Dragging"); break; case EventType.DragPerform: //DragAndDrop.AcceptDrag(); UnityEngine.Debug.Log("Drag and Drop not supported... yet"); Undo.RegisterCompleteObjectUndo(model, "Default material scale"); doAutobuild = true; break; } if (richLabelStyle == null) { richLabelStyle = new GUIStyle(GUI.skin.label); richLabelStyle.richText = true; richLabelStyle.wordWrap = true; } //if (infoIconTexture = null) String rubricColor = (EditorGUIUtility.isProSkin) ? "#bbbbff" : "#bbbbff"; GUIStyle gsTest = new GUIStyle(); gsTest.normal.background = ArchimatixEngine.nodeIcons ["Blank"]; // //Color.gray; gsTest.normal.textColor = Color.white; Color textColor = new Color(.82f, .80f, .85f); Color textColorSel = new Color(.98f, .95f, 1f); GUIStyle rubric = new GUIStyle(GUI.skin.label); rubric.normal.textColor = textColor; GUIStyle foldoutStyle = new GUIStyle(EditorStyles.foldout); foldoutStyle.normal.textColor = textColor; foldoutStyle.active.textColor = textColorSel; foldoutStyle.hover.textColor = textColor; foldoutStyle.focused.textColor = textColorSel; foldoutStyle.onNormal.textColor = textColor; foldoutStyle.onActive.textColor = textColorSel; foldoutStyle.onHover.textColor = textColor; foldoutStyle.onFocused.textColor = textColorSel; GUILayout.Space(10); GUILayout.BeginVertical(gsTest); EditorGUI.indentLevel++; EditorGUIUtility.labelWidth = 150; model.displayModelDefaults = EditorGUILayout.Foldout(model.displayModelDefaults, "Model Defaults", true, foldoutStyle); if (model.displayModelDefaults) { // PRECISION LEVEL EditorGUILayout.BeginHorizontal(); GUILayout.Space(20); GUILayout.Label("Precision Level", rubric); GUILayout.FlexibleSpace(); model.precisionLevel = (PrecisionLevel)EditorGUILayout.EnumPopup("", model.precisionLevel); EditorGUILayout.EndHorizontal(); if (!AXNodeGraphEditorWindow.IsOpen) { GUILayout.Space(10); if (GUILayout.Button("Open in Node Graph")) { AXNodeGraphEditorWindow.Init(); } } //GUILayout.Space(20); // -- RUBRIC - MATERIAL -- EditorGUILayout.BeginHorizontal(); GUILayout.Space(20); GUILayout.Label("Material (Default)", rubric); GUILayout.FlexibleSpace(); //if (GUILayout.Button ( infoIconTexture, GUIStyle.none)) if (GUILayout.Button(infoIconTexture, GUIStyle.none, new GUILayoutOption[] { GUILayout.Width(16), GUILayout.Height(16) })) { Application.OpenURL("http://www.archimatix.com/manual/materials"); } EditorGUILayout.EndHorizontal(); // -------- if (model.axMat.mat.name == "AX_GridPurple") { EditorGUILayout.HelpBox("Set the default Material for this model.", MessageType.Info); } // Material EditorGUI.BeginChangeCheck(); model.axMat.mat = (Material)EditorGUILayout.ObjectField(model.axMat.mat, typeof(Material), true); if (EditorGUI.EndChangeCheck()) { Undo.RegisterCompleteObjectUndo(model, "Default material for " + model.name); model.remapMaterialTools(); model.autobuild(); } GUILayout.Space(10); // Texture // model.showDefaultMaterial = EditorGUILayout.Foldout(model.showDefaultMaterial, "Texture Scaling", true, foldoutStyle); if (model.showDefaultMaterial) { EditorGUI.BeginChangeCheck(); model.axTex.scaleIsUnified = EditorGUILayout.Toggle("Unified Scaling", model.axTex.scaleIsUnified); if (EditorGUI.EndChangeCheck()) { Undo.RegisterCompleteObjectUndo(model, "Default material scale"); model.axTex.scale.y = model.axTex.scale.x; model.isAltered(); } if (model.axTex.scaleIsUnified) { EditorGUI.BeginChangeCheck(); model.axTex.scale.x = EditorGUILayout.FloatField("Scale", model.axTex.scale.x); if (EditorGUI.EndChangeCheck()) { Undo.RegisterCompleteObjectUndo(model, "Default material for " + model.name); model.axTex.scale.y = model.axTex.scale.x; model.isAltered(); ArchimatixEngine.scheduleBuild(); } } else { // Scale X EditorGUI.BeginChangeCheck(); model.axTex.scale.x = EditorGUILayout.FloatField("Scale X", model.axTex.scale.x); if (EditorGUI.EndChangeCheck()) { Undo.RegisterCompleteObjectUndo(model, "Default material for " + model.name); model.isAltered(); ArchimatixEngine.scheduleBuild(); } // Scale Y EditorGUI.BeginChangeCheck(); model.axTex.scale.y = EditorGUILayout.FloatField("Scale Y", model.axTex.scale.y); if (EditorGUI.EndChangeCheck()) { Undo.RegisterCompleteObjectUndo(model, "Default material for " + model.name); model.isAltered(); ArchimatixEngine.scheduleBuild(); } } EditorGUI.BeginChangeCheck(); model.axTex.runningU = EditorGUILayout.Toggle("Running U", model.axTex.runningU); if (EditorGUI.EndChangeCheck()) { Undo.RegisterCompleteObjectUndo(model, "Running U"); model.isAltered(); ArchimatixEngine.scheduleBuild(); } } GUILayout.Space(10); // PhysicMaterial // model.axMat.showPhysicMaterial = EditorGUILayout.Foldout(model.axMat.showPhysicMaterial, "Physics Material", true, foldoutStyle); if (model.axMat.showPhysicMaterial) { // PHYSIC MATERIAL EditorGUI.BeginChangeCheck(); model.axMat.physMat = (PhysicMaterial)EditorGUILayout.ObjectField(model.axMat.physMat, typeof(PhysicMaterial), true); if (EditorGUI.EndChangeCheck()) { Undo.RegisterCompleteObjectUndo(model, "Default PhysicMaterial for " + model.name); model.remapMaterialTools(); ArchimatixEngine.scheduleBuild(); } // DENSITY EditorGUI.BeginChangeCheck(); model.axMat.density = EditorGUILayout.FloatField("Density", model.axMat.density); if (EditorGUI.EndChangeCheck()) { Undo.RegisterCompleteObjectUndo(model, "Material Density for " + model.name); model.isAltered(); ArchimatixEngine.scheduleBuild(); } } GUILayout.Space(20); model.automaticModelRegeneration = EditorGUILayout.ToggleLeft("Automatic Model Regeneration", model.automaticModelRegeneration); GUILayout.Space(20); // -- RUBRIC - LIGHTING -- EditorGUILayout.BeginHorizontal(); GUILayout.Space(20); GUILayout.Label("Lighting", rubric); //GUILayout.Label ("<color=" + rubricColor + "> <size=13>Lighting</size></color>", richLabelStyle); GUILayout.FlexibleSpace(); //if (GUILayout.Button ( infoIconTexture, GUIStyle.none)) if (GUILayout.Button(infoIconTexture, GUIStyle.none, new GUILayoutOption[] { GUILayout.Width(16), GUILayout.Height(16) })) { Application.OpenURL("http://www.archimatix.com/manual/lightmapping-with-archimatix"); } EditorGUILayout.EndHorizontal(); // -------- // LIGHTMAP FLAGS ENABLED EditorGUI.BeginChangeCheck(); model.staticFlagsEnabled = EditorGUILayout.ToggleLeft("Lightmap Flags Enabled", model.staticFlagsEnabled); if (EditorGUI.EndChangeCheck()) { Undo.RegisterCompleteObjectUndo(model, "Static Masks Enabled change for " + model.name); model.staticFlagsJustEnabled = true; ArchimatixEngine.scheduleBuild(); } // SECONDARY UVs if (model.staticFlagsEnabled) { //if (model.buildStatus == AXModel.BuildStatus.Generated) EditorGUI.BeginChangeCheck(); model.createSecondaryUVs = EditorGUILayout.ToggleLeft("Create Secondary UVs (for Baked GI)", model.createSecondaryUVs); if (EditorGUI.EndChangeCheck()) { //if (model.createSecondaryUVs) // AXEditorUtilities.makeLightMapUVs (model); model.createSecondaryUVsJustEnabled = true; } } GUILayout.Space(20); } // displayModelDefaults /* * if (GUILayout.Button("Set All Objects as Lightmap Static")) * { * Debug.Log("Set all"); * model.setLightmapStaticForAllPOs(); * } */ if (ArchimatixEngine.plevel == 3) { // RUNTIME // string countString = ""; if (model.exposedParameterAliases != null && model.exposedParameterAliases.Count > 0) { countString = " (" + model.exposedParameterAliases.Count + ")"; } model.displayModelRuntimeParameters = EditorGUILayout.Foldout(model.displayModelRuntimeParameters, "Runtime Parameters" + countString, true, foldoutStyle); if (model.displayModelRuntimeParameters) { //GUILayout.Label("<color="+rubricColor+"> <size=13>Pro Runtime Features</size></color>", richLabelStyle); // EXPOSED PARAMETERS //if (model.cycleSelectedAXGO != null) // GUILayout.Label("Consumer Address: "+model.cycleSelectedAXGO.consumerAddress); //GUILayout.Label("Runtime Parameters"); if (model.exposedParameterAliases != null && model.exposedParameterAliases.Count > 0) { EditorGUI.BeginChangeCheck(); foreach (AXParameterAlias pa in model.exposedParameterAliases) { ParameterAliasGUILayout.OnGUI(pa); } if (EditorGUI.EndChangeCheck()) { model.isAltered(); } } else { // GUIStyle labelSty = new GUIStyle("Label"); // labelSty.wordWrap = true; // labelSty.richText = true; EditorGUILayout.HelpBox("You can add runntime parameters by opening any parameter in the graph and checking \"Enable Runtime\"", MessageType.Info); //GUILayout.Label ("<color=\"gray\">You can add runntime parameters by opening any parameter in the graph and checking \"Enable Runtime\"</color>", labelSty); } GUILayout.Space(15); if (model.exposedParameterAliases != null && model.exposedParameterAliases.Count > 0) { if (GUILayout.Button("Create Runtime Controller", GUILayout.Width(200))) { ArchimatixEngine.createControllerForModel = model; } } // RUNTIME HANDLES //if (model.cycleSelectedAXGO != null) // GUILayout.Label("Consumer Address: "+model.cycleSelectedAXGO.consumerAddress); if (model.runtimeHandleAliases != null && model.runtimeHandleAliases.Count > 0) { //GUILayout.Label("Runtime Handles"); foreach (AXHandleRuntimeAlias rth in model.runtimeHandleAliases) { AXRuntimeHandlesGUI.OnGUI(rth); } } GUILayout.Space(20); } } // RUNTIME // RELATIONS if (model.selectedRelationInGraph != null) { GUILayout.Space(20); GUILayout.Label("<color=" + rubricColor + "> <size=13>Selected Relation</size></color>", richLabelStyle); AXRelation r = model.selectedRelationInGraph; RelationEditorGUI.OnGUI(r); } //GUILayout.Space(20); model.displayModelSelectedNodes = EditorGUILayout.Foldout(model.displayModelSelectedNodes, "Selected Node Controls", true, foldoutStyle); if (model.displayModelSelectedNodes) { // -- RUBRIC - SELECTED NODES -- EditorGUILayout.BeginHorizontal(); //GUILayout.Label("<color="+rubricColor+"> <size=13>Selected Nodes</size></color>", richLabelStyle); GUILayout.FlexibleSpace(); //if (GUILayout.Button ( infoIconTexture, GUIStyle.none)) if (GUILayout.Button(infoIconTexture, GUIStyle.none, new GUILayoutOption[] { GUILayout.Width(16), GUILayout.Height(16) })) { Application.OpenURL("http://www.archimatix.com/manual/node-selection"); } EditorGUILayout.EndHorizontal(); // -------- //GUILayout.Space(10); if (model.selectedPOs != null && model.selectedPOs.Count > 0) { for (int i = 0; i < model.selectedPOs.Count; i++) { //Debug.Log(i); AXParametricObject po = model.selectedPOs [i]; //Debug.Log(i+" ------------------------ po.Name="+po.Name+ " -- " + po.generator.AllInput_Ps.Count); doPO(po); // for subnodes... if (po.generator.AllInput_Ps != null) { for (int j = po.generator.AllInput_Ps.Count - 1; j >= 0; j--) { AXParameter p = po.generator.AllInput_Ps [j]; if (p.DependsOn != null) { AXParametricObject spo = p.DependsOn.parametricObject; doPO(spo); // sub-sub nodes... for (int k = spo.generator.AllInput_Ps.Count - 1; k >= 0; k--) { if (spo.generator.AllInput_Ps [k].DependsOn != null) { doPO(spo.generator.AllInput_Ps [k].DependsOn.parametricObject); } } } } } } } else { GUILayout.Label("<color=\"gray\">...no nodes selected</color>", richLabelStyle); } GUILayout.Space(50); } EditorGUI.indentLevel--; GUILayout.EndVertical(); // Editor currentTransformEditor = Editor.CreateEditor(model.gameObject.); // if (currentTransformEditor != null) { // currentTransformEditor.OnInspectorGUI (); // } //model.controls[0].val = EditorGUILayout.Slider(model.controls[0].val, 0, 100); /* * switch (e.type) * { * case EventType.KeyUp: * case EventType.mouseUp: * * model.autobuild(); * //e.Use (); * * //return; * break; * * case EventType.mouseDown: * * //model.autobuild(); * //e.Use (); * break; * * } */ //DrawDefaultInspector (); }
// return the height of this gui area public static int OnGUI(Rect pRect, AXNodeGraphEditorWindow editor, AXParameter p) { Event e = Event.current; if (Event.current.type == EventType.KeyUp) { if (p != null && !GUI.GetNameOfFocusedControl().Contains("logicTextArea_")) { p.parametricObject.model.autobuildDelayed(1000); } } int hgt = (int)pRect.height; float foldoutWidth = 20; float boxWidth = pRect.width - foldoutWidth - ArchimatixUtils.indent; float cur_x = ArchimatixUtils.cur_x; float box_w = ArchimatixUtils.paletteRect.width - cur_x - 3 * ArchimatixUtils.indent; int cur_y = (int)pRect.y; Color inactiveColor = new Color(.7f, .7f, .7f); Color oldBackgroundColor = GUI.backgroundColor; Color dataColor = editor.getDataColor(p.Type); // PERSONAL if (!EditorGUIUtility.isProSkin) { dataColor = new Color(dataColor.r, dataColor.b, dataColor.g, .3f); } GUI.color = dataColor; Rect boxRect = new Rect(cur_x + ArchimatixUtils.indent, cur_y, box_w, ArchimatixUtils.lineHgt); GUI.Box(boxRect, " "); GUI.Box(boxRect, " "); GUI.color = Color.white; int margin = 24; float x0 = pRect.x + 14; float xTF = pRect.x + 12; float wid = pRect.width - margin; int indent = (int)x0 + 2; int lineHgt = 16; int gap = 2; if (p.isEditing) { hgt *= 5; hgt += 8; GUI.Box(new Rect(pRect.x - 6, pRect.y - 3, boxWidth, lineHgt * (8 + p.expressions.Count)), GUIContent.none); } if (p.Parent == null) { return(0); } if (p.Parent != null && p.to_delete == true) { p.Parent.removeParameter(p); return(0); } Color defcolor = GUI.color; // input/ouput sockets GUI.backgroundColor = dataColor; // INPUT SOCKET string buttonLabel = null; Rect buttonRect; if (p.isEditing || p.hasInputSocket) { if (p.isEditing && !p.hasInputSocket) { GUI.color = new Color(defcolor.r, defcolor.g, defcolor.b, .3f); } buttonLabel = (editor.InputParameterBeingDragged == p) ? "-" : ""; buttonRect = new Rect(-3, pRect.y, ArchimatixEngine.buttonSize, ArchimatixEngine.buttonSize); // button color if (editor.OutputParameterBeingDragged != null) { if (editor.OutputParameterBeingDragged.Type != p.Type) { GUI.backgroundColor = inactiveColor; } else if (buttonRect.Contains(Event.current.mousePosition)) { GUI.backgroundColor = Color.white; } } else if (editor.InputParameterBeingDragged != null) { if (editor.InputParameterBeingDragged == p) { GUI.backgroundColor = Color.white; } else { GUI.backgroundColor = inactiveColor; } } // Input Button if (editor.OutputParameterBeingDragged != null && (editor.OutputParameterBeingDragged.parametricObject == p.parametricObject || editor.OutputParameterBeingDragged.Type != p.Type)) { GUI.enabled = false; } if (GUI.Button(buttonRect, buttonLabel)) { if (p.isEditing) { p.hasOutputSocket = (!p.hasOutputSocket); } else { if (Event.current.command) { Debug.Log("CONTEXT"); } else if (editor.OutputParameterBeingDragged != null && editor.OutputParameterBeingDragged.Type != p.Type) { editor.OutputParameterBeingDragged = null; } else { editor.inputSocketClicked(p); } } } GUI.enabled = true; } GUI.backgroundColor = editor.getDataColor(p.Type); GUI.color = defcolor; // INPUT SOCKET // OUTPUT SOCKET if (p.isEditing || p.hasOutputSocket) { if (p.isEditing && !p.hasOutputSocket) { GUI.color = new Color(defcolor.r, defcolor.g, defcolor.b, .3f); } buttonLabel = (editor.OutputParameterBeingDragged == p) ? "-" : ""; buttonRect = new Rect(p.Parent.rect.width - pRect.height + 3, pRect.y, ArchimatixEngine.buttonSize, ArchimatixEngine.buttonSize); // button color if (editor.InputParameterBeingDragged != null) { if (editor.InputParameterBeingDragged.Type != p.Type) { GUI.backgroundColor = inactiveColor; } else if (buttonRect.Contains(Event.current.mousePosition)) { GUI.backgroundColor = Color.white; } } else if (editor.OutputParameterBeingDragged != null) { if (editor.OutputParameterBeingDragged == p) { GUI.backgroundColor = Color.white; } else { GUI.backgroundColor = inactiveColor; } } // Output Button if (editor.InputParameterBeingDragged != null && (editor.InputParameterBeingDragged.parametricObject == p.parametricObject || editor.InputParameterBeingDragged.Type != p.Type)) { GUI.enabled = false; } if (GUI.Button(buttonRect, buttonLabel)) { if (p.isEditing) { p.hasOutputSocket = (!p.hasOutputSocket); } else { if (Event.current.control) { // DISPLAY CONTEXT MENU FOR THINGS YOU CAN USE THIS OUTPUT FOR Debug.Log("context"); //model.selectPO(parametricObject); MeshOuputMenu.contextMenu(p, e.mousePosition); e.Use(); } else if (editor.InputParameterBeingDragged != null && editor.InputParameterBeingDragged.Type != p.Type) { editor.InputParameterBeingDragged = null; } else { editor.outputSocketClicked(p); } } } GUI.enabled = true; } GUI.color = defcolor; // OUTPUT SOCKET // SLIDER AND NUMBER FIELD Rect nameLabelRect = new Rect(x0, pRect.y, wid - 30, 16); Rect cntlRect = new Rect(x0, pRect.y, wid, 16); //Rect boxRect = new Rect(xb, pRect.y+vMargin, boxWidth, pRect.height-vMargin*2); /* * if (hasInputSocket && ! hasOutputSocket) * boxRect = new Rect(xb, pRect.y+vMargin, inputwid, pRect.height-vMargin*2); * else if(! hasInputSocket && hasOutputSocket) * boxRect = new Rect(xb+x_output, pRect.y+vMargin, inputwid+4, pRect.height-vMargin*2); */ Rect textFieldRect = new Rect(xTF + 3, pRect.y, wid - 60, pRect.height + 2); // -- DON'T USE PROPERTY DRAWER TO HANDLE UNDO WITH SLIDER // we need o get the updated value atomically, which the propertydrawer does not seem to do (slower update) // BINDING HIGHLIGHT BACKGROUND BOX //Handles.yAxisColor; //GUI.color = Handles.yAxisColor; /* * if (p.sizeBindingAxis > 0) * { * switch(p.sizeBindingAxis) * { * case Axis.X: * GUI.color = Handles.xAxisColor; break; * case Axis.Y: * GUI.color = Handles.yAxisColor; break; * case Axis.Z: * GUI.color = Handles.zAxisColor; break; * * } * * GUI.Box (new Rect(boxRect.x-m, boxRect.y-m, boxRect.width+4*m, boxRect.height+2*m), GUIContent.none); * GUI.Box (new Rect(boxRect.x-m, boxRect.y-m, boxRect.width+4*m, boxRect.height+2*m), GUIContent.none); * GUI.Box (new Rect(boxRect.x-m, boxRect.y-m, boxRect.width+4*m, boxRect.height+2*m), GUIContent.none); * GUI.Box (new Rect(boxRect.x-m, boxRect.y-m, boxRect.width+4*m, boxRect.height+2*m), GUIContent.none); * GUI.Box (new Rect(boxRect.x-m, boxRect.y-m, boxRect.width+4*m, boxRect.height+2*m), GUIContent.none); * GUI.Box (new Rect(boxRect.x-m, boxRect.y-m, boxRect.width+4*m, boxRect.height+2*m), GUIContent.none); * } */ /* * if (EditorGUIUtility.isProSkin) * GUI.color = new Color(defcolor.r, defcolor.b, defcolor.g, 1f); * else * GUI.color = new Color(defcolor.r, defcolor.b, defcolor.g, .4f); * * GUI.Box (boxRect, GUIContent.none); * GUI.color = defcolor; * * if (EditorGUIUtility.isProSkin) * { * GUI.Box (boxRect, GUIContent.none); * GUI.Box (boxRect, GUIContent.none); * if (p.Parent.model.isSelected(p.Parent)) * GUI.Box (boxRect, GUIContent.none); * } */ // BINDING HIGHLIGHT BACKGROUND BOX // PROPERTYDRAWER //EditorGUI.PropertyField(pRect, pProperty); //OR... GUIStyle labelstyle = GUI.skin.GetStyle("Label"); labelstyle.alignment = TextAnchor.MiddleLeft; GUIStyle buttonstyle = GUI.skin.GetStyle("Button"); buttonstyle.alignment = TextAnchor.MiddleLeft; // NAME string nameString = p.Name; // + "_" + Guid; if (p.Type == AXParameter.DataType.Mesh || p.Type == AXParameter.DataType.Spline || p.Type == AXParameter.DataType.Generic) { labelstyle.alignment = TextAnchor.MiddleLeft; labelstyle.fixedWidth = boxRect.width - 10; GUI.Label(nameLabelRect, nameString); } else if (p.PType == AXParameter.ParameterType.Output) { labelstyle.alignment = TextAnchor.MiddleRight; labelstyle.fixedWidth = boxRect.width - 10; GUI.Label(nameLabelRect, nameString); } else if ((p.hasInputSocket && !p.hasOutputSocket)) { labelstyle.alignment = TextAnchor.MiddleLeft; if (p.Parent.isEditing) { GUI.Label(nameLabelRect, nameString); } else { GUI.Label(nameLabelRect, nameString); } } else if (p.PType == AXParameter.ParameterType.Output) //(!hasInputSocket && hasOutputSocket) { labelstyle.alignment = TextAnchor.MiddleRight; if (p.Parent.isEditing) { GUI.Label(nameLabelRect, nameString + " .... "); } else { GUI.Label(cntlRect, nameString); } } else if (p.Type == AXParameter.DataType.Plane) { labelstyle.alignment = TextAnchor.MiddleRight; if (p.Parent.isEditing) { GUI.Label(nameLabelRect, nameString); } else { GUI.Label(cntlRect, nameString); } } else if (p.Type == AXParameter.DataType.MaterialTool) { labelstyle.alignment = TextAnchor.MiddleLeft; if (p.Parent.isEditing) { GUI.Label(nameLabelRect, nameString); } else { GUI.Label(cntlRect, nameString); } } else if ((p.hasInputSocket && p.hasOutputSocket) || (p.Type == AXParameter.DataType.Float || p.Type == AXParameter.DataType.Int || p.Type == AXParameter.DataType.FloatList)) { EditorGUIUtility.fieldWidth = wid / 3.2f; //36; EditorGUIUtility.labelWidth = wid - EditorGUIUtility.fieldWidth; GUI.backgroundColor = Color.white; EditorGUI.BeginChangeCheck(); p.isOpen = EditorGUI.Foldout(new Rect(pRect.x, cur_y, 20, lineHgt), p.isOpen, ""); if (EditorGUI.EndChangeCheck()) { if (p.isOpen) { foreach (AXParameter pop in p.parametricObject.parameters) { if (pop != p) { pop.isOpen = false; } } } } if (p.isOpen) { // NAME GUI.SetNextControlName("ParameterName_Text_NameField" + p.Guid + "_" + p.Name); p.Name = EditorGUI.TextField(textFieldRect, p.Name); if (p.shouldFocus) { GUI.FocusControl("ParameterName_Text_NameField" + p.Guid + "_" + p.Name); p.shouldFocus = false; } // DELETE PARAMETER if (GUI.Button(new Rect(pRect.width - 2 * lineHgt * 1.5f, cur_y - 1, lineHgt * 1.25f, lineHgt), "-")) { //Debug.Log("remove..."); p.parametricObject.removeParameter(p); //p.expressions.RemoveAt(i); } // MOVE PARAMETER UP if (GUI.Button(new Rect(pRect.width - lineHgt * 1.5f, cur_y - 1, lineHgt * 1.25f, lineHgt), "^")) { //Debug.Log("remove..."); p.parametricObject.moveParameterUp(p); //p.expressions.RemoveAt(i); } cur_y += lineHgt + gap * 3; GUI.Box(new Rect((x0 - 4), cur_y - 4, (pRect.width - 20), ((6 + p.expressions.Count) * lineHgt)), " "); // DATA_TYPE //EditorGUI.PropertyField( new Rect((textFieldRect.x+textFieldRect.width)+6, textFieldRect.y, 60, 22), pProperty.FindPropertyRelative("m_type"), GUIContent.none); //EditorGUI.PropertyField( new Rect((textFieldRect.x+textFieldRect.width)+6, textFieldRect.y, 60, 22), m_type, GUIContent.none); //Rect rec = new Rect((textFieldRect.x+textFieldRect.width)+6, textFieldRect.y, 60, 22); Rect rec = new Rect(x0, cur_y, 60, 22); //m_type = (DataType) EditorGUI.EnumPopup(rec, m_type, "YUP"); string dataType_menu = "Float|Int|Bool|String|Color|FloatList"; string[] dataType_options = dataType_menu.Split('|'); EditorGUI.BeginChangeCheck(); int typeOption = (int)p.Type; if (typeOption == (int)AXParameter.DataType.String) { typeOption = 3; } else if (typeOption == (int)AXParameter.DataType.Color) { typeOption = 4; } else if (typeOption == (int)AXParameter.DataType.FloatList) { typeOption = 5; } typeOption = (int)EditorGUI.Popup( rec, "", typeOption, dataType_options); if (EditorGUI.EndChangeCheck()) { Undo.RegisterCompleteObjectUndo(p.parametricObject.model, "Parameter Type"); p.Type = (AXParameter.DataType)typeOption; if (p.Type == AXParameter.DataType.Spline) { p.Type = AXParameter.DataType.String; } } cur_y += lineHgt + gap * 3; // EXPOSE AS RUNTIME Interface ------------ //EditorGUIUtility.labelWidth = wid-36; cntlRect = new Rect(x0, cur_y, wid, 16); EditorGUI.BeginChangeCheck(); p.exposeAsInterface = EditorGUI.Toggle(cntlRect, "Expose", p.exposeAsInterface); if (EditorGUI.EndChangeCheck()) { Undo.RegisterCompleteObjectUndo(p.parametricObject.model, "Expose Parameter"); if (p.exposeAsInterface) { p.parametricObject.model.addExposedParameter(p); } else { p.parametricObject.model.removeExposedParameter(p); } } cur_y += lineHgt + gap; /* * if (p.Type == AXParameter.DataType.Float) * { * EditorGUI.BeginChangeCheck (); * * //EditorGUIUtility.labelWidth = 20; * GUI.backgroundColor = Color.white; * GUI.Label(new Rect(indent, cur_y, 200,16), "Bind externally in: "); * p.sizeBindingAxis = EditorGUI.Popup( * new Rect((textFieldRect.x+textFieldRect.width)+6, cur_y, 60,16), * "", * p.sizeBindingAxis, * new string[] { * "None", * "X", * "Y", * "Z" * }); * if (EditorGUI.EndChangeCheck ()) { * Undo.RegisterCompleteObjectUndo (p.parametricObject.model, "Size bind Axis"); * Debug.Log ("sizeBindingAxis changed to "+p.sizeBindingAxis ); * * } * cur_y += lineHgt; * } */ // STRING if (p.Type == AXParameter.DataType.String) { p.StringVal = EditorGUI.TextField(new Rect(indent, cur_y, wid - 10, lineHgt), p.StringVal); cur_y += lineHgt; } // NUMBER else if (p.Type == AXParameter.DataType.Float || (p.Type == AXParameter.DataType.Int)) { // MIN/MAX cntlRect = new Rect(x0, cur_y, wid, 16); EditorGUI.BeginChangeCheck(); GUI.SetNextControlName("FloatField_Text_MIN" + p.Guid + "_" + p.Name); if (p.Type == AXParameter.DataType.Float) { p.min = EditorGUI.FloatField(cntlRect, "Min", p.min); } else { p.intmin = EditorGUI.IntField(cntlRect, "Min", p.intmin); } if (EditorGUI.EndChangeCheck()) { //Debug.Log(val); Undo.RegisterCompleteObjectUndo(p.Parent.model, "value change for " + p.Name); if (p.Type == AXParameter.DataType.Float) { p.Parent.initiateRipple_setFloatValueFromGUIChange(p.Name, p.min); } else { p.Parent.initiateRipple_setIntValueFromGUIChange(p.Name, p.intmin); } p.parametricObject.model.isAltered(27); p.parametricObject.generator.adjustWorldMatrices(); ArchimatixEngine.scheduleBuild(); } cur_y += lineHgt; cntlRect = new Rect(x0, cur_y, wid, 16); EditorGUI.BeginChangeCheck(); GUI.SetNextControlName("FloatField_Text_MAX" + p.Guid + "_" + p.Name); if (p.Type == AXParameter.DataType.Float) { p.max = EditorGUI.FloatField(cntlRect, "Max", p.max); } else { p.intmax = EditorGUI.IntField(cntlRect, "Max", p.intmax); } if (EditorGUI.EndChangeCheck()) { //Debug.Log(val); Undo.RegisterCompleteObjectUndo(p.Parent.model, "value change for " + p.Name); if (p.Type == AXParameter.DataType.Float) { p.Parent.initiateRipple_setFloatValueFromGUIChange(p.Name, p.max); } else { p.Parent.initiateRipple_setIntValueFromGUIChange(p.Name, p.intmax); } p.parametricObject.model.isAltered(27); p.parametricObject.generator.adjustWorldMatrices(); } cur_y += lineHgt; GUI.Label(new Rect(indent, cur_y, 200, 16), new GUIContent("Expressions", "When the value of this parameter changes, define its effect on other paramters with mathematical descriptions using this parameter.")); cur_y += lineHgt; // EXPRESSIONS if (p.expressions == null) { p.expressions = new List <string>(); } if (p.expressions.Count == 0) { p.expressions.Add(""); } for (int i = 0; i < p.expressions.Count; i++) { GUI.SetNextControlName("ParameterExpression_" + i + "_Text_" + p.Guid + "_" + p.Name); p.expressions[i] = EditorGUI.TextField(new Rect(indent, cur_y, wid - 30, lineHgt), p.expressions[i]); if (GUI.Button(new Rect(pRect.width - lineHgt * 1.5f, cur_y - 1, lineHgt * 1.25f, lineHgt), "-")) { p.expressions.RemoveAt(i); } cur_y += lineHgt + gap * 2; } if (GUI.Button(new Rect(pRect.width - lineHgt * 1.5f, cur_y, lineHgt * 1.25f, lineHgt), new GUIContent("+", "Add an expression to this Parameter"))) { p.expressions.Add(""); } cur_y += lineHgt; } cur_y += lineHgt; // DONE if (GUI.Button(new Rect((wid - 30 - lineHgt * 1.5f), cur_y - 1, 50, pRect.height), "Done")) { p.isOpen = false; p.shouldFocus = false; AXEditorUtilities.clearFocus(); } // MOVE PARAMETER UP if (GUI.Button(new Rect(pRect.width - lineHgt * 1.5f, cur_y - 1, lineHgt * 1.25f, lineHgt), "v")) { //Debug.Log("remove..."); p.parametricObject.moveParameterDown(p); //p.expressions.RemoveAt(i); } cur_y += lineHgt; } else // (not open) { // NOT EDITING, RATHER USING string bindingLabel = ""; switch (p.sizeBindingAxis) { case Axis.X: bindingLabel = " [X]"; break; case Axis.Y: bindingLabel = " [Y]"; break; case Axis.Z: bindingLabel = " [Z]"; break; } switch (p.Type) { case AXParameter.DataType.AnimationCurve: GUILayout.BeginArea(new Rect(indent, cur_y, wid - 10, 2 * lineHgt)); EditorGUI.BeginChangeCheck(); EditorGUILayout.CurveField(p.animationCurve); if (EditorGUI.EndChangeCheck()) { Undo.RegisterCompleteObjectUndo(p.parametricObject.model, "ModifierCurve"); p.parametricObject.model.isAltered(28); ArchimatixEngine.scheduleBuild(); } GUILayout.EndArea(); break; // COLOR case AXParameter.DataType.Color: p.colorVal = EditorGUI.ColorField(cntlRect, p.colorVal); break; case AXParameter.DataType.Float: // FLOAT SLIDER if (p.PType != AXParameter.ParameterType.DerivedValue) { // VALIDATE INPUT - IF INVALID >> LOSE FOCUS AXEditorUtilities.assertFloatFieldKeyCodeValidity("FloatField_Text_FloatField_" + p.Name); EditorGUI.BeginChangeCheck(); GUI.SetNextControlName("FloatField_Text_" + p.Guid + "_" + p.Name); p.val = EditorGUI.FloatField(cntlRect, nameString + bindingLabel, p.val); if (EditorGUI.EndChangeCheck()) { //Debug.Log(val); Undo.RegisterCompleteObjectUndo(p.Parent.model, "value change for " + p.Name); p.Parent.initiateRipple_setFloatValueFromGUIChange(p.Name, p.val); p.parametricObject.model.isAltered(27); p.parametricObject.generator.adjustWorldMatrices(); ArchimatixEngine.scheduleBuild(); } } else { Rect labelRect = cntlRect; labelRect.width = cntlRect.width - 25; GUI.Label(labelRect, p.Name); GUI.Label(new Rect(cntlRect.width - 10, cntlRect.y, 18, cntlRect.height), "" + p.val); } if (p.shouldFocus) { GUI.FocusControl("FloatField_Text_" + p.Guid + "_" + p.Name); p.shouldFocus = false; } break; case AXParameter.DataType.Int: { // INT SLIDER // VALIDATE INPUT - IF INVALID >> LOSE FOCUS /* * if (Event.current.type == EventType.KeyDown) * { * if(Event.current.keyCode != KeyCode.None && !AXEditorUtilities.isValidIntFieldKeyCode(Event.current.keyCode) && GUI.GetNameOfFocusedControl() == ("IntField_" + p.Name)) * { * Event.current.Use(); * GUI.FocusControl("dummy_label"); * } * } */ AXEditorUtilities.assertIntFieldKeyCodeValidity("IntField_" + p.Name); EditorGUI.BeginChangeCheck(); GUI.SetNextControlName("IntField_" + p.Guid + "_" + p.Name); p.intval = EditorGUI.IntField(cntlRect, nameString, p.intval); if (EditorGUI.EndChangeCheck()) { Undo.RegisterCompleteObjectUndo(p.Parent.model, "value change for " + p.Name); p.initiateRipple_setIntValueFromGUIChange(p.intval); p.parametricObject.model.isAltered(28); p.parametricObject.generator.adjustWorldMatrices(); ArchimatixEngine.scheduleBuild(); } break; } case AXParameter.DataType.Bool: { EditorGUIUtility.labelWidth = wid - 16; EditorGUI.BeginChangeCheck(); GUI.SetNextControlName("BoolToggle_" + p.Guid + "_" + p.Name); p.boolval = EditorGUI.Toggle(cntlRect, nameString, p.boolval); if (EditorGUI.EndChangeCheck()) { Undo.RegisterCompleteObjectUndo(p.Parent.model, "value change for " + p.Name); p.parametricObject.initiateRipple_setBoolParameterValueByName(p.Name, p.boolval); //p.parametricObject.model.autobuild(); p.parametricObject.model.isAltered(); p.parametricObject.generator.adjustWorldMatrices(); ArchimatixEngine.scheduleBuild(); } break; } case AXParameter.DataType.String: labelstyle.alignment = TextAnchor.MiddleLeft; if (p.Parent.isEditing) { GUI.Label(nameLabelRect, nameString); } else { GUI.Label(nameLabelRect, nameString); } break; case AXParameter.DataType.FloatList: labelstyle.alignment = TextAnchor.MiddleLeft; if (p.Parent.isEditing) { GUI.Label(nameLabelRect, nameString); } else { GUI.Label(nameLabelRect, nameString + " (" + p.floats.Count + ")"); } break; case AXParameter.DataType.Option: { // OPTION POPUP string[] options = ArchimatixUtils.getMenuOptions(p.Name); EditorGUIUtility.labelWidth = wid - 50; EditorGUI.BeginChangeCheck(); GUI.SetNextControlName("OptionPopup_" + p.Guid + "_" + p.Name); p.intval = EditorGUI.Popup( cntlRect, p.Name, p.intval, options); if (EditorGUI.EndChangeCheck()) { Undo.RegisterCompleteObjectUndo(p.Parent.model, "value change for " + p.Name); p.parametricObject.model.autobuild(); if (p.PType == AXParameter.ParameterType.PositionControl) { p.parametricObject.generator.adjustWorldMatrices(); } } break; } case AXParameter.DataType.CustomOption: { // OPTION POPUP string[] options = p.optionLabels.ToArray(); EditorGUIUtility.labelWidth = wid * .5f; EditorGUI.BeginChangeCheck(); GUI.SetNextControlName("CustomOptionPopup_" + p.Guid + "_" + p.Name); p.intval = EditorGUI.Popup( cntlRect, p.Name, p.intval, options); if (EditorGUI.EndChangeCheck()) { Undo.RegisterCompleteObjectUndo(p.Parent.model, "value change for " + p.Name); p.parametricObject.model.autobuild(); if (p.PType == AXParameter.ParameterType.PositionControl) { p.parametricObject.generator.adjustWorldMatrices(); } } break; } } // END switch (Type) } } cur_y += lineHgt; GUI.backgroundColor = oldBackgroundColor; /* * if(GUI.changed && ! editor.codeChanged) * { * Debug.Log ("generate " + Parent.Name + " :: " + Name); * //Parent.generateOutput("guid01"); * * * } */ GUI.color = defcolor; return(cur_y - (int)pRect.y); }