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 (); }
public static AXParametricObject instantiateParametricObject(string readIntoLibraryFromRelativeAXOBJPath) { AXModel model = null; // 1. First choice is to use a selected model.... if (ArchimatixEngine.currentModel != null) { model = ArchimatixEngine.currentModel; } bool doInstantiation = true; if (model == null) { // ok, are there other models in the scene that the user doesn't realize arene't selected? AXModel[] axModels = GameObject.FindObjectsOfType(typeof(AXModel)) as AXModel[]; if (axModels != null) { if (axModels.Length == 1) { // Offer this model as a button, but also give opportunity to create a new one... int option = EditorUtility.DisplayDialogComplex("Instantiating Library Item", "There is no AX model currently selected", "Cancel", "Add to " + axModels[0], "Create a new Model"); switch (option) { // Save Scene case 0: doInstantiation = false; break; // Save and Quit. case 1: model = axModels[0]; break; case 2: GameObject axgo = AXEditorUtilities.createNewModel(); model = axgo.GetComponent <AXModel>(); doInstantiation = false; break; default: doInstantiation = false; break; } } else if (axModels.Length > 1) { // Throw up a dialog to see if use wants to go select one of the existing models or create a new one. if (EditorUtility.DisplayDialog("Instantiating Library Item", "There is no AX model currently selected", "Select and Existing Model", "Create a new Model")) { return(null); } } } } if (!doInstantiation) { return(null); } if (model == null) { // Well, then, we tried everything.... GameObject axgo = AXEditorUtilities.createNewModel(); model = axgo.GetComponent <AXModel>(); } //Library.lastInstantiation = po; // This file path is where the metadata // for this head_po was found. Go back to this file // and get the rest of the data... string filepath = ArchimatixUtils.getAbsoluteLibraryPath(readIntoLibraryFromRelativeAXOBJPath); List <AXParametricObject> poList = new List <AXParametricObject>(); List <AXRelation> relationList = new List <AXRelation>(); AX.SimpleJSON.JSONNode json = AX.SimpleJSON.JSON.Parse(File.ReadAllText(filepath)); foreach (AX.SimpleJSON.JSONNode poNode in json["parametric_objects"].AsArray) { poList.Add(JSONSerializersAX.ParametricObjectFromJSON(poNode)); } foreach (AX.SimpleJSON.JSONNode rNode in json["relations"].AsArray) { relationList.Add(AXRelation.fromJSON(rNode)); } //Debug.Log (rNode); // make sure there is a game object ready to instantiate this on if (model == null) { // check if the user really wants to create a new model... GameObject axgo = AXEditorUtilities.createNewModel(); model = axgo.GetComponent <AXModel>(); } Undo.RegisterCompleteObjectUndo(model, "Add Library Object"); // ADD AND RIGUP // !!! Actually add the library item (as a list of PO's and Relations) to the model model.addAndRigUp(poList, relationList); AXParametricObject head_po = poList[0]; head_po.startStowInputs(); //if (poList[0].is2D() && ArchimatixEngine.workingAxis != (int) Axis.NONE) // poList[0].intValue ("Axis", ArchimatixEngine.workingAxis); model.setRenderMode(AXModel.RenderMode.GameObjects); model.generate(); ArchimatixEngine.currentModel = model; Selection.activeGameObject = model.gameObject; model.deselectAll(); model.selectOnlyPO(head_po); head_po.focusMe = true; //AXParametricObject mostRecentPO = model.recentlySelectedPO; AXParametricObject mostRecentPO = model.recentlySelectedPO; //getPOSelectedBefore(head_po); //Debug.Log ("model.focusPointInGraphEditor="+model.focusPointInGraphEditor); float pos_x = (model.focusPointInGraphEditor.x) + 100; // + UnityEngine.Random.Range(-100, 300); float pos_y = (model.focusPointInGraphEditor.y - 250) + UnityEngine.Random.Range(-10, 0); if (mostRecentPO != null) { //pos_x = mostRecentPO.rect.x + 200; //pos_y = mostRecentPO.rect.y; } //Debug.Log (new Rect(pos_x, pos_y, 150, 100)); head_po.rect = new Rect(pos_x, pos_y, 150, 500); //Debug.Log ("OK "+po.Name+".focusMe = " + po.focusMe); // make sure it is in view in the editor window.... //model.startPanningToRect(head_po.rect); //model.cleanGraph(); model.remapMaterialTools(); model.autobuild(); head_po.generator.adjustWorldMatrices(); model.build(); model.selectOnlyPO(head_po); //model.beginPanningToRect(head_po.rect); //AXNodeGraphEditorWindow.zoomToRectIfOpen(head_po.rect); //Debug.Log(" 1 model.selectedPOs.Count="+model.selectedPOs.Count + " " + model.selectedPOs[0].Name ); // EDITOR WINDOW ArchimatixEngine.repaintGraphEditorIfExistsAndOpen(); // SCENEVIEW if (SceneView.lastActiveSceneView != null) { //Debug.Log("REPAINT"); SceneView.lastActiveSceneView.Repaint(); } //Debug.Log("--> ArchimatixEngine.currentModel=" + ArchimatixEngine.currentModel); return(head_po); }
public static void processEventCommand(Event e, AXModel model) { if (e.type == EventType.ValidateCommand) { e.Use(); } //Debug.Log("-> processEventCommand 1: PROCESS COMMAND "+e.commandName); var view = SceneView.lastActiveSceneView; string focusedControlName = GUI.GetNameOfFocusedControl(); if (model != null) { // intercept this command and use for po's switch (e.commandName) { case "UndoRedoPerformed": //Debug.Log ("UndoRedoPerformed"); model.cleanGraph(); model.autobuild(); for (int i = 0; i < model.selectedPOs.Count; i++) { model.selectedPOs[i].generator.adjustWorldMatrices(); } // SCENEVIEW if (SceneView.lastActiveSceneView != null) { SceneView.lastActiveSceneView.Repaint(); } //model.setRenderMode( AXModel.RenderMode.GameObjects ); model.cacheThumbnails("AXGeometryTools.Utilities::processEventCommand::UndoRedoPerformed"); if (e.type != EventType.Repaint && e.type != EventType.Layout) { e.Use(); } break; case "SelectAll": Debug.Log("SelectAll"); model.selectAll(); e.Use(); break; case "Copy": //Debug.Log ("COPY ..."+ GUI.GetNameOfFocusedControl()); //Debug.Log ("buf: " + EditorGUIUtility.systemCopyBuffer); //Debug.Log("-"+focusedControlName+"-"); //Debug.Log((string.IsNullOrEmpty(focusedControlName) || !focusedControlName.Contains("_Text_"))); if (string.IsNullOrEmpty(focusedControlName) || !focusedControlName.Contains("_Text_")) { if (model.selectedPOs.Count > 0) { EditorGUIUtility.systemCopyBuffer = LibraryEditor.poWithSubNodes_2_JSON(model.selectedPOs[0], true); } if (e.type != EventType.Repaint && e.type != EventType.Layout) { e.Use(); } } break; case "Paste": //Debug.Log ("PASTE"); //Debug.Log(GUI.GetNameOfFocusedControl()); //if (string.IsNullOrEmpty(GUI.GetNameOfFocusedControl())) //{ Undo.RegisterCompleteObjectUndo(model, "Paste"); string focusedControlNameBeforePaste = GUI.GetNameOfFocusedControl(); if (string.IsNullOrEmpty(focusedControlNameBeforePaste) || !focusedControlNameBeforePaste.Contains("_Text_")) { //model.deselectAll(); Library.pasteParametricObjectFromString(EditorGUIUtility.systemCopyBuffer); model.autobuild(); if (e.type != EventType.Repaint && e.type != EventType.Layout) { e.Use(); } } model.autobuild(); break; case "Duplicate": Undo.RegisterCompleteObjectUndo(model, "Duplicate"); //Debug.Log ("Duplicate Command"); if (model.selectedPOs.Count > 0) { AXParametricObject selectedPO = model.selectedPOs[0]; instancePO(selectedPO); } model.autobuild(); if (e.type != EventType.Repaint && e.type != EventType.Layout) { e.Use(); } break; case "Cut": Undo.RegisterCompleteObjectUndo(model, "Cut"); //EditorGUIUtility.systemCopyBuffer = JSONSerializersAX.allSelectedPOsAsJson(model); if (string.IsNullOrEmpty(focusedControlName) || !focusedControlName.Contains("_Text_")) { if (model.selectedPOs.Count > 0) { EditorGUIUtility.systemCopyBuffer = LibraryEditor.poWithSubNodes_2_JSON(model.selectedPOs[0], true); } if (e.shift) { model.deleteSelectedPOsAndInputs(); } else { model.deleteSelectedPOs(); } model.autobuild(); if (e.type != EventType.Repaint && e.type != EventType.Layout) { e.Use(); } } break; case "SoftDelete": case "Delete": //Debug.Log("DELETE"); // see if it is a selected point on a curve //if (ArchimatixEngine /* * FreeCurve selectedFreeCurve = null; * * if ( model.selectedPOs != null && model.selectedPOs.Count == 1 && model.selectedPOs[0] != null && model.selectedPOs[0].generator != null && model.selectedPOs[0].generator is FreeCurve) * { * selectedFreeCurve = (FreeCurve) model.selectedPOs[0].generator; * } * * if (selectedFreeCurve != null && selectedFreeCurve.selectedIndices != null && selectedFreeCurve.selectedIndices.Count > 0) * { * // delete points * selectedFreeCurve.deleteSelected(); * } */ // SELECTED POINTS TO DELETE? //Debug.Log("focusedControlName="+focusedControlName); if (string.IsNullOrEmpty(focusedControlName) || !focusedControlName.Contains("_Text_")) { bool foundSelectedPoints = false; if (model.activeFreeCurves.Count > 0) { for (int i = 0; i < model.activeFreeCurves.Count; i++) { FreeCurve gener = (FreeCurve)model.activeFreeCurves[i].generator; //Debug.Log("gener.hasSelectedPoints()="+gener.hasSelectedPoints()); if (gener.hasSelectedPoints()) { foundSelectedPoints = true; gener.deleteSelected(); } } } //Debug.Log("foundSelectedPoints="+foundSelectedPoints); if (foundSelectedPoints) { ArchimatixEngine.mouseIsDownOnHandle = false; } else if (e.shift) { Undo.RegisterCompleteObjectUndo(model, "Delete Nodes"); model.deleteSelectedPOsAndInputs(); } // [S.Darkwell: changed else to this else if to fix bug: "Fix pressing Delete key without Node selected still registers undo event" https://archimatixbeta.slack.com/files/s.darkwell/F1DJRQ3LL/fix_pressing_delete_key_without_node_selected_still_registers_undo_event.cs - 2016.06.02] else if (model.selectedPOs.Count > 0) { Undo.RegisterCompleteObjectUndo(model, "Delete Node"); model.deleteSelectedPOs(); } else if (model.selectedParameterInputRelation != null) { Undo.RegisterCompleteObjectUndo(model, "Delete Dependancy"); model.selectedParameterInputRelation.makeIndependent(); model.selectedParameterInputRelation = null; } else if (model.selectedRelationInGraph != null) { Undo.RegisterCompleteObjectUndo(model, "Delete Relation"); model.unrelate(model.selectedRelationInGraph); model.selectedRelationInGraph = null; } //Debug.Log("*********************************** DELETE"); model.remapMaterialTools(); model.autobuild(); //Debug.Log("caching here G"); model.cacheThumbnails(); e.Use(); } break; case "FrameSelected": if (view != null) { float framePadding = 400; if (model.selectedPOs == null || model.selectedPOs.Count == 0) { //model.selectAll(); model.selectAllVisibleInGroup(model.currentWorkingGroupPO); Rect allRect = AXUtilities.getBoundaryRectFromPOs(model.selectedPOs); allRect.x -= framePadding; allRect.y -= framePadding; allRect.width += framePadding * 2; allRect.height += framePadding * 2; AXNodeGraphEditorWindow.zoomToRectIfOpen(allRect); model.deselectAll(); } else if (model.selectedPOs.Count > 1) { Rect allRect = AXUtilities.getBoundaryRectFromPOs(model.selectedPOs); allRect.x -= framePadding; allRect.y -= framePadding; allRect.width += framePadding * 2; allRect.height += framePadding * 2; AXNodeGraphEditorWindow.zoomToRectIfOpen(allRect); } else { //frame first po AXParametricObject currPO = model.cycleSelectedPO; // model.selectedPOs[0]; if (currPO == null) { currPO = model.mostRecentlySelectedPO; } if (currPO == null && model.selectedPOs != null && model.selectedPOs.Count > 0) { currPO = model.selectedPOs[0]; } if (currPO == null) { currPO = model.selectFirstHeadPO(); } if (currPO != null) { Matrix4x4 m = model.transform.localToWorldMatrix * currPO.worldDisplayMatrix; // * currPO.getLocalMatrix(); if (m.isIdentity) { m = currPO.generator.localMatrix; } Vector3 position = m.MultiplyPoint(currPO.bounds.center); if (currPO.bounds.size.magnitude > .005 && currPO.bounds.size.magnitude < 10000) { view.LookAt(position, view.camera.transform.rotation, currPO.bounds.size.magnitude * 1.01f); } else { //Debug.Log("FrameSelected - select ParametricObjectObject bounds not good: "+currPO.bounds.size.magnitude); } //if (currPO.grouper != null ) //{ AXNodeGraphEditorWindow.displayGroupIfOpen(currPO.grouper); //} //model.beginPanningToPoint(currPO.rect.center); AXNodeGraphEditorWindow.zoomToRectIfOpen(currPO.rect); } } if (e.type != EventType.Repaint && e.type != EventType.Layout) { e.Use(); } } break; } } // EDITOR WINDOW ArchimatixEngine.repaintGraphEditorIfExistsAndOpen(); // SCENEVIEW if (view != null) { view.Repaint(); } lastCommand = e.commandName; }
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 (); }