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 void OnGUI(Rect footerRect, AXNodeGraphEditorWindow editor) { Event e = Event.current; AXModel model = editor.model; float statusBarY = footerRect.y; GUI.Box(footerRect, GUIContent.none); float bSize = 32; Rect vButtonRect = new Rect(4, statusBarY - 3, bSize, bSize); GUIStyle s = new GUIStyle(EditorStyles.label); Color oldColor = s.normal.textColor; s.alignment = TextAnchor.MiddleLeft; s.normal.textColor = ArchimatixEngine.AXGUIColors["GrayText"]; s.fixedWidth = 120; Color vcolor = Color.white; vcolor.a = .5f; GUI.color = vcolor; GUI.Label(vButtonRect, "AX v" + ArchimatixEngine.version, s); GUI.color = Color.white; Rect mButtonRect = new Rect(90, statusBarY, bSize, bSize); Rect tooltipRect = new Rect(mButtonRect.x - 10, statusBarY - 25, 100, bSize); GUIStyle labelstyle = GUI.skin.GetStyle("Label"); labelstyle.alignment = TextAnchor.MiddleLeft; Color prevGUIColor = GUI.color; Color gcol = GUI.color; GUI.backgroundColor = Color.gray; tooltipRect.x = mButtonRect.x - 10; // BUTTON: Close All Controls if (mButtonRect.Contains(Event.current.mousePosition)) // TOOLTIP { gcol.a = .8f; GUI.Label(tooltipRect, "Close All Controls"); } else { gcol.a = .5f; } GUI.color = gcol; if (GUI.Button(mButtonRect, editor.CloseAllControlsIcon)) { editor.closeAllControls(); } // BUTTON: Close All Tools mButtonRect.x += bSize + 3; tooltipRect.x = mButtonRect.x - 10; if (mButtonRect.Contains(Event.current.mousePosition)) // TOOLTIP { gcol.a = .8f; GUI.color = gcol; GUI.Label(tooltipRect, "Close All Tools"); } else { gcol.a = .5f; } GUI.color = gcol; if (GUI.Button(mButtonRect, editor.CloseAllToolsIcon)) { editor.closeTools(); } // BUTTON: Show All Nodes mButtonRect.x += bSize + 3; tooltipRect.x = mButtonRect.x - 10; if (mButtonRect.Contains(Event.current.mousePosition)) // TOOLTIP { gcol.a = .8f; GUI.color = gcol; GUI.Label(tooltipRect, "Show All Nodes"); } else { gcol.a = .5f; } GUI.color = gcol; if (GUI.Button(mButtonRect, editor.ShowAllNodesIcon)) { foreach (AXParametricObject po in model.parametricObjects) { po.isOpen = true; } } // zoomScale mButtonRect.x += bSize + 3; tooltipRect.x = mButtonRect.x - 10; mButtonRect.width = 45; if (mButtonRect.Contains(Event.current.mousePosition)) // TOOLTIP { gcol.a = .8f; GUI.color = gcol; GUI.Label(tooltipRect, "Zoom Scale"); } else { gcol.a = .5f; } GUI.color = gcol; if (GUI.Button(mButtonRect, ("" + (model.zoomScale * 100)) + "%")) { editor.zoomScale = 1; model.zoomScale = 1; editor.Repaint(); } GUI.color = prevGUIColor; //GUI.Label (new Rect (position.width / 2, statusBarY + 10, 100, 20), "Archimatix v " + ArchimatixEngine.version); if (model != null) { //Debug.Log("model.stats_TriangleCount="+model.stats_TriangleCount); EditorGUI.LabelField(new Rect(editor.position.width - 335, statusBarY + 7, 100, 20), "Vertices: " + model.stats_VertCount, s); EditorGUI.LabelField(new Rect(editor.position.width - 230, statusBarY + 7, 100, 20), "Triangles: " + model.stats_TriangleCount, s); EditorGUI.BeginChangeCheck(); EditorGUIUtility.labelWidth = 70; //model.segmentReductionFactor = EditorGUI.Slider( new Rect(position.width-120, statusBarY+7, 115, 20), "Detail Level", model.segmentReductionFactor, 0, 1); model.segmentReductionFactor = EditorGUI.Slider(new Rect(editor.position.width - 120, statusBarY + 7, 115, 20), "Detail Level", model.segmentReductionFactor, 0, 1); if (EditorGUI.EndChangeCheck()) { Undo.RegisterCompleteObjectUndo(model, "Segment Reduction"); model.isAltered(); } } Handles.BeginGUI( ); Handles.color = Color.gray; Handles.DrawLine( new Vector3(0, statusBarY, 0), new Vector3(editor.position.width, statusBarY, 0)); Handles.EndGUI(); s.normal.textColor = oldColor; }
public override void OnSceneGUI() { AXModel model = ArchimatixEngine.currentModel; FreeCurve gener = (FreeCurve)generator; Event e = Event.current; if (model != null) { Matrix4x4 context = parametricObject.model.transform.localToWorldMatrix * generator.parametricObject.worldDisplayMatrix; // * generator.localMatrix; drawGUIControls(); if ((ArchimatixEngine.sceneViewState == ArchimatixEngine.SceneViewState.AddPoint || (e.type == EventType.mouseDrag && ArchimatixEngine.isPseudoDraggingSelectedPoint >= 0)) && !e.alt) { Vector3 v1 = context.MultiplyPoint3x4(Vector3.zero); Vector3 v2 = context.MultiplyPoint3x4(new Vector3(100, 0, 0)); Vector3 v3 = context.MultiplyPoint3x4(new Vector3(0, 100, 0)); //Debug.Log ("-"+ArchimatixEngine.sceneViewState + "- plane points: " + v1 + ", " + v2+ ", " + v3 ); Plane drawingSurface = new Plane(v1, v2, v3); //Matrix4x4 = parametricObject.model.transform.localToWorldMatrix * generator.parametricObject.worldDisplayMatrix;// * generator.localMatrix.inverse; Ray ray = HandleUtility.GUIPointToWorldRay(e.mousePosition); float rayDistance = 0; Vector3 hitPoint; // Point on Plane if (drawingSurface.Raycast(ray, out rayDistance)) { hitPoint = ray.GetPoint(rayDistance); Vector3 hit_position3D = new Vector3(hitPoint.x, hitPoint.y, hitPoint.z); if (ArchimatixEngine.snappingOn()) { hit_position3D = AXGeometryTools.Utilities.SnapToGrid(hit_position3D, parametricObject.model.snapSizeGrid); } int nearId = HandleUtility.nearestControl; if (nearId == 0) { Color cyan = Color.cyan; cyan.a = .1f; float hScale = .09f * HandleUtility.GetHandleSize(hit_position3D); float lScale = 5 * hScale; Handles.color = cyan; Handles.DrawSolidDisc(hit_position3D, Vector3.up, hScale); cyan.a = .8f; Handles.color = cyan; Handles.DrawWireDisc(hit_position3D, Vector3.up, 2 * hScale); Handles.DrawLine(hit_position3D + lScale * Vector3.forward, hit_position3D - lScale * Vector3.forward); //Handles.color = Color.white; Handles.DrawLine(hit_position3D + lScale * Vector3.right, hit_position3D - lScale * Vector3.right); // put visual cue under mouse.... //Debug.Log (hitPoint); } hitPoint = context.inverse.MultiplyPoint3x4(hitPoint); Vector2 hit_position2D = new Vector2(hitPoint.x, hitPoint.y); if (ArchimatixEngine.snappingOn()) { hit_position2D = AXGeometryTools.Utilities.SnapToGrid(hit_position2D, parametricObject.model.snapSizeGrid); } // EVENTS if (e.type == EventType.MouseDown && !e.alt && nearId == 0 && e.button == 0) { ArchimatixEngine.isPseudoDraggingSelectedPoint = -1; if (gener != null) { if (!e.control) // add to end of line { // ADD POINT AT END gener.parametricObject.curve.Add(new CurvePoint(hit_position2D.x, hit_position2D.y)); gener.selectedIndex = gener.parametricObject.curve.Count - 1; } else // ADD POINT TO BEGINNING { gener.parametricObject.curve.Insert(0, new CurvePoint(hit_position2D.x, hit_position2D.y)); gener.selectedIndex = 0; } ArchimatixEngine.isPseudoDraggingSelectedPoint = gener.selectedIndex; model.autobuild(); } } else if (e.type == EventType.mouseDrag) { //Debug.Log("Dragging "+ ArchimatixEngine.isPseudoDraggingSelectedPoint + " :: " + generator.selectedIndices); if (gener == ArchimatixEngine.selectedFreeCurve && ArchimatixEngine.isPseudoDraggingSelectedPoint >= 0) { if (gener.parametricObject.curve.Count > ArchimatixEngine.isPseudoDraggingSelectedPoint && generator.selectedIndices != null) { // The actual point being dragged: Vector2 displ = hit_position2D - gener.parametricObject.curve[ArchimatixEngine.isPseudoDraggingSelectedPoint].position; gener.parametricObject.curve[ArchimatixEngine.isPseudoDraggingSelectedPoint].position = hit_position2D; for (int i = 0; i < model.activeFreeCurves.Count; i++) { FreeCurve fc = (FreeCurve)model.activeFreeCurves[i].generator; if (fc != null && fc.selectedIndices != null) { for (int j = 0; j < fc.selectedIndices.Count; j++) { if (!(fc == gener && fc.selectedIndices[j] == ArchimatixEngine.isPseudoDraggingSelectedPoint)) { fc.parametricObject.curve[fc.selectedIndices[j]].position += displ; } } } } //Debug.Log ("DRAGGING"); parametricObject.setAltered(); model.isAltered(); generator.adjustWorldMatrices(); } } } if (e.type == EventType.mouseUp) { //if (ArchimatixEngine.isPseudoDraggingSelectedPoint > -1) ArchimatixEngine.isPseudoDraggingSelectedPoint = -1; ArchimatixEngine.draggingNewPointAt = -1; //model.autobuild(); //Debug.Log("mouse up"); } if ((e.type == EventType.mouseDown) || (e.type == EventType.mouseDrag && ArchimatixEngine.isPseudoDraggingSelectedPoint >= 0) || (e.type == EventType.mouseUp)) { //e.Use(); } SceneView sv = SceneView.lastActiveSceneView; if (sv != null) { sv.Repaint(); } } } } } // \OnScenView
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 static void processEventCommandKeyDown(Event e, AXModel model) { switch (e.keyCode) { case KeyCode.L: if (model.selectedPOs != null && model.selectedPOs.Count == 1) { LibraryEditor.doSave_MenuItem(model.selectedPOs[0]); if (e.type != EventType.Repaint && e.type != EventType.Layout) { e.Use(); } } break; case KeyCode.V: // this paste waste uncaught by EventType.ExecuteCommand or EventType.ValidateCommand // beacuse alt or command were held down Undo.RegisterCompleteObjectUndo(model, "Paste"); if (e.shift) { if (e.alt) { model.duplicateSelectedPOs(); } else { model.replicateSelectedPOs(); } model.isAltered(6); if (e.type != EventType.Repaint && e.type != EventType.Layout) { e.Use(); } } break; case KeyCode.D: Undo.RegisterCompleteObjectUndo(model, "Duplicate"); //Debug.Log ("DUPLICATE.....KeyCode.D"); if (model.selectedPOs.Count > 0) { AXParametricObject selectedPO = model.selectedPOs[0]; if (e.shift) { replicatePO(selectedPO); } else if (e.alt) { duplicatePO(selectedPO); } else { //Debug.Log ("instancePO"); instancePO(selectedPO); } } // "Duplicate" is caught by the validateCommand and processed here in processEventCommand() model.isAltered(7); if (e.type != EventType.Repaint && e.type != EventType.Layout) { e.Use(); } break; case KeyCode.Backspace: string focusedControlName = GUI.GetNameOfFocusedControl(); if (string.IsNullOrEmpty(focusedControlName) || !focusedControlName.Contains("_Text_")) { Undo.RegisterCompleteObjectUndo(model, "Delete"); if (e.shift) { model.deleteSelectedPOsAndInputs(); } else { model.deleteSelectedPOs(); } model.isAltered(8); e.Use(); } break; } // Update EditorWindow ArchimatixEngine.repaintGraphEditorIfExistsAndOpen(); }
public void UpdateRadius(float val) { p_radius.initiateRipple_setFloatValueFromGUIChange(val); model.isAltered(); }
public static void contextMenu(AXParameter p, Vector2 position) { AXModel model = p.parametricObject.model; GenericMenu menu = new GenericMenu(); //parametricObject.generator.addContextMenuItems(menu); menu.AddSeparator("Organizers ..."); menu.AddItem(new GUIContent("Grouper"), false, () => { AXParametricObject npo = AXEditorUtilities.addNodeToCurrentModel("Grouper"); AXParameter new_p = npo.addInputMesh(); new_p.makeDependentOn(p); model.isAltered(21); }); menu.AddSeparator(" "); menu.AddSeparator("Repeaters ..."); menu.AddItem(new GUIContent("Instance"), false, () => { AXEditorUtilities.addNodeToCurrentModel("Instance").getParameter("Input Mesh").makeDependentOn(p); model.autobuild(); }); menu.AddItem(new GUIContent("Replicant"), false, () => { AXEditorUtilities.addNodeToCurrentModel("Replicant").getParameter("Input Mesh").makeDependentOn(p); model.autobuild(); }); menu.AddItem(new GUIContent("PairRepeater"), false, () => { AXEditorUtilities.addNodeToCurrentModel("PairRepeater").getPreferredInputParameter().makeDependentOn(p); model.autobuild(); }); menu.AddItem(new GUIContent("RadialRepeater"), false, () => { AXEditorUtilities.addNodeToCurrentModel("RadialRepeater").getPreferredInputParameter().makeDependentOn(p); model.autobuild(); }); menu.AddItem(new GUIContent("FloorRepeater (Node)"), false, () => { AXEditorUtilities.addNodeToCurrentModel("FloorRepeater").getParameter("Node Mesh").makeDependentOn(p); model.autobuild(); }); menu.AddItem(new GUIContent("FloorRepeater (Node)"), false, () => { AXEditorUtilities.addNodeToCurrentModel("FloorRepeater").getParameter("Story Mesh").makeDependentOn(p); model.autobuild(); }); // GRID_REPEATER menu.AddItem(new GUIContent("GridRepeater (Node)"), false, () => { AXEditorUtilities.addNodeToCurrentModel("GridRepeater").getParameter("Node Mesh").makeDependentOn(p); model.autobuild(); }); menu.AddItem(new GUIContent("GridRepeater (Cell)"), false, () => { AXEditorUtilities.addNodeToCurrentModel("GridRepeater").getParameter("Cell Mesh").makeDependentOn(p); model.autobuild(); }); menu.AddItem(new GUIContent("GridRepeater (Span)"), false, () => { AXEditorUtilities.addNodeToCurrentModel("GridRepeater").getParameter("Bay Span").makeDependentOn(p); model.autobuild(); }); menu.AddItem(new GUIContent("ShapeRepeater (Node Mesh)"), false, () => { AXEditorUtilities.addNodeToCurrentModel("ShapeRepeater").getParameter("Node Mesh").makeDependentOn(p); model.autobuild(); }); menu.AddItem(new GUIContent("ShapeRepeater (Bay Span Mesh)"), false, () => { AXEditorUtilities.addNodeToCurrentModel("ShapeRepeater").getParameter("Bay Span Mesh").makeDependentOn(p); model.autobuild(); }); menu.AddItem(new GUIContent("ShapeRepeater (Corner Mesh)"), false, () => { AXEditorUtilities.addNodeToCurrentModel("ShapeRepeater").getParameter("Corner Mesh").makeDependentOn(p); model.autobuild(); }); menu.ShowAsContext(); }
public override void OnInspectorGUI() { //if (Event.current.type != EventType.Layout) // return; AXModel model = (AXModel)target; Event e = Event.current; //Debug.Log(evt.type); switch (e.type) { case EventType.Layout: if (doAutobuild) { doAutobuild = false; model.autobuild(); } break; case EventType.MouseDown: //Debug.Log("Down"); break; case EventType.MouseUp: doAutobuild = true; break; case EventType.KeyUp: Undo.RegisterCompleteObjectUndo(model, "Key Up"); //Debug.Log("KeyUp"); doAutobuild = true; break; case EventType.DragUpdated: //Debug.Log("Dragging"); break; case EventType.DragPerform: //DragAndDrop.AcceptDrag(); //Debug.Log("Drag and Drop not supported... yet"); Undo.RegisterCompleteObjectUndo(model, "Default material scale"); doAutobuild = true; break; } /* * switch (e.type) * { * case EventType.mouseUp: * * model.autobuild(); * //e.Use (); * break; * * case EventType.mouseDown: * * model.autobuild(); * //e.Use (); * break; * * } */ //myTarget.MyValue = EditorGUILayout.IntSlider("Val-you", myTarget.MyValue, 1, 10); if (richLabelStyle == null) { richLabelStyle = new GUIStyle(GUI.skin.label); richLabelStyle.richText = true; richLabelStyle.wordWrap = true; } //if (infoIconTexture = null) String rubricColor = (EditorGUIUtility.isProSkin) ? "#bbbbff" : "#660022"; EditorGUIUtility.labelWidth = 150; model.precisionLevel = (PrecisionLevel)EditorGUILayout.EnumPopup("Precision Level", model.precisionLevel); if (!AXNodeGraphEditorWindow.IsOpen) { GUILayout.Space(10); if (GUILayout.Button("Open in Node Graph")) { AXNodeGraphEditorWindow.Init(); } } GUILayout.Space(20); // -- RUBRIC - MATERIAL -- EditorGUILayout.BeginHorizontal(); GUILayout.Label("<color=" + rubricColor + "> <size=13>Material (Default)</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/materials"); } EditorGUILayout.EndHorizontal(); // -------- // 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(); } // Texture // model.showDefaultMaterial = EditorGUILayout.Foldout(model.showDefaultMaterial, "Texture Scaling"); 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(); } } 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(); } // 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(); } } EditorGUI.BeginChangeCheck(); model.axTex.runningU = EditorGUILayout.Toggle("Running U", model.axTex.runningU); if (EditorGUI.EndChangeCheck()) { Undo.RegisterCompleteObjectUndo(model, "Running U"); model.isAltered(); } } // PhysicMaterial // model.axMat.showPhysicMaterial = EditorGUILayout.Foldout(model.axMat.showPhysicMaterial, "Physics Material"); 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(); model.autobuild(); } // 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(); } } GUILayout.Space(20); // -- RUBRIC - LIGHTING -- EditorGUILayout.BeginHorizontal(); 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; model.autobuild(); } // 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); /* * if (GUILayout.Button("Set All Objects as Lightmap Static")) * { * Debug.Log("Set all"); * model.setLightmapStaticForAllPOs(); * } */ if (ArchimatixEngine.plevel == 3) { // RUNTIME // 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"); EditorGUI.BeginChangeCheck(); foreach (AXParameterAlias pa in model.exposedParameterAliases) { ParameterAliasGUILayout.OnGUI(pa); } if (EditorGUI.EndChangeCheck()) { model.isAltered(); } GUILayout.Space(30); 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); // -- 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("...no nodes selected"); } GUILayout.Space(50); //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 (); }