void OnGUI() { // Is all in order with the Archimatix install? if (string.IsNullOrEmpty(ArchimatixEngine.pathChangelog) || string.IsNullOrEmpty(changelogText)) { return; } if (richLabelStyle == null) { richLabelStyle = new GUIStyle(GUI.skin.label); richLabelStyle.richText = true; richLabelStyle.wordWrap = true; richButtonStyle = new GUIStyle(GUI.skin.button); richButtonStyle.richText = true; textLabelStyle = new GUIStyle(GUI.skin.label); textLabelStyle.richText = true; textLabelStyle.wordWrap = true; textLabelStyle.alignment = TextAnchor.MiddleLeft; textLabelStyle.fixedWidth = 510; iconButtonStyle = new GUIStyle(GUI.skin.button); iconButtonStyle.normal.background = null; iconButtonStyle.imagePosition = ImagePosition.ImageOnly; iconButtonStyle.fixedWidth = 128; iconButtonStyle.fixedHeight = 128; } Rect headerRect = new Rect(0, 0, 530, 200); EditorGUI.DrawTextureTransparent(headerRect, headerPic, ScaleMode.StretchToFill); GUILayout.Space(200); GUILayout.BeginVertical(); { // What to do next.... horizontalRule(0, 2); /* * GUILayout.BeginHorizontal(); * GUILayout.FlexibleSpace(); * GUILayout.Label ("Version " +ArchimatixEngine.version, richLabelStyle); * GUILayout.FlexibleSpace(); * GUILayout.EndHorizontal(); */ // TOP BUTTONS GUILayout.BeginHorizontal(); GUILayout.Space(5); // User GUIDE if (GUILayout.Button("<b>User Guide </b>\n<size=12>The best way to get started</size>", richButtonStyle, GUILayout.MaxWidth(400), GUILayout.Height(36))) { string file = "file:///" + Application.dataPath + "/Archimatix/Documentation/UserGuide.pdf"; Application.OpenURL(file); } // TUTORIALS if (GUILayout.Button("<b>Tutorial Videos </b>\n<size=12>Watch a range of how-tos</size>", richButtonStyle, GUILayout.MaxWidth(400), GUILayout.Height(36))) { Application.OpenURL("http://www.archimatix.com/tutorials"); } GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); GUILayout.Space(4); GUILayout.Label("Or, click on one of these to jump right in!", textLabelStyle, new GUILayoutOption[] { GUILayout.MinWidth(450) }); GUILayout.BeginHorizontal(); { GUILayout.FlexibleSpace(); if (GUILayout.Button(icon3DLibrary, iconButtonStyle)) { ArchimatixEngine.openLibrary3D(); } if (GUILayout.Button(icon2DLibrary, iconButtonStyle)) { ArchimatixEngine.openLibrary2D(); } //if (ArchimatixEngine.NodeGraphEditorIsInstalled) //{ if (GUILayout.Button(iconAXEditor, iconButtonStyle)) { AXNodeGraphEditorWindow.Init(); } //} GUILayout.FlexibleSpace(); } GUILayout.EndHorizontal(); } horizontalRule(4, 1); // CHANGE_LOG GUILayout.BeginHorizontal(); changelogScroll = GUILayout.BeginScrollView(changelogScroll, GUIStyle.none, new GUIStyle(GUI.skin.verticalScrollbar)); GUILayout.Label(changelogText, textLabelStyle); GUILayout.EndScrollView(); GUILayout.EndHorizontal(); horizontalRule(0, 4); GUILayout.BeginHorizontal(); { showAcknowledgements = EditorGUILayout.Foldout(showAcknowledgements, "Acknowledgments", true); if (showAcknowledgements) { GUILayout.BeginHorizontal(); { GUILayout.TextArea("Special thanks to Unity community members in the Beta Team: @elbows, @S_Darkwell, @HeliosDoubleSix, @Teila, @wetcircuit, @radimoto @puzzlekings, @mangax, @sarum, @Sheriziya, @Voronoi, @steveR, @manpower13, @vrpostcard, @Whippets, @pixelstream, @Damien-Delmarle, @recursive, @sloopidoopi, @KWaldt, @pcg, @Hitch42, @Bitstream, @CognitiveCode, @ddutchie, @JacooGamer, @razmot, @angrypenguin, @Paylo, @AdamGoodrich. Also, for much needed feedback and support, many thanks to Eden Muir, Andrew Cortese, Lucas Meijer, Sanjay Mistry, Dominic Laflamme, Rune Skovbo, Alan Robles, Luke Noonan, Anton Hand, Lucas Miller, and Joachim Holmér"); } GUILayout.EndHorizontal(); } } GUILayout.EndHorizontal(); // BOTTOM BUTTON - DOCUMENTATION GUILayout.BeginHorizontal(); { if (GUILayout.Button("<b>Documentation</b>\n<size=12>Manual, examples and tips</size>", richButtonStyle, GUILayout.MaxWidth(260), GUILayout.Height(36))) { Application.OpenURL("http://archimatix.com/documentation"); } if (GUILayout.Button("<b>Rate it</b>\n<size=12>on the Asset Store</size>", richButtonStyle, GUILayout.Height(36))) { Application.OpenURL("http://u3d.as/qYW"); //Application.OpenURL("com.unity3d.kharma:content/?"); } if (GUILayout.Button("<b>Join the Community!</b>\n<size=12>We're are building worlds.</size>", richButtonStyle, GUILayout.Height(36))) { Application.OpenURL("http://community.archimatix.com"); //Application.OpenURL("com.unity3d.kharma:content/?"); } } GUILayout.EndHorizontal(); // Contact horizontalRule(4, 2); GUILayout.BeginHorizontal(); { if (GUILayout.Button("<b>E-mail</b>\n<size=12>[email protected]</size>", richButtonStyle, GUILayout.MaxWidth(172), GUILayout.Height(36))) { Application.OpenURL("mailto:[email protected]"); } if (GUILayout.Button("<b>Twitter</b>\n<size=12>@archimatix</size>", richButtonStyle, GUILayout.Height(36))) { Application.OpenURL("http://twitter.com/archimatix"); } // UNITY FORUM if (GUILayout.Button("<b>Unity Forum</b>\n<size=12>The Original!</size>", richButtonStyle, GUILayout.MaxWidth(172), GUILayout.Height(36))) { Application.OpenURL("http://bit.ly/2gj4oax"); } } GUILayout.EndHorizontal(); GUILayout.Space(5); GUILayout.EndVertical(); }
// 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 static int OnGUI_Mesh(Rect pRect, AXNodeGraphEditorWindow editor, AXParameter p) { float cur_x = ArchimatixUtils.cur_x; //float box_w = ArchimatixUtils.paletteRect.width - cur_x - 3*ArchimatixUtils.indent; float box_w = pRect.width - cur_x - 1 * ArchimatixUtils.indent; int cur_y = (int)pRect.y; int lineHgt = (int)pRect.height; int gap = 5; Color oldBackgroundColor = GUI.backgroundColor; Color dataColor = editor.getDataColor(p.Type); GUI.backgroundColor = dataColor; // INPUT if (!p.parametricObject.isCurrentGrouper()) { if (editor.OutputParameterBeingDragged == null || editor.OutputParameterBeingDragged.Type == AXParameter.DataType.Mesh) { if (p.PType != AXParameter.ParameterType.Output) { if (GUI.Button(new Rect(-3, cur_y, ArchimatixEngine.buttonSize, ArchimatixEngine.buttonSize), "")) { if (editor.OutputParameterBeingDragged != null && editor.OutputParameterBeingDragged.Type != p.Type) { editor.OutputParameterBeingDragged = null; } else { editor.inputSocketClicked(p); } } } } } // OUTPUT if (editor.InputParameterBeingDragged == null || editor.InputParameterBeingDragged.Type == AXParameter.DataType.Mesh) { if (GUI.Button(new Rect(pRect.width + 6, cur_y, ArchimatixEngine.buttonSize, ArchimatixEngine.buttonSize), "")) { if (editor.OutputParameterBeingDragged != null && editor.OutputParameterBeingDragged.Type != p.Type) { editor.OutputParameterBeingDragged = null; } else { editor.outputSocketClicked(p); } } } /* * // IF EDITABLE * 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; * } * } */ // LABEL Rect boxRect = new Rect(cur_x + ArchimatixUtils.indent, cur_y, box_w, pRect.height); Rect lRect = boxRect; lRect.x += 3; lRect.width -= 10; GUIStyle labelstyle = GUI.skin.GetStyle("Label"); labelstyle.alignment = TextAnchor.MiddleLeft; if (p.PType == AXParameter.ParameterType.Output) { labelstyle.alignment = TextAnchor.MiddleRight; labelstyle.fixedWidth = lRect.width - 13; } GUI.Box(boxRect, " "); GUI.Box(boxRect, " "); GUI.Box(boxRect, " "); GUI.Box(boxRect, " "); //Debug.Log(p.Name + " - " + p.ParentNode+ " - " + p.ParentNode.Name); string label = p.Name; GUI.Label(lRect, label); GUI.Label(new Rect(10, 40, 100, 40), GUI.tooltip); cur_y += lineHgt + gap; GUI.backgroundColor = oldBackgroundColor; return(cur_y); }
// Use this for initialization public static void OnGUI(AXRelation r) { GUIStyle richLabelStyle = new GUIStyle(GUI.skin.label); richLabelStyle.richText = true; string labelA = r.pA.Parent.Name + "." + r.pA.Name; string labelB = r.pB.Parent.Name + "." + r.pB.Name; GUILayout.Label("<color=" + ((EditorGUIUtility.isProSkin) ? "#bbbbff" : "#660022") + "> <size=13>Relation Expressions</size></color>", richLabelStyle); GUILayout.Space(5); // SLIDING A SETS B EditorGUILayout.BeginHorizontal(); // B = f(A) GUILayout.Label(labelB + "=", GUILayout.Width(150)); // swap the internal variable name to let the user always use current name, // even if that name has changed since the last time the expresion was edited. if (r.expression_AB != null) { // if ( // Debug.Log(); GUI.SetNextControlName("expression_Text_AB_" + r.pA_guid + "_" + r.pB_guid); r.expression_AB = GUILayout.TextField(r.expression_AB.Replace(r.pA.guidAsEpressionKey, labelA)); r.expression_AB = r.expression_AB.Replace(labelA, r.pA.guidAsEpressionKey); } EditorGUILayout.EndHorizontal(); // SLIDING B SETS A EditorGUILayout.BeginHorizontal(); // A = f(B) GUILayout.Label(labelA + "=", GUILayout.Width(150)); // swap the internal variable name to let the user always use current name, // even if that name has changed since the last time the expresion was edited. string tmp_expression_BA = ""; if (r.expression_BA != null) { GUI.SetNextControlName("expressionBA_Text_BA_" + r.pA_guid + "_" + r.pB_guid); tmp_expression_BA = GUILayout.TextField(r.expression_BA.Replace(r.pB.guidAsEpressionKey, labelB)); r.expression_BA = tmp_expression_BA.Replace(labelB, r.pB.guidAsEpressionKey); } EditorGUILayout.EndHorizontal(); GUILayout.Space(10); // FOOTER MENU AXModel model = r.pA.parametricObject.model; // HORIZONTALMENU EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("Revert")) { r.revert(); AXNodeGraphEditorWindow.repaintIfOpen(); } if (GUILayout.Button("Save")) { model.selectedRelationInGraph = null; //relationEditWindowIsDisplayed = false; } if (GUILayout.Button("Delete")) { //Debug.Log("model "+ model); model.unrelate(r); model.selectedRelation = null; model.selectedRelationInGraph = null; } if (GUILayout.Button("Cancel")) { r.revert(); model.selectedRelationInGraph = null; model.selectedRelation = null; } EditorGUILayout.EndHorizontal(); // labelStyle.alignment = textAlignment; // labelStyle.fixedWidth = fixedWidth; }
public static void makePrefab(AXModel model, string prefabPath, AXNodeGraphEditorWindow _editor) { //if (model == null) // return null; if (model.generatedGameObjects != null) { // extrat folder path from path //string filename = System.IO.Path.GetFileName (filepath); string prefabName = System.IO.Path.GetFileNameWithoutExtension(prefabPath); string relativePrefabPath = ArchimatixUtils.getRelativeFilePath(prefabPath); string folderPath = System.IO.Path.GetDirectoryName(prefabPath); string relativeFolderPath = ArchimatixUtils.getRelativeFilePath(folderPath); // if no directory selected in dialog, then relativeFolderPath is empty if (String.IsNullOrEmpty(relativeFolderPath)) { relativeFolderPath = "Assets"; } Debug.Log(folderPath + " :: " + relativeFolderPath + " :: " + prefabName); model.build(); GameObject stampedGO = model.stamp(); // Only save unique, sharedMeshes to the AssetsDatabase List <Mesh> meshesToSave = new List <Mesh> (); int meshCount = 0; Transform[] transforms = stampedGO.GetComponentsInChildren <Transform> (); foreach (Transform transform in transforms) { MeshFilter meshFilter = transform.gameObject.GetComponent <MeshFilter> (); if (meshFilter != null) { Mesh mesh = meshFilter.sharedMesh; if (mesh != null && !meshesToSave.Contains(mesh)) { ; meshesToSave.Add(mesh); meshCount++; } GameObjectUtility.SetStaticEditorFlags(transform.gameObject, StaticEditorFlags.LightmapStatic); } } AssetDatabase.DeleteAsset(relativePrefabPath); // [not sure why this is needed here to correct the filepath, but not in the Library Save dalog...] relativePrefabPath = relativePrefabPath.Replace('\\', '/'); var prefab = PrefabUtility.CreateEmptyPrefab(relativePrefabPath); int i = 0; foreach (Mesh mesh in meshesToSave) /* * { * if (string.IsNullOrEmpty(mesh.name)) * mesh.name = prefabName+"_"+(i++); * AssetDatabase.DeleteAsset (relativePrefabPath+"/"+mesh.name); * AssetDatabase.AddObjectToAsset(mesh, relativePrefabPath); * } */ { // Compliments of Enoch if (string.IsNullOrEmpty(mesh.name)) { mesh.name = prefabName + "_" + (i++); } var path = AssetDatabase.GetAssetPath(mesh); if (string.IsNullOrEmpty(path)) { AssetDatabase.AddObjectToAsset(mesh, relativePrefabPath); } } AssetDatabase.SaveAssets(); AssetDatabase.Refresh(); PrefabUtility.ReplacePrefab(stampedGO, prefab, ReplacePrefabOptions.ConnectToPrefab); stampedGO.name = prefabName; //Selection.activeGameObject = stampedGO; //buildStatus = BuildStatus.Generated; //Close(); } }
// 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); 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.PType == AXParameter.ParameterType.Input) { 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)) { 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"; string[] dataType_options = dataType_menu.Split('|'); EditorGUI.BeginChangeCheck(); int typeOption = (int)p.Type; if (typeOption == (int)AXParameter.DataType.String) { typeOption = 3; } 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)) { 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); } GUILayout.EndArea(); 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(); } } 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(); } 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.generator.adjustWorldMatrices(); } 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.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); }
public static int OnGUI_Spline(Rect pRect, AXNodeGraphEditorWindow editor, AXParameter p) { float cur_x = ArchimatixUtils.cur_x; //float box_w = ArchimatixUtils.paletteRect.width - cur_x - 3*ArchimatixUtils.indent; float box_w = pRect.width - cur_x - 1 * ArchimatixUtils.indent; int cur_y = (int)pRect.y; int lineHgt = (int)pRect.height; int gap = 5; int margin = 24; float wid = pRect.width - margin; Color shapeColor = editor.getDataColor(AXParameter.DataType.Spline); Color oldBackgroundColor = GUI.backgroundColor; Color dataColor = editor.getDataColor(p.Type); GUI.backgroundColor = dataColor; // INPUT if (editor.OutputParameterBeingDragged != null && editor.OutputParameterBeingDragged.Type != AXParameter.DataType.Spline) { GUI.enabled = false; } if (p.PType != AXParameter.ParameterType.Output) { if (GUI.Button(new Rect(-3, cur_y, ArchimatixEngine.buttonSize, ArchimatixEngine.buttonSize), "")) { if (editor.OutputParameterBeingDragged != null && editor.OutputParameterBeingDragged.Type != p.Type) { editor.OutputParameterBeingDragged = null; } else { editor.inputSocketClicked(p); } } } GUI.enabled = true; // OUTPUT if (editor.InputParameterBeingDragged == null || editor.InputParameterBeingDragged.Type == AXParameter.DataType.Spline) { if (GUI.Button(new Rect(pRect.width + 6, cur_y, ArchimatixEngine.buttonSize, ArchimatixEngine.buttonSize), "")) { if (editor.OutputParameterBeingDragged != null && editor.OutputParameterBeingDragged.Type != p.Type) { editor.OutputParameterBeingDragged = null; } else { editor.outputSocketClicked(p); } } } // LABEL Rect boxRect = new Rect(cur_x + ArchimatixUtils.indent + 3, cur_y, box_w, pRect.height); Rect lRect = boxRect; lRect.x += 3; lRect.width -= 10; GUIStyle labelstyle = GUI.skin.GetStyle("Label"); labelstyle.alignment = TextAnchor.MiddleLeft; if (p.PType == AXParameter.ParameterType.Output) { labelstyle.alignment = TextAnchor.MiddleRight; labelstyle.fixedWidth = lRect.width - 13; } GUI.Box(boxRect, " "); GUI.Box(boxRect, " "); GUI.Box(boxRect, " "); GUI.Box(boxRect, " "); //Debug.Log(p.Name + " - " + p.ParentNode+ " - " + p.ParentNode.Name); string label = p.Name; if (p.ParentNode != null && p.ParentNode is AXShape) { if (p.DependsOn != null) { if (p.DependsOn.Parent != null) { label = p.DependsOn.Parent.Name; } } } GUI.Label(lRect, label); // SOLID/VOID TOGGLE if (p.PType == AXParameter.ParameterType.Input && p.ParentNode != null && (p.ParentNode is AXShape)) { // Texture2D solidVoidIconTexture = (Texture2D) AssetDatabase.LoadAssetAtPath(ArchimatixEngine.ArchimatixAssetPath+"/ui/GeneralIcons/"+iconname, typeof(Texture2D)); Texture2D solidVoidIconTexture = (p.polyType == PolyType.ptSubject) ? editor.solidIconTexture : editor.voidIconTexture; Rect svRect = new Rect(boxRect.x + boxRect.width - lineHgt, cur_y, lineHgt, lineHgt); if (GUI.Button(svRect, new GUIContent(solidVoidIconTexture, "Solid/Void"), GUIStyle.none)) //if(GUI.Button ( bRect, solidVoidIconTexture, GUIStyle.none)) { p.polyType = (p.polyType == PolyType.ptSubject) ? PolyType.ptClip : PolyType.ptSubject; p.parametricObject.model.autobuild(); } GUI.Label(new Rect(10, 40, 100, 40), GUI.tooltip); } // OPEN/CLOSED TOGGLE else { Texture2D solidOpenClosedTexture = (p.shapeState == ShapeState.Open) ? editor.shapeOpenIconTexture : editor.shapeClosedIconTexture; Rect svRect = new Rect(boxRect.x + boxRect.width - lineHgt - 2, cur_y, lineHgt + 2, lineHgt + 2); if (GUI.Button(svRect, new GUIContent(solidOpenClosedTexture, "Open/Closed"), GUIStyle.none)) //if(GUI.Button ( bRect, solidVoidIconTexture, GUIStyle.none)) { p.shapeState = (p.shapeState == ShapeState.Open) ? ShapeState.Closed : ShapeState.Open; p.parametricObject.model.autobuild(); } GUI.Label(new Rect(10, 40, 100, 40), GUI.tooltip); } // FOLDOUT (isOpen) GUI.backgroundColor = new Color(1, 1, 1, 1f); p.isOpen = EditorGUI.Foldout(new Rect(cur_x, cur_y, 15, lineHgt), p.isOpen, ""); GUI.backgroundColor = shapeColor; cur_y += lineHgt + gap; Rect tRect = pRect; tRect.x = 30; tRect.width = pRect.width - 20; if (p.isOpen) { ArchimatixUtils.cur_x += ArchimatixUtils.indent; lineHgt = ArchimatixUtils.lineHgtSmall; p.drawClosed = false; string[] options; tRect.x += 2; tRect.y = cur_y; tRect.width -= 11; tRect.height = 16; Rect cntlRect = tRect; // new Rect(x0, cur_y, wid, 16); cntlRect.height = 16; // EXPOSE AS RUNTIME Interface ------------ //EditorGUIUtility.labelWidth = wid-36; cntlRect = new Rect(tRect.x, cur_y, wid, 16); EditorGUI.BeginChangeCheck(); p.exposeAsInterface = EditorGUI.Toggle(cntlRect, "Runtime", 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; // BREAK MINMAXSLIDER tRect.y = cur_y; GUI.Label(tRect, "Break Geom|Norms"); cur_y += lineHgt; GUI.backgroundColor = Color.white; tRect.y = cur_y; EditorGUI.BeginChangeCheck(); #if UNITY_5_5_OR_NEWER EditorGUI.MinMaxSlider( tRect, GUIContent.none, ref p.breakGeom, ref p.breakNorm, 0, 100); #else EditorGUI.MinMaxSlider( GUIContent.none, tRect, ref p.breakGeom, ref p.breakNorm, 0, 100); #endif if (EditorGUI.EndChangeCheck()) { Undo.RegisterCompleteObjectUndo(p.parametricObject.model, "Max Min Slider"); p.parametricObject.model.isAltered(1); } cur_y += lineHgt + gap; cntlRect.y = cur_y; // REVERSE EditorGUI.BeginChangeCheck(); p.reverse = GUI.Toggle(cntlRect, p.reverse, "Reverse"); if (EditorGUI.EndChangeCheck()) { Undo.RegisterCompleteObjectUndo(p.parametricObject.model, "Reverse"); p.parametricObject.model.autobuild(); } cur_y += lineHgt + gap; cntlRect.y = cur_y; // SYMMETRY EditorGUI.BeginChangeCheck(); p.symmetry = GUI.Toggle(cntlRect, p.symmetry, "Symetry"); if (EditorGUI.EndChangeCheck()) { Undo.RegisterCompleteObjectUndo(p.parametricObject.model, "Symetry"); p.parametricObject.model.autobuild(); } cur_y += lineHgt + gap; cntlRect.y = cur_y; // SYMMETRY SEPERATION if (p.symmetry) { EditorGUI.BeginChangeCheck(); EditorGUIUtility.labelWidth = .5f * wid; GUI.SetNextControlName("FloatField_SymSeperation_Text_" + p.Guid + "_"); p.symSeperation = EditorGUI.FloatField(cntlRect, "Seperation", p.symSeperation); if (EditorGUI.EndChangeCheck()) { Undo.RegisterCompleteObjectUndo(p.parametricObject.model, "SymetrySeperation"); p.parametricObject.model.autobuild(); } cur_y += lineHgt + gap; cntlRect.y = cur_y; } // FLIP_X EditorGUI.BeginChangeCheck(); p.flipX = GUI.Toggle(cntlRect, p.flipX, "FlipX"); if (EditorGUI.EndChangeCheck()) { Undo.RegisterCompleteObjectUndo(p.parametricObject.model, "Flip X"); p.parametricObject.model.autobuild(); p.parametricObject.generator.adjustWorldMatrices(); } cur_y += lineHgt + gap; tRect.y = cur_y; tRect.height = 16; // SHAPE_STATE options = ArchimatixUtils.getMenuOptions("ShapeState"); EditorGUIUtility.labelWidth = .5f * wid; //-50; EditorGUI.BeginChangeCheck(); p.shapeState = (ShapeState)EditorGUI.Popup( tRect, "ShapeState", (int)p.shapeState, options); if (EditorGUI.EndChangeCheck()) { Undo.RegisterCompleteObjectUndo(p.parametricObject.model, "Shape State"); p.parametricObject.model.autobuild(); } cur_y += lineHgt + gap; cntlRect.y = cur_y; cntlRect.height = ArchimatixUtils.lineHgtSmall; // THICKNESS AXEditorUtilities.assertFloatFieldKeyCodeValidity("FloatField_Thickness"); EditorGUI.BeginChangeCheck(); GUI.SetNextControlName("FloatField_Thickness_Text_" + p.Guid + "_"); p.thickness = EditorGUI.FloatField(cntlRect, "Thickness", p.thickness); if (EditorGUI.EndChangeCheck()) { Undo.RegisterCompleteObjectUndo(p.Parent.model, "value change for Thickness"); p.thickness = Mathf.Max(p.thickness, 0); p.parametricObject.model.isAltered(2); } cur_y += ArchimatixUtils.lineHgtSmall + gap; if (p.shapeState == ShapeState.Closed) { cntlRect.y = cur_y; cntlRect.height = ArchimatixUtils.lineHgtSmall; // ROUNDNESS AXEditorUtilities.assertFloatFieldKeyCodeValidity("FloatField_Roundness"); EditorGUI.BeginChangeCheck(); GUI.SetNextControlName("FloatField_Roundness_Text_" + p.Guid + "_"); p.roundness = EditorGUI.FloatField(cntlRect, "Roundness", p.roundness); if (EditorGUI.EndChangeCheck()) { Undo.RegisterCompleteObjectUndo(p.Parent.model, "value change for Roundness"); p.parametricObject.model.isAltered(3); } cur_y += ArchimatixUtils.lineHgtSmall + gap; cntlRect.y = cur_y; cntlRect.height = ArchimatixUtils.lineHgtSmall; // OFFSET AXEditorUtilities.assertFloatFieldKeyCodeValidity("FloatField_Offset"); EditorGUI.BeginChangeCheck(); GUI.SetNextControlName("FloatField_Offset_Text_" + p.Guid + "_"); p.offset = EditorGUI.FloatField(cntlRect, "Offset", p.offset); if (EditorGUI.EndChangeCheck()) { Undo.RegisterCompleteObjectUndo(p.Parent.model, "value change for Offset"); p.parametricObject.model.isAltered(3); } cur_y += ArchimatixUtils.lineHgtSmall + gap; } if (p.thickness > 0) { if (p.shapeState == ShapeState.Closed) { // CLOSED if (p.thickness > 0) { p.endType = AXClipperLib.EndType.etClosedLine; } else { p.endType = AXClipperLib.EndType.etClosedPolygon; } } else { // OPEN switch (p.openEndType) { case AXParameter.OpenEndType.Butt: p.endType = AXClipperLib.EndType.etOpenButt; break; case AXParameter.OpenEndType.Square: p.endType = AXClipperLib.EndType.etOpenSquare; break; case AXParameter.OpenEndType.Round: p.endType = AXClipperLib.EndType.etOpenRound; break; default: p.endType = AXClipperLib.EndType.etOpenSquare; break; } } } if (p.shapeState == ShapeState.Closed) { p.drawClosed = true; } if ((p.thickness > 0) || (p.roundness != 0) || (p.offset != 0)) { p.drawClosed = true; tRect.y = cur_y; options = ArchimatixUtils.getMenuOptions("JoinType"); EditorGUIUtility.labelWidth = .5f * wid; //-50; EditorGUI.BeginChangeCheck(); p.joinType = (AXClipperLib.JoinType)EditorGUI.Popup( tRect, "JoinType", (int)p.joinType, options); if (EditorGUI.EndChangeCheck()) { Undo.RegisterCompleteObjectUndo(p.Parent.model, "value change for JoinType"); p.parametricObject.model.autobuild(); } cur_y += lineHgt + gap; if (p.joinType == AXClipperLib.JoinType.jtRound || p.endType == AXClipperLib.EndType.etOpenRound) { tRect.y = cur_y; AXEditorUtilities.assertFloatFieldKeyCodeValidity("FloatField_smoothness"); if (float.IsNaN(p.arcTolerance)) { p.arcTolerance = 50; } if (p.arcTolerance < .25f) { p.arcTolerance = .25f; } float tmp_arcTol = p.arcTolerance; float smoothness = (float)(120 / (p.arcTolerance * p.arcTolerance)); EditorGUI.BeginChangeCheck(); GUI.SetNextControlName("FloatField_smoothness_Text_" + p.Guid + "_"); smoothness = EditorGUI.FloatField(tRect, "smoothness", smoothness); if (EditorGUI.EndChangeCheck()) { smoothness = Mathf.Clamp(smoothness, .048f, 2.0f); float smoothLOD = ((smoothness - .048f) * p.parametricObject.model.segmentReductionFactor) + .048f; p.arcTolerance = (float)(Math.Sqrt(120 / smoothLOD)); if (p.arcTolerance != tmp_arcTol && p.Parent.model.readyToRegisterUndo) { //Debug.Log ("REGISTER UNDO"); float newval = p.arcTolerance; p.arcTolerance = tmp_arcTol; Undo.RegisterCompleteObjectUndo(p.Parent.model, "value change for " + p.Name); p.arcTolerance = newval; p.Parent.model.readyToRegisterUndo = false; } if (p.arcTolerance < .25f) { p.arcTolerance = .25f; } if (p.arcTolerance > 50) { p.arcTolerance = 50; } if (float.IsNaN(p.arcTolerance)) { p.arcTolerance = 50; } p.parametricObject.model.isAltered(4); } cur_y += lineHgt + gap; } } if (p.shapeState == ShapeState.Open && p.thickness > 0) { // OPEN_END_TYPE options = ArchimatixUtils.getMenuOptions("OpenEndType"); EditorGUIUtility.labelWidth = .5f * wid; //-50; tRect.y = cur_y; EditorGUI.BeginChangeCheck(); p.openEndType = (AXParameter.OpenEndType)EditorGUI.Popup( tRect, "EndType", (int)p.openEndType, options); if (EditorGUI.EndChangeCheck()) { Undo.RegisterCompleteObjectUndo(p.Parent.model, "value change for EndType"); } cur_y += lineHgt + gap; } cur_y += lineHgt / 2; // SUBDIVISION cntlRect.y = cur_y; EditorGUI.BeginChangeCheck(); GUI.SetNextControlName("FloatField_Subdivision_Text_" + p.Guid + "_"); p.subdivision = (float)EditorGUI.IntField(cntlRect, "Subdivision", (int)p.subdivision); if (EditorGUI.EndChangeCheck()) { Undo.RegisterCompleteObjectUndo(p.Parent.model, "value change for Subdivision"); if (p.subdivision < 0) { p.subdivision = 0; } p.parametricObject.model.isAltered(3); } ArchimatixUtils.cur_x -= ArchimatixUtils.indent; cur_y += 2 * lineHgt; } GUI.backgroundColor = oldBackgroundColor; return(cur_y); }
// return the height of this gui area public static void OnGUI(int win_id, AXNodeGraphEditorWindow editor, AXParametricObject po) { Event e = Event.current; AXModel model = editor.model; AXParameter p; string buttonLabel; Rect buttonRect; Color inactiveColor = new Color(.7f, .7f, .7f); Color oldBackgroundColor = GUI.backgroundColor; // START LAYOUT OF INNER PALETTE // Horizontal layput float winMargin = ArchimatixUtils.indent; float innerWidth = po.rect.width - 2 * winMargin; int x1 = 10; int x2 = 20; // vertical layut int cur_y = 25; int gap = ArchimatixUtils.gap; int lineHgt = ArchimatixUtils.lineHgt; // if (EditorGUIUtility.isProSkin) // { // GUI.color = po.generator.GUIColorPro; // GUI.backgroundColor = Color.Lerp(po.generator.GUIColorPro, Color.white, .5f) ; // } // else // { // GUI.color = po.generator.GUIColor; // GUI.backgroundColor = Color.Lerp(po.generator.GUIColor, Color.white, .5f) ; // // } // DRAW HIGHLIGHT AROUND SELECTED NODE PALETTE if (model.isSelected(po)) { float pad = (EditorGUIUtility.isProSkin) ? 1 : 1; Rect outline = new Rect(0, 0, po.rect.width - pad, po.rect.height - pad); Handles.color = Color.white; Handles.DrawSolidRectangleWithOutline(outline, new Color(1, 1, 1, 0f), ArchimatixEngine.AXGUIColors ["NodePaletteHighlightRect"]); //Handles.DrawSolidRectangleWithOutline(outline, new Color(.1f, .1f, .3f, .05f), new Color(.1f, .1f, .8f, 1f)); } // TITLE if (GUI.Button(new Rect(x1, cur_y, innerWidth - lineHgt * 2 - 6, lineHgt * 2), po.Name)) { // po.isEditing = true; // for (int i = 0; i < po.parameters.Count; i++) { // p = po.parameters [i]; // p.isEditing = false; // } po.isMini = false; } if (ArchimatixEngine.nodeIcons.ContainsKey(po.Type)) { EditorGUI.DrawTextureTransparent(new Rect(x1 + innerWidth - lineHgt * 2 - 4, cur_y, lineHgt * 2, lineHgt * 2), ArchimatixEngine.nodeIcons [po.Type], ScaleMode.ScaleToFit, 1.0F); } cur_y += lineHgt + 2 * gap; // DO THUMBNAIL / DROP_ZONE int bottomPadding = 55; int splineCanvasSize = (int)(po.rect.width - 60); editor.mostRecentThumbnailRect = new Rect(x1, cur_y + lineHgt, innerWidth, innerWidth); Rect lowerRect = new Rect(0, cur_y - 50, po.rect.width, po.rect.width); if (po.thumbnailState == ThumbnailState.Open) { //if (po.Output != null && po.Output.Type == AXParameter.DataType.Spline) if (po.is2D()) { AXParameter output_p = po.generator.getPreferredOutputParameter(); if (po.generator.hasOutputsReady()) { if (ArchimatixEngine.nodeIcons.ContainsKey("Blank")) { EditorGUI.DrawTextureTransparent(editor.mostRecentThumbnailRect, ArchimatixEngine.nodeIcons ["Blank"], ScaleMode.ScaleToFit, 1.0F); } Color color = po.thumbnailLineColor; if (color.Equals(Color.clear)) { color = Color.magenta; } GUIDrawing.DrawPathsFit(output_p, new Vector2(po.rect.width / 2, cur_y + po.rect.width / 2), po.rect.width - 60, ArchimatixEngine.AXGUIColors ["ShapeColor"]); } else if (ArchimatixEngine.nodeIcons.ContainsKey(po.Type.ToString())) { EditorGUI.DrawTextureTransparent(editor.mostRecentThumbnailRect, ArchimatixEngine.nodeIcons [po.Type], ScaleMode.ScaleToFit, 1.0F); } } else { //Debug.Log ("po.renTex.IsCreated()="+po.renTex.IsCreated()); //Debug.Log (po.renTex + " :::::::::::::::::::::::--:: if (po.generator is PrefabInstancer && po.prefab != null) { Texture2D thumber = AssetPreview.GetAssetPreview(po.prefab); if (e.type == EventType.Repaint) { if (thumber != null) { EditorGUI.DrawTextureTransparent(editor.mostRecentThumbnailRect, thumber, ScaleMode.ScaleToFit, 1.0F); } else { EditorGUI.DrawTextureTransparent(editor.mostRecentThumbnailRect, ArchimatixEngine.nodeIcons [po.Type], ScaleMode.ScaleToFit, 1.0F); } } } else if (((po.Output != null && po.Output.meshes != null && po.Output.meshes.Count > 0) || po.generator is MaterialTool) && (po.renTex != null || po.thumbnail != null)) { //if ( po.thumbnail != null ) //Debug.Log("thumb " + po.renTex); if (e.type == EventType.Repaint) { EditorGUI.DrawTextureTransparent(editor.mostRecentThumbnailRect, po.renTex, ScaleMode.ScaleToFit, 1.0F); // DROP ZONE if (po.generator is Grouper && editor.editorState == AXNodeGraphEditorWindow.EditorState.DraggingNodePalette && editor.mouseIsDownOnPO != po && po != model.currentWorkingGroupPO) { if (editor.mostRecentThumbnailRect.Contains(e.mousePosition)) { EditorGUI.DrawTextureTransparent(editor.mostRecentThumbnailRect, editor.dropZoneOverTex, ScaleMode.ScaleToFit, 1.0F); editor.OverDropZoneOfPO = po; } else { EditorGUI.DrawTextureTransparent(editor.mostRecentThumbnailRect, editor.dropZoneTex, ScaleMode.ScaleToFit, 1.0F); } } } //else // GUI.DrawTexture(editor.mostRecentThumbnailRect, po.thumbnail, ScaleMode.ScaleToFit, false, 1.0F); if (editor.mostRecentThumbnailRect.Contains(e.mousePosition) || editor.draggingThumbnailOfPO == po) { Rect orbitButtonRect = new Rect(x1 + innerWidth - 16 - 3, cur_y + lineHgt + 3, 16, 16); if (e.command || e.control) { EditorGUI.DrawTextureTransparent(orbitButtonRect, editor.dollyIconTex); } else { EditorGUI.DrawTextureTransparent(orbitButtonRect, editor.orbitIconTex); } if (e.type == EventType.MouseDown && orbitButtonRect.Contains(e.mousePosition)) { model.selectOnlyPO(po); editor.draggingThumbnailOfPO = po; e.Use(); } } } else if (ArchimatixEngine.nodeIcons.ContainsKey(po.Type.ToString())) { EditorGUI.DrawTextureTransparent(editor.mostRecentThumbnailRect, ArchimatixEngine.nodeIcons [po.Type], ScaleMode.ScaleToFit, 1.0F); // DROP ZONE if (po.generator is Grouper && editor.editorState == AXNodeGraphEditorWindow.EditorState.DraggingNodePalette && editor.mouseIsDownOnPO != po && po != model.currentWorkingGroupPO) { if (editor.mostRecentThumbnailRect.Contains(e.mousePosition)) { EditorGUI.DrawTextureTransparent(editor.mostRecentThumbnailRect, editor.dropZoneOverTex, ScaleMode.ScaleToFit, 1.0F); editor.OverDropZoneOfPO = po; } else { EditorGUI.DrawTextureTransparent(editor.mostRecentThumbnailRect, editor.dropZoneTex, ScaleMode.ScaleToFit, 1.0F); } } } } cur_y += lineHgt + bottomPadding + splineCanvasSize + gap; po.rect.height = cur_y; cur_y += 4 * gap; } else { // no thumbnail cur_y += 2 * lineHgt; po.rect.height = cur_y; } // INLETS // INPUT ITEMS // Parameter Lines //for (int i=0; i<po.parameters.Count; i++) { if ((po.inputControls != null && po.inputControls.children != null)) { for (int i = 0; i < po.inputControls.children.Count; i++) { p = (AXParameter)po.inputControls.children [i]; if (p.PType != AXParameter.ParameterType.Input) { continue; } //if ( p.DependsOn != null && !p.DependsOn.Parent.isOpen && ! p.Name.Contains ("External")) // continue; //if (parametricObjects_Property != null) if (model.parametricObjects != null) { // these points are world, not rlative to the this GUIWindow p.inputPoint = new Vector2(po.rect.x, po.rect.y + 100); p.outputPoint = new Vector2(po.rect.x + po.rect.width, po.rect.y + cur_y + lineHgt / 2); } } } // OUTLETS if (po.outputsNode != null) { for (int i = 0; i < po.outputsNode.children.Count; i++) { p = (AXParameter)po.outputsNode.children [i]; if (p == null) { continue; } //if (p.hasInputSocket || ! p.hasOutputSocket) if (p.PType != AXParameter.ParameterType.Output) { continue; } //if (parametricObjects_Property != null) if (model.parametricObjects != null) { // these points are world, not relative to the this GUIWindow p.inputPoint = new Vector2(po.rect.x, po.rect.y + cur_y + lineHgt / 2); p.outputPoint = new Vector2(po.rect.x + po.rect.width, po.rect.y + po.rect.width); Rect pRect = new Rect(x1, cur_y, innerWidth, lineHgt); //if (parameters_Property.arraySize > i) if (po.parameters != null && po.parameters.Count > i) { int hgt = 0; if (po.is2D()) { hgt = ParameterSplineGUI.OnGUI_Spline(pRect, editor, p); cur_y = hgt + gap; } else { //hgt = ParameterGUI.OnGUI (pRect, editor, p); //cur_y += hgt + gap; Color dataColor = editor.getDataColor(p.Type); // PERSONAL if (!EditorGUIUtility.isProSkin) { dataColor = new Color(dataColor.r, dataColor.b, dataColor.g, .3f); } GUI.color = dataColor; buttonLabel = (editor.OutputParameterBeingDragged == p) ? "-" : ""; buttonRect = new Rect(p.Parent.rect.width - pRect.height - 10, p.Parent.rect.width - 10, 2 * ArchimatixEngine.buttonSize, 2 * 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; } } if (GUI.Button(buttonRect, buttonLabel)) { if (editor.InputParameterBeingDragged != null && editor.InputParameterBeingDragged.Type != p.Type) { editor.InputParameterBeingDragged = null; } else { editor.outputSocketClicked(p); } } } } } } } // FOOTER // // STATS if (po.stats_VertCount > 0 || po.generator is MaterialTool) { string statsText; if (po.generator is MaterialTool) { statsText = (po.generator as MaterialTool).texelsPerUnit.ToString("F0") + " Texels/Unit"; } else { statsText = po.stats_VertCount + " verts"; if (po.stats_TriangleCount > 0) { statsText += ", " + po.stats_TriangleCount + " tris"; } } GUIStyle statlabelStyle = GUI.skin.GetStyle("Label"); TextAnchor prevStatTextAlignment = statlabelStyle.alignment; statlabelStyle.alignment = TextAnchor.MiddleLeft; EditorGUIUtility.labelWidth = 500; GUI.Label(new Rect(10, po.rect.height - x2 + 2, 500, lineHgt), statsText); statlabelStyle.alignment = prevStatTextAlignment; } if (e.type == EventType.MouseDown && lowerRect.Contains(e.mousePosition)) { editor.clearFocus(); GUI.FocusWindow(po.guiWindowId); } // WINDOW RESIZE buttonRect = new Rect(po.rect.width - 16, po.rect.height - 17, 14, 14); if (e.type == EventType.MouseDown && buttonRect.Contains(e.mousePosition)) { Undo.RegisterCompleteObjectUndo(model, "GUI Window Resize"); editor.editorState = AXNodeGraphEditorWindow.EditorState.DragResizingNodePalleteWindow; editor.DraggingParameticObject = po; } //GUI.Button ( buttonRect, "∆", GUIStyle.none); GUI.Button(buttonRect, editor.resizeCornerTexture, GUIStyle.none); if (e.type == EventType.MouseDown && buttonRect.Contains(e.mousePosition)) { } //cur_y += lineHgt + gap; // Window title bar is the dragable area //GUI.DragWindow(headerRect); if (editor.draggingThumbnailOfPO == null || editor.draggingThumbnailOfPO != po) { GUI.DragWindow(); } }
// return the height of this gui area public static void OnGUI(Rect headerRect, AXNodeGraphEditorWindow editor) { Event e = Event.current; AXModel model = editor.model; // DO HEADER MENU BAR -- MODEL MENU GUILayout.BeginArea(headerRect); GUILayout.BeginHorizontal(); GUIStyle labelstyle = new GUIStyle(GUI.skin.label); labelstyle.alignment = TextAnchor.LowerLeft; labelstyle.fixedWidth = 150; GUILayout.Space(5); if (GUILayout.Button("2D")) { ArchimatixEngine.openLibrary2D(); } if (GUILayout.Button("3D")) { ArchimatixEngine.openLibrary3D(); } // NEW MODEL GUILayout.Space(10); if (GUILayout.Button("▼")) { AXModel[] allModels = ArchimatixUtils.getAllModels(); GenericMenu menu = new GenericMenu(); //menu.AddSeparator("Library ..."); if (allModels != null && allModels.Length > 0) { for (int i = 0; i < allModels.Length; i++) { AXModel m = allModels [i]; menu.AddItem(new GUIContent(m.gameObject.name), false, () => { Selection.activeGameObject = m.gameObject; ArchimatixEngine.currentModel = m; }); } } menu.AddSeparator(""); menu.AddItem(new GUIContent("New Model"), false, () => { AXEditorUtilities.createNewModel(); }); menu.ShowAsContext(); } Color bgc = GUI.backgroundColor; GUI.backgroundColor = Color.clear; if (model != null) { // SELECTED MODEL if (GUILayout.Button(model.name)) { model.currentWorkingGroupPO = null; model.selectAllVisibleInGroup(null); float framePadding = 50; Rect allRect = AXUtilities.getBoundaryRectFromPOs(model.selectedPOs); allRect.x -= framePadding; allRect.y -= framePadding; allRect.width += framePadding * 2; allRect.height += framePadding * 2; AXNodeGraphEditorWindow.zoomToRectIfOpen(allRect); } if (model.currentWorkingGroupPO != null) { if (model.currentWorkingGroupPO.grouper != null) { // Make breadcrumb trail List <AXParametricObject> crumbs = new List <AXParametricObject>(); AXParametricObject cursor = model.currentWorkingGroupPO; while (cursor.grouper != null) { crumbs.Add(cursor.grouper); cursor = cursor.grouper; } crumbs.Reverse(); // model button frames for (int i = 0; i < crumbs.Count; i++) { if (GUILayout.Button("> " + crumbs[i].Name)) { model.currentWorkingGroupPO = crumbs[i]; Rect grouperCanvasRect = model.currentWorkingGroupPO.getBoundsRect(); editor.zoomToRect(grouperCanvasRect); } } } GUILayout.Button("> " + model.currentWorkingGroupPO.Name); } } GUILayout.FlexibleSpace(); if (model != null) { Color buildBG = Color.Lerp(Color.cyan, Color.white, .8f); string buildLabel = "Rebuild"; if (model.buildStatus == AXModel.BuildStatus.Generated) { buildBG = Color.red; buildLabel = "Build"; } GUI.backgroundColor = buildBG; if (GUILayout.Button(buildLabel)) { model.build(); } GUI.backgroundColor = Color.cyan; if (model.generatedGameObjects != null && model.generatedGameObjects.transform.childCount == 0) { GUI.enabled = false; } if (GUILayout.Button("Stamp")) { model.stamp(); } if (GUILayout.Button("Prefab")) { string startDir = Application.dataPath; string path = EditorUtility.SaveFilePanel( "Save Prefab", startDir, ("" + model.name), "prefab"); if (!string.IsNullOrEmpty(path)) { AXPrefabWindow.makePrefab(model, path, editor); } } GUI.enabled = true; GUILayout.Space(4); } GUILayout.EndHorizontal(); GUILayout.EndArea(); GUI.backgroundColor = bgc; }
} // \OnScenView public override int customNodeGUIZone_4(int cur_y, AXNodeGraphEditorWindow editor, AXParametricObject po, float x = 0, float w = 150) { float cur_x = ArchimatixUtils.cur_x; Rect pRect = new Rect(x, cur_y, w, 16); //float box_w = ArchimatixUtils.paletteRect.width - cur_x - 3*ArchimatixUtils.indent; float box_w = pRect.width - cur_x - 1 * ArchimatixUtils.indent; int lineHgt = (int)pRect.height; //int gap = 5; //int margin = 24; //float wid = pRect.width-margin; // LABEL Rect boxRect = new Rect(cur_x + ArchimatixUtils.indent + 3, cur_y, box_w, pRect.height); Rect lRect = boxRect; lRect.x += 3; lRect.width -= 10; lRect.y = cur_y; GUI.Label(lRect, "Curve Points: " + po.curve.Count); cur_y += 16; GUIStyle labelStyle = new GUIStyle(GUI.skin.GetStyle("Label")); labelStyle.fixedWidth = 150; float origLabelWidth = EditorGUIUtility.labelWidth; EditorGUIUtility.labelWidth = 10; for (int i = 0; i < po.curve.Count; i++) { lRect.y = cur_y; GUILayout.BeginArea(lRect); EditorGUILayout.BeginHorizontal(); GUILayout.Label("[" + i + "] ", GUILayout.MaxWidth(15)); EditorGUI.BeginChangeCheck(); po.curve[i].position.x = EditorGUILayout.FloatField("X", po.curve[i].position.x, GUILayout.MinWidth(50)); if (EditorGUI.EndChangeCheck()) { po.model.isAltered(); } //GUILayout.Label( "Y ", GUILayout.MaxWidth(12)); EditorGUI.BeginChangeCheck(); po.curve[i].position.y = EditorGUILayout.FloatField("Y ", po.curve[i].position.y, GUILayout.MinWidth(50)); if (EditorGUI.EndChangeCheck()) { po.model.isAltered(); } //GUI.Label(new Rect, "["+i+"] X:" ); //+ po.curve[i].position EditorGUILayout.EndHorizontal(); GUILayout.EndArea(); cur_y += 16; } cur_y += 16; EditorGUIUtility.labelWidth = origLabelWidth; return(cur_y); }
// Maintain a AXHandle.GUID // and any other runtime preferences public static void OnGUI(AXHandleRuntimeAlias rth) { AXHandle handle = rth.handle; if (handle == null) { return; } //Event e = Event.current; GUILayout.BeginHorizontal(); // FOLDOUT GUIStyle toggleStyle = new GUIStyle(EditorStyles.foldout); toggleStyle.fixedWidth = 50; rth.isEditing = EditorGUILayout.Foldout(rth.isEditing, GUIContent.none); //Debug.Log(pa.isEditing); // SLIDER AND NUMBER FIELD GUIStyle textfieldStyle = new GUIStyle(GUI.skin.textField); textfieldStyle.fixedWidth = 150; GUIStyle labelWrap = new GUIStyle(GUI.skin.label); labelWrap.stretchWidth = true; labelWrap.wordWrap = true; labelWrap.fontSize = 9; labelWrap.fixedWidth = 150; if (rth.isEditing) { GUILayout.BeginVertical(); rth.alias = GUILayout.TextField(rth.alias, textfieldStyle); GUILayout.Label("You can edit the alias without altering the source handle.", labelWrap); GUILayout.Label("Actual: ", labelWrap); if (GUILayout.Button(handle.parametricObject.Name + "." + handle.Name)) { handle.parametricObject.model.selectPO(handle.parametricObject); //handle.ParentNode.isOpen = true; float framePadding = 200; Rect allRect = AXUtilities.getBoundaryRectFromPOs(handle.parametricObject.model.selectedPOs); allRect.x -= framePadding; allRect.y -= framePadding; allRect.width += framePadding * 2; allRect.height += framePadding * 2; AXNodeGraphEditorWindow.zoomToRectIfOpen(allRect); } GUILayout.Space(15); GUILayout.EndVertical(); } else { GUILayout.Label(rth.alias); } GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); } // OnGUI()
public static int OnGUI(Rect pRect, AXNodeGraphEditorWindow editor, AXShape shp) { Color shapeColor = editor.getDataColor(AXParameter.DataType.Spline); Color origBG = GUI.backgroundColor; //Rect pRect = new Rect(x1+12, cur_y, width-20,lineHgt); float cur_x = ArchimatixUtils.cur_x; //float box_x = cur_x + ArchimatixUtils.indent; float box_w = ArchimatixUtils.paletteRect.width - cur_x - 3 * ArchimatixUtils.indent; int x1 = (int)pRect.x - ArchimatixUtils.indent; int cur_y = (int)pRect.y; int width = (int)pRect.width; int lineHgt = ArchimatixUtils.lineHgt; int gap = 5; Rect boxRect = pRect; boxRect = new Rect(cur_x + ArchimatixUtils.indent, cur_y, box_w, ArchimatixUtils.lineHgt); Rect lRect = new Rect(x1 + 11, cur_y, 50, lineHgt); if (!shp.isOpen && shp.inputs != null) { foreach (AXParameter sp in shp.inputs) { sp.inputPoint = new Vector2(ArchimatixUtils.paletteRect.x, ArchimatixUtils.paletteRect.y + cur_y + lineHgt / 2); sp.outputPoint = new Vector2(ArchimatixUtils.paletteRect.x + ArchimatixUtils.paletteRect.width, ArchimatixUtils.paletteRect.y + cur_y + lineHgt / 2); } } // Header //EditorGUI.BeginChangeCheck(); //GUI.Button(pRect, Name); GUI.color = Color.white; GUI.backgroundColor = shapeColor; // shp.isOpen = true; if (shp.isOpen) { /* INPUTS */ GUIStyle labelstyle = GUI.skin.GetStyle("Label"); labelstyle.alignment = TextAnchor.MiddleLeft; labelstyle.fixedWidth = 100; labelstyle.fontSize = 12; //Rect boxRect = new Rect (x1 + 22, cur_y, width - 38, lineHgt); //Rect editRect = new Rect (x1 + 22, cur_y, width - 38, lineHgt); //Archimatix.cur_x += Archimatix.indent; // INPUT SHAPE PARAMETERS for (int i = 0; i < shp.inputs.Count; i++) { AXParameter sp = shp.inputs [i]; sp.inputPoint = new Vector2(ArchimatixUtils.paletteRect.x, ArchimatixUtils.paletteRect.y + cur_y + lineHgt / 2); sp.outputPoint = new Vector2(ArchimatixUtils.paletteRect.x + ArchimatixUtils.paletteRect.width, ArchimatixUtils.paletteRect.y + cur_y + lineHgt / 2); cur_y = ParameterSplineGUI.OnGUI_Spline(new Rect(x1, cur_y, width, lineHgt), editor, sp); } //Archimatix.cur_x -= Archimatix.indent; // Empty / New SHAPE PARAMETER if (editor.OutputParameterBeingDragged != null && editor.OutputParameterBeingDragged.Type != AXParameter.DataType.Spline) { GUI.enabled = false; } if (GUI.Button(new Rect(-3, cur_y, lineHgt, lineHgt), "")) { //Debug.Log ("make shape 2"); AXParameter new_p = shp.addInput(); editor.inputSocketClicked(new_p); editor.OutputParameterBeingDragged = null; } GUI.enabled = true; boxRect = new Rect(x1 + 11, cur_y, width - 38, lineHgt); GUI.Box(boxRect, " "); GUI.Box(boxRect, " "); //boxRect.x += 10; GUI.Label(boxRect, "Empty Shape"); cur_y += lineHgt + gap; //cur_y += 2*gap; //Rect bRect = boxRect; lRect.y = cur_y; /* SPECIFIC OUTPUT PARAMETERS */ //lRect.y = cur_y; //GUI.Label(lRect, "Output Combinations"); cur_y += gap; //Archimatix.cur_x += Archimatix.indent; GUI.color = Color.white; GUI.backgroundColor = Color.white; //Rect foldRect = new Rect(ArchimatixUtils.indent*2, cur_y, 30,lineHgt); //outputParametersOpen = EditorGUI.Foldout(foldRect, outputParametersOpen, "Merge Results"); /* * if (false && shp.outputParametersOpen) * { * cur_y += lineHgt; * ArchimatixUtils.cur_x += ArchimatixUtils.indent; * * bool tmp_boolval; * bRect.x = ArchimatixUtils.indent*3+4;//width-lineHgt; * * * // difference * shp.difference.inputPoint = new Vector2 (ArchimatixUtils.paletteRect.x, ArchimatixUtils.paletteRect.y + cur_y + lineHgt / 2); * shp.difference.outputPoint = new Vector2 (ArchimatixUtils.paletteRect.x + ArchimatixUtils.paletteRect.width, ArchimatixUtils.paletteRect.y + cur_y + lineHgt / 2); * bRect.y = cur_y-2; * lRect.y = cur_y; * * cur_y = ParameterSplineGUI.OnGUI_Spline(new Rect(x1, cur_y, width,lineHgt), editor, shp.difference); * * tmp_boolval = (shp.combineType == AXShape.CombineType.Difference); * EditorGUI.BeginChangeCheck (); * tmp_boolval = EditorGUI.Toggle (bRect, "", tmp_boolval); * if (EditorGUI.EndChangeCheck ()) { * Undo.RegisterCompleteObjectUndo (shp.Parent.model, "value change for combineType" ); * shp.combineType = AXShape.CombineType.Difference; * shp.parametricObject.model.autobuild(); * } * * // difference * shp.differenceRail.inputPoint = new Vector2 (ArchimatixUtils.paletteRect.x, ArchimatixUtils.paletteRect.y + cur_y + lineHgt / 2); * shp.differenceRail.outputPoint = new Vector2 (ArchimatixUtils.paletteRect.x + ArchimatixUtils.paletteRect.width, ArchimatixUtils.paletteRect.y + cur_y + lineHgt / 2); * * bRect.y = cur_y-2; * * cur_y = ParameterSplineGUI.OnGUI_Spline(new Rect(x1, cur_y, width, lineHgt), editor, shp.differenceRail); * * tmp_boolval = (shp.combineType == AXShape.CombineType.DifferenceRail); * EditorGUI.BeginChangeCheck (); * tmp_boolval = EditorGUI.Toggle (bRect, "", tmp_boolval); * if (EditorGUI.EndChangeCheck ()) { * Undo.RegisterCompleteObjectUndo (shp.Parent.model, "value change for combineType" ); * shp.combineType = AXShape.CombineType.DifferenceRail; * shp.parametricObject.model.autobuild(); * } * * cur_y += gap; * * * * // INTERSECTION * shp.intersection.inputPoint = new Vector2 (ArchimatixUtils.paletteRect.x, ArchimatixUtils.paletteRect.y + cur_y + lineHgt / 2); * shp.intersection.outputPoint = new Vector2 (ArchimatixUtils.paletteRect.x + ArchimatixUtils.paletteRect.width, ArchimatixUtils.paletteRect.y + cur_y + lineHgt / 2); * bRect.y = cur_y-2; * * cur_y = ParameterSplineGUI.OnGUI_Spline(new Rect(x1, cur_y, width, lineHgt), editor, shp.intersection); * * tmp_boolval = (shp.combineType == AXShape.CombineType.Intersection); * EditorGUI.BeginChangeCheck (); * tmp_boolval = EditorGUI.Toggle (bRect, "", tmp_boolval); * if (EditorGUI.EndChangeCheck ()) { * Undo.RegisterCompleteObjectUndo (shp.Parent.model, "value change for combineType" ); * Debug.Log("YA"); * shp.combineType = AXShape.CombineType.Intersection; * shp.parametricObject.model.autobuild(); * } * * * // INTERSECTION_RAIL * shp.intersectionRail.inputPoint = new Vector2 (ArchimatixUtils.paletteRect.x, ArchimatixUtils.paletteRect.y + cur_y + lineHgt / 2); * shp.intersectionRail.outputPoint = new Vector2 (ArchimatixUtils.paletteRect.x + ArchimatixUtils.paletteRect.width, ArchimatixUtils.paletteRect.y + cur_y + lineHgt / 2); * bRect.y = cur_y-2; * * cur_y = ParameterSplineGUI.OnGUI_Spline(new Rect(x1, cur_y, width, lineHgt), editor, shp.intersectionRail); * * tmp_boolval = (shp.combineType == AXShape.CombineType.IntersectionRail); * EditorGUI.BeginChangeCheck (); * tmp_boolval = EditorGUI.Toggle (bRect, "", tmp_boolval); * if (EditorGUI.EndChangeCheck ()) { * Undo.RegisterCompleteObjectUndo (shp.Parent.model, "value change for combineType" ); * shp.combineType = AXShape.CombineType.IntersectionRail; * shp.parametricObject.model.autobuild(); * } * * cur_y += gap; * * * * // union * shp.union.inputPoint = new Vector2 (ArchimatixUtils.paletteRect.x, ArchimatixUtils.paletteRect.y + cur_y + lineHgt / 2); * shp.union.outputPoint = new Vector2 (ArchimatixUtils.paletteRect.x + ArchimatixUtils.paletteRect.width, ArchimatixUtils.paletteRect.y + cur_y + lineHgt / 2); * bRect.y = cur_y-2; * * cur_y = ParameterSplineGUI.OnGUI_Spline(new Rect(x1, cur_y, width, lineHgt), editor, shp.union); * * tmp_boolval = (shp.combineType == AXShape.CombineType.Union); * EditorGUI.BeginChangeCheck (); * tmp_boolval = EditorGUI.Toggle (bRect, "", tmp_boolval); * if (EditorGUI.EndChangeCheck ()) { * Undo.RegisterCompleteObjectUndo (shp.Parent.model, "value change for combineType" ); * shp.combineType = AXShape.CombineType.Union; * shp.parametricObject.model.autobuild(); * } * * cur_y += gap; * * * * // grouped * if (shp.grouped == null || shp.grouped.Type == AXParameter.DataType.Float) * shp.grouped = shp.createSplineParameter(AXParameter.ParameterType.Output, "Grouped"); * * shp.grouped.inputPoint = new Vector2 (ArchimatixUtils.paletteRect.x, ArchimatixUtils.paletteRect.y + cur_y + lineHgt / 2); * shp.grouped.outputPoint = new Vector2 (ArchimatixUtils.paletteRect.x + ArchimatixUtils.paletteRect.width, ArchimatixUtils.paletteRect.y + cur_y + lineHgt / 2); * bRect.y = cur_y-2; * * cur_y = ParameterSplineGUI.OnGUI_Spline(new Rect(x1, cur_y, width, lineHgt), editor, shp.grouped); * * tmp_boolval = (shp.combineType == AXShape.CombineType.Grouped); * EditorGUI.BeginChangeCheck (); * tmp_boolval = EditorGUI.Toggle (bRect, "", tmp_boolval); * if (EditorGUI.EndChangeCheck ()) { * Undo.RegisterCompleteObjectUndo (shp.Parent.model, "value change for combineType" ); * shp.combineType = AXShape.CombineType.Grouped; * shp.parametricObject.model.autobuild(); * } * * * * * ArchimatixUtils.cur_x -= ArchimatixUtils.indent; * * * } */ //Archimatix.cur_x -= Archimatix.indent; //cur_y += lineHgt; } GUI.backgroundColor = origBG; return(cur_y); } // OnGUI
} // OnGUI public static int displayOutput(Rect pRect, AXNodeGraphEditorWindow editor, AXShape shp) { float cur_x = ArchimatixUtils.cur_x; //float box_x = cur_x + ArchimatixUtils.indent; float box_w = ArchimatixUtils.paletteRect.width - cur_x - 3 * ArchimatixUtils.indent; int x1 = (int)pRect.x - ArchimatixUtils.indent; int cur_y = (int)pRect.y; int width = (int)pRect.width; int lineHgt = ArchimatixUtils.lineHgt; int gap = 5; Rect boxRect = pRect; boxRect = new Rect(cur_x + ArchimatixUtils.indent, cur_y, box_w, ArchimatixUtils.lineHgt); Rect lRect = new Rect(x1 + 11, cur_y, 50, lineHgt); Rect bRect = boxRect; lRect.y = cur_y; //cur_y += lineHgt; ArchimatixUtils.cur_x += ArchimatixUtils.indent; bool tmp_boolval; bRect.x = ArchimatixUtils.indent * 3 + 4; //width-lineHgt; // difference shp.difference.inputPoint = new Vector2(ArchimatixUtils.paletteRect.x, ArchimatixUtils.paletteRect.y + cur_y + lineHgt / 2); shp.difference.outputPoint = new Vector2(ArchimatixUtils.paletteRect.x + ArchimatixUtils.paletteRect.width, ArchimatixUtils.paletteRect.y + cur_y + lineHgt / 2); bRect.y = cur_y - 1; lRect.y = cur_y; cur_y = ParameterSplineGUI.OnGUI_Spline(new Rect(x1, cur_y, width, lineHgt), editor, shp.difference); tmp_boolval = (shp.combineType == AXShape.CombineType.Difference); EditorGUI.BeginChangeCheck(); tmp_boolval = EditorGUI.Toggle(bRect, "", tmp_boolval); if (EditorGUI.EndChangeCheck()) { Undo.RegisterCompleteObjectUndo(shp.Parent.model, "value change for combineType"); shp.combineType = AXShape.CombineType.Difference; shp.parametricObject.model.generate(); } // difference shp.differenceRail.inputPoint = new Vector2(ArchimatixUtils.paletteRect.x, ArchimatixUtils.paletteRect.y + cur_y + lineHgt / 2); shp.differenceRail.outputPoint = new Vector2(ArchimatixUtils.paletteRect.x + ArchimatixUtils.paletteRect.width, ArchimatixUtils.paletteRect.y + cur_y + lineHgt / 2); bRect.y = cur_y - 1; cur_y = ParameterSplineGUI.OnGUI_Spline(new Rect(x1, cur_y, width, lineHgt), editor, shp.differenceRail); tmp_boolval = (shp.combineType == AXShape.CombineType.DifferenceRail); EditorGUI.BeginChangeCheck(); tmp_boolval = EditorGUI.Toggle(bRect, "", tmp_boolval); if (EditorGUI.EndChangeCheck()) { Undo.RegisterCompleteObjectUndo(shp.Parent.model, "value change for combineType"); shp.combineType = AXShape.CombineType.DifferenceRail; shp.parametricObject.model.generate(); } cur_y += gap; // INTERSECTION shp.intersection.inputPoint = new Vector2(ArchimatixUtils.paletteRect.x, ArchimatixUtils.paletteRect.y + cur_y + lineHgt / 2); shp.intersection.outputPoint = new Vector2(ArchimatixUtils.paletteRect.x + ArchimatixUtils.paletteRect.width, ArchimatixUtils.paletteRect.y + cur_y + lineHgt / 2); bRect.y = cur_y - 1; cur_y = ParameterSplineGUI.OnGUI_Spline(new Rect(x1, cur_y, width, lineHgt), editor, shp.intersection); tmp_boolval = (shp.combineType == AXShape.CombineType.Intersection); EditorGUI.BeginChangeCheck(); tmp_boolval = EditorGUI.Toggle(bRect, "", tmp_boolval); if (EditorGUI.EndChangeCheck()) { Undo.RegisterCompleteObjectUndo(shp.Parent.model, "value change for combineType"); shp.combineType = AXShape.CombineType.Intersection; shp.parametricObject.model.generate(); } // INTERSECTION_RAIL shp.intersectionRail.inputPoint = new Vector2(ArchimatixUtils.paletteRect.x, ArchimatixUtils.paletteRect.y + cur_y + lineHgt / 2); shp.intersectionRail.outputPoint = new Vector2(ArchimatixUtils.paletteRect.x + ArchimatixUtils.paletteRect.width, ArchimatixUtils.paletteRect.y + cur_y + lineHgt / 2); bRect.y = cur_y - 1; cur_y = ParameterSplineGUI.OnGUI_Spline(new Rect(x1, cur_y, width, lineHgt), editor, shp.intersectionRail); tmp_boolval = (shp.combineType == AXShape.CombineType.IntersectionRail); EditorGUI.BeginChangeCheck(); tmp_boolval = EditorGUI.Toggle(bRect, "", tmp_boolval); if (EditorGUI.EndChangeCheck()) { Undo.RegisterCompleteObjectUndo(shp.Parent.model, "value change for combineType"); shp.combineType = AXShape.CombineType.IntersectionRail; shp.parametricObject.model.generate(); } cur_y += gap; // union shp.union.inputPoint = new Vector2(ArchimatixUtils.paletteRect.x, ArchimatixUtils.paletteRect.y + cur_y + lineHgt / 2); shp.union.outputPoint = new Vector2(ArchimatixUtils.paletteRect.x + ArchimatixUtils.paletteRect.width, ArchimatixUtils.paletteRect.y + cur_y + lineHgt / 2); bRect.y = cur_y - 1; cur_y = ParameterSplineGUI.OnGUI_Spline(new Rect(x1, cur_y, width, lineHgt), editor, shp.union); tmp_boolval = (shp.combineType == AXShape.CombineType.Union); EditorGUI.BeginChangeCheck(); tmp_boolval = EditorGUI.Toggle(bRect, "", tmp_boolval); if (EditorGUI.EndChangeCheck()) { Undo.RegisterCompleteObjectUndo(shp.Parent.model, "value change for combineType"); shp.combineType = AXShape.CombineType.Union; shp.parametricObject.model.generate(); } cur_y += gap; // grouped if (shp.grouped == null || shp.grouped.Type == AXParameter.DataType.Float) { shp.grouped = shp.createSplineParameter(AXParameter.ParameterType.Output, "Grouped"); } shp.grouped.inputPoint = new Vector2(ArchimatixUtils.paletteRect.x, ArchimatixUtils.paletteRect.y + cur_y + lineHgt / 2); shp.grouped.outputPoint = new Vector2(ArchimatixUtils.paletteRect.x + ArchimatixUtils.paletteRect.width, ArchimatixUtils.paletteRect.y + cur_y + lineHgt / 2); bRect.y = cur_y - 1; cur_y = ParameterSplineGUI.OnGUI_Spline(new Rect(x1, cur_y, width, lineHgt), editor, shp.grouped); tmp_boolval = (shp.combineType == AXShape.CombineType.Grouped); EditorGUI.BeginChangeCheck(); tmp_boolval = EditorGUI.Toggle(bRect, "", tmp_boolval); if (EditorGUI.EndChangeCheck()) { Undo.RegisterCompleteObjectUndo(shp.Parent.model, "value change for combineType"); shp.combineType = AXShape.CombineType.Grouped; shp.parametricObject.model.generate(); } ArchimatixUtils.cur_x -= ArchimatixUtils.indent; //Archimatix.cur_x -= Archimatix.indent; cur_y += lineHgt * 2; return(cur_y); }
public void display(float imagesize = 64, AXNodeGraphEditorWindow editor = null, string mode = "2D") // mode { //Debug.Log("imagesise="+imagesize); // called from an OnGUI //imagesize = 64; Event e = Event.current; scrollPosition = EditorGUILayout.BeginScrollView(scrollPosition, GUIStyle.none, GUIStyle.none); //StopWatch sw = new StopWatch(); EditorGUILayout.BeginVertical(); if (mode == "2D") { if (ArchimatixEngine.library != null && ArchimatixEngine.library.filteredResults != null) { // EACH 2D ITEM for (int i = 0; i < ArchimatixEngine.library.filteredResults.Count; i++) { // ** THE BIG CLICK 2D LibraryItem li = ArchimatixEngine.library.filteredResults [i]; if (!li.includeInSidebarMenu) { continue; } if (!li.is2D) { continue; } if (GUILayout.Button(new GUIContent(li.icon, li.Name), GUILayout.Width(imagesize), GUILayout.Height(imagesize))) { e.Use(); AXParametricObject prevSelectedPO = null; if (ArchimatixEngine.currentModel != null && ArchimatixEngine.currentModel.selectedPOs != null && ArchimatixEngine.currentModel.selectedPOs.Count > 0) { //foreach(AXParametricObject poo in ArchimatixEngine.currentModel.selectedPOs) // Debug.Log(" --- " + poo.Name); prevSelectedPO = ArchimatixEngine.currentModel.selectedPOs [ArchimatixEngine.currentModel.selectedPOs.Count - 1]; ArchimatixEngine.currentModel.deselectAll(); } AXParametricObject npo = Library.instantiateParametricObject(li.readIntoLibraryFromRelativeAXOBJPath); npo.generator.pollInputParmetersAndSetUpLocalReferences(); if (prevSelectedPO != null) { // AUTO-CONNECT TO A SELECTED SHAPE_MERGER ShapeMerger shapeMerger = null; Rect rect = new Rect(); if (prevSelectedPO != null && prevSelectedPO.generator is ShapeMerger) { shapeMerger = prevSelectedPO.generator as ShapeMerger; rect = new Rect(prevSelectedPO.rect.x - 300, prevSelectedPO.rect.y, prevSelectedPO.rect.width, prevSelectedPO.rect.height); } if (shapeMerger == null && prevSelectedPO.generator.P_Output != null) { foreach (AXParameter d in prevSelectedPO.generator.P_Output.Dependents) { if (d.parametricObject.generator is ShapeMerger) { shapeMerger = d.parametricObject.generator as ShapeMerger; rect = new Rect(prevSelectedPO.rect.x + 50, prevSelectedPO.rect.y + 50, prevSelectedPO.rect.width, prevSelectedPO.rect.height); break; } } } if (shapeMerger != null) { shapeMerger.connect(npo); npo.rect = rect; npo.generator.pollInputParmetersAndSetUpLocalReferences(); shapeMerger.pollInputParmetersAndSetUpLocalReferences(); ArchimatixEngine.currentModel.autobuild(); shapeMerger.adjustWorldMatrices(); npo.generator.adjustWorldMatrices(); //AXNodeGraphEditorWindow.zoomToRectIfOpen(npo.rect); } } if (npo != null) { if (npo.rect.width < npo.generator.minNodePaletteWidth) { npo.rect.width = npo.generator.minNodePaletteWidth; } } //Selection.activeGameObject = null; } } } } else { // 3D Library if (ArchimatixEngine.library != null && ArchimatixEngine.library.filteredResults != null) { for (int i = 0; i < ArchimatixEngine.library.filteredResults.Count; i++) { // THE BIG CLICK 3D !!!! LibraryItem li = ArchimatixEngine.library.filteredResults [i]; if (!li.includeInSidebarMenu) { continue; } if (li.is2D) { continue; } if (GUILayout.Button(new GUIContent(li.icon, li.Name), GUILayout.Width(imagesize), GUILayout.Height(imagesize))) { Library.instantiateParametricObject(li.readIntoLibraryFromRelativeAXOBJPath); //Selection.activeGameObject = null; } } } } EditorGUILayout.Space(); EditorGUILayout.EndVertical(); //Debug.Log(sw.stop()); EditorGUILayout.EndScrollView(); /* Not sure why I was doing this - it took up a huge amount of CPU! * * editor.Repaint(); * SceneView sv = SceneView.lastActiveSceneView; * if (sv != null) * sv.Repaint(); * */ }
public static int GeometryControlsOnGUI(int cur_y, AXNodeGraphEditorWindow editor, AXParametricObject po) { int gap = ArchimatixUtils.gap; int lineHgt = ArchimatixUtils.lineHgt; float x1 = 10; float x2 = 20; float winMargin = ArchimatixUtils.indent; float innerWidth = po.rect.width - 2 * winMargin; AXParameter p = null; // Geometry (and other) controllers if (po.geometryControls != null && po.geometryControls.children != null) { for (int i = 0; i < po.geometryControls.children.Count; i++) { p = po.geometryControls.children[i] as AXParameter; if (p.PType != AXParameter.ParameterType.None && p.PType != AXParameter.ParameterType.GeometryControl) { continue; } // these points are world, not relative to the this GUIWindow p.inputPoint = new Vector2(po.rect.x, po.rect.y + cur_y + lineHgt / 2); p.outputPoint = new Vector2(po.rect.x + po.rect.width, po.rect.y + cur_y + lineHgt / 2); Rect pRect = new Rect(x1, cur_y, innerWidth, lineHgt); try { int hgt = ParameterGUI.OnGUI(pRect, editor, p); cur_y += hgt + gap; } catch { } } } if (po.is2D() || po.generator is Grouper) { if (GUI.Button(new Rect(x2, cur_y, lineHgt * 1.25f, lineHgt), new GUIContent("+", "Create a new Control Parameter"))) { Undo.RegisterCompleteObjectUndo(po.model, "New AXParameter"); AXParameter tmpP = po.addParameter(new AXParameter()); foreach (AXParameter pop in po.parameters) { if (pop != p) { pop.isOpen = false; } } po.model.indexedParameters.Add(tmpP.Guid, tmpP); po.doneEditing(); tmpP.isOpen = true; tmpP.isEditing = false; tmpP.shouldFocus = true; //po.isEditing = true; po.model.cleanGraph(); AXNodeGraphEditorWindow.repaintIfOpen(); } /* * if (GUI.Button (new Rect(x1+editButtonWid+6, cur_y, editButtonWid,lineHgt), "Done" )) * po.doneEditing(); * else * if (GUI.Button (new Rect(x1+editButtonWid+6, cur_y, editButtonWid,lineHgt), "Edit Controls" )) * po.isEditing = true; */ cur_y += lineHgt + gap + 5; } if (po.generator is MaterialTool) { MaterialTool materialTool = (po.generator as MaterialTool); GUIStyle labelstyle = GUI.skin.GetStyle("Label"); labelstyle.alignment = TextAnchor.MiddleLeft; GUI.Label(new Rect(10, cur_y, 250, 32), " Texels/Unit: " + materialTool.texelsPerUnit.ToString("F0")); cur_y += 32; } else if (po.generator is ShapeOffsetter) { ShapeOffsetter offsetter = (po.generator as ShapeOffsetter); AXParameter output_p = offsetter.P_Output; if (output_p == null) { output_p = po.getParameter("Output Shape"); } if (output_p == null) { return(cur_y); } Rect tRect = new Rect(25, cur_y, 150, 16); GUIStyle labelstyle = GUI.skin.GetStyle("Label"); labelstyle.alignment = TextAnchor.MiddleLeft; /* * if (p.PType == AXParameter.ParameterType.Output) * { * labelstyle.alignment = TextAnchor.MiddleRight; * labelstyle.fixedWidth = lRect.width+5; * } */ // JOIN_TYPE: Square, Round, Miter if (offsetter.offset != 0) { string[] options = ArchimatixUtils.getMenuOptions("JoinType"); EditorGUIUtility.labelWidth = 75; //-50; EditorGUI.BeginChangeCheck(); output_p.joinType = (JoinType)EditorGUI.Popup(tRect, "JoinType", (int)output_p.joinType, options); if (EditorGUI.EndChangeCheck()) { Undo.RegisterCompleteObjectUndo(po.model, "value change for JoinType"); po.model.autobuild(); } cur_y += ArchimatixUtils.lineHgt + ArchimatixUtils.gap; } // ARC_TOLERANCE (for JoinType.Round) if (output_p.joinType == AXClipperLib.JoinType.jtRound || output_p.endType == AXClipperLib.EndType.etOpenRound) { tRect.y = cur_y; if (float.IsNaN(output_p.arcTolerance)) { output_p.arcTolerance = 50; } if (output_p.arcTolerance < .25f) { output_p.arcTolerance = .25f; } float smooth = (float)(120 / (output_p.arcTolerance * output_p.arcTolerance)); AXEditorUtilities.assertFloatFieldKeyCodeValidity("shapehandler_Text_smoothness_" + output_p.Guid + "_" + output_p.Name); EditorGUI.BeginChangeCheck(); GUI.SetNextControlName("shapehandler" + output_p.Name); smooth = EditorGUI.FloatField(tRect, "smoothness", smooth); if (EditorGUI.EndChangeCheck()) { output_p.arcTolerance = (float)(Mathf.Sqrt(120 / smooth)); Undo.RegisterCompleteObjectUndo(po.model, "value change for " + output_p.Name); if (output_p.arcTolerance < .25f) { output_p.arcTolerance = .25f; } if (output_p.arcTolerance > 50) { output_p.arcTolerance = 50; } if (float.IsNaN(output_p.arcTolerance)) { output_p.arcTolerance = 50; } po.model.isAltered(20); } cur_y += ArchimatixUtils.lineHgt + ArchimatixUtils.gap; } } return(cur_y); }
// return the height of this gui area public static void OnGUI(AXParameterAlias pa) { AXParameter p = pa.parameter; //Event e = Event.current; // if (Event.current.type == EventType.KeyUp) // { // if (p != null && ! GUI.GetNameOfFocusedControl().Contains("logicTextArea_") ) // { // p.parametricObject.model.autobuildDelayed(1000); // } // } //Color oldBackgroundColor = GUI.backgroundColor; if (p == null || p.parametricObject == null) { return; } //Color defcolor = GUI.color; GUILayout.BeginHorizontal(); // FOLDOUT GUIStyle toggleStyle = new GUIStyle(EditorStyles.foldout); toggleStyle.fixedWidth = 50; pa.isEditing = EditorGUILayout.Foldout(pa.isEditing, GUIContent.none); //Debug.Log(pa.isEditing); // SLIDER AND NUMBER FIELD GUIStyle textfieldStyle = new GUIStyle(GUI.skin.textField); textfieldStyle.fixedWidth = 150; GUIStyle labelWrap = new GUIStyle(GUI.skin.label); labelWrap.stretchWidth = true; labelWrap.wordWrap = true; labelWrap.fontSize = 9; labelWrap.fixedWidth = 150; if (pa.isEditing) { GUILayout.BeginVertical(); pa.alias = GUILayout.TextField(pa.alias, textfieldStyle); GUILayout.Label("You can edit the alias without altering the source parameter.", labelWrap); GUILayout.Label("Actual: ", labelWrap); if (GUILayout.Button(pa.parameter.parametricObject.Name + "." + pa.parameter.Name)) { pa.parameter.parametricObject.model.selectPO(pa.parameter.parametricObject); pa.parameter.ParentNode.isOpen = true; float framePadding = 200; Rect allRect = AXUtilities.getBoundaryRectFromPOs(pa.parameter.parametricObject.model.selectedPOs); allRect.x -= framePadding; allRect.y -= framePadding; allRect.width += framePadding * 2; allRect.height += framePadding * 2; AXNodeGraphEditorWindow.zoomToRectIfOpen(allRect); } GUILayout.Space(15); GUILayout.EndVertical(); } else { string nameString = pa.alias; switch (p.Type) { case AXParameter.DataType.Float: // FLOAT SLIDER if (p.PType != AXParameter.ParameterType.DerivedValue) { // VALIDATE INPUT - IF INVALID >> LOSE FOCUS AXEditorUtilities.assertFloatFieldKeyCodeValidity("FloatField_Text_" + p.Name); EditorGUI.BeginChangeCheck(); GUI.SetNextControlName("FloatField_Text_" + p.Guid + "_" + p.Name); p.val = EditorGUILayout.FloatField(nameString, 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(); } } else { GUILayout.Label(p.Name); GUILayout.Label("" + p.val); } 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 = EditorGUILayout.IntField(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(); } break; } case AXParameter.DataType.Bool: { EditorGUI.BeginChangeCheck(); GUI.SetNextControlName("BoolToggle_" + p.Guid + "_" + p.Name); p.boolval = EditorGUILayout.Toggle(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.generator.adjustWorldMatrices(); } break; } case AXParameter.DataType.String: if (p.Parent.isEditing) { GUILayout.Label(nameString); } else { GUILayout.Label(nameString); } break; case AXParameter.DataType.Option: { // OPTION POPUP string[] options = ArchimatixUtils.getMenuOptions(p.Name); EditorGUI.BeginChangeCheck(); GUI.SetNextControlName("OptionPopup_" + p.Guid + "_" + p.Name); p.intval = EditorGUILayout.Popup( nameString, 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(); EditorGUI.BeginChangeCheck(); GUI.SetNextControlName("CustomOptionPopup_" + p.Guid + "_" + p.Name); p.intval = EditorGUILayout.Popup( nameString, p.intval, options); if (EditorGUI.EndChangeCheck()) { Undo.RegisterCompleteObjectUndo(p.Parent.model, "value change for " + p.Name); if (p.PType == AXParameter.ParameterType.PositionControl) { p.parametricObject.generator.adjustWorldMatrices(); } p.parametricObject.model.autobuild(); } break; } case AXParameter.DataType.Spline: { GUILayout.Label(pa.alias); break; } } // END switch (Type) } GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); //GUI.backgroundColor = oldBackgroundColor; //GUI.color = defcolor; }
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 int display(Rect pRect, AXNodeGraphEditorWindow editor, AXParameter p) { //Debug.Log("ParameterTextureGUI.DISPLAY "+p.Name); float cur_x = ArchimatixUtils.cur_x; //float box_w = ArchimatixUtils.paletteRect.width - cur_x - 3*ArchimatixUtils.indent; float box_w = pRect.width - cur_x - 1 * ArchimatixUtils.indent; int cur_y = (int)pRect.y; int lineHgt = (int)pRect.height; int gap = 5; //Color shapeColor = editor.getDataColor (AXParameter.DataType.Spline); Color dataColor = editor.getDataColor(p.Type); Color oldBackgroundColor = GUI.backgroundColor; GUI.backgroundColor = dataColor; // INPUT if (editor.OutputParameterBeingDragged == null || editor.OutputParameterBeingDragged.Type == p.Type) { if (p.PType != AXParameter.ParameterType.Output) { if (GUI.Button(new Rect(-3, cur_y, ArchimatixEngine.buttonSize, ArchimatixEngine.buttonSize), "")) { if (editor.OutputParameterBeingDragged != null && editor.OutputParameterBeingDragged.Type != p.Type) { editor.OutputParameterBeingDragged = null; } else { editor.inputSocketClicked(p); } } } } // OUTPUT if (editor.InputParameterBeingDragged == null || editor.InputParameterBeingDragged.Type == AXParameter.DataType.MaterialTool) { if (GUI.Button(new Rect(pRect.width + 6, cur_y, ArchimatixEngine.buttonSize, ArchimatixEngine.buttonSize), "")) { if (editor.InputParameterBeingDragged != null && editor.InputParameterBeingDragged.Type != p.Type) { editor.InputParameterBeingDragged = null; } else { editor.outputSocketClicked(p); } } } // LABEL BOX Rect boxRect = new Rect(cur_x + ArchimatixUtils.indent, cur_y, box_w, pRect.height); GUI.Box(boxRect, " "); GUI.Box(boxRect, " "); GUI.Box(boxRect, " "); GUI.Box(boxRect, " "); // LABEL Rect lRect = boxRect; lRect.x += 3; lRect.width -= 10; GUI.Box(boxRect, " "); GUI.Box(boxRect, " "); GUI.Box(boxRect, " "); GUI.Box(boxRect, " "); GUIStyle labelstyle = GUI.skin.GetStyle("Label"); labelstyle.alignment = TextAnchor.MiddleLeft; if (p.PType == AXParameter.ParameterType.Output) { labelstyle.alignment = TextAnchor.MiddleRight; labelstyle.fixedWidth = lRect.width + 5; } string label = p.Name; if (p.ParentNode != null && p.ParentNode is AXShape) { if (p.DependsOn != null) { if (p.DependsOn.Parent != null) { label = p.DependsOn.Parent.Name; } } } GUI.Label(lRect, label); // Texture Thumbnail AXParameter src_p = p.DependsOn; AXParametricObject src_po = null; if (src_p != null) { src_po = src_p.parametricObject; } Rect texThumbRect; if (src_po != null) { if (src_po.generator is MaterialTool && src_po.axMat.mat != null && src_po.axMat.mat.mainTexture != null) { texThumbRect = new Rect((boxRect.x + boxRect.width - lineHgt + 1), cur_y + 1, lineHgt - 2, lineHgt - 2); EditorGUI.DrawTextureTransparent(texThumbRect, src_po.axMat.mat.mainTexture, ScaleMode.ScaleToFit, 1.0F); } else { texThumbRect = new Rect((boxRect.x + boxRect.width - lineHgt + 1), cur_y + 1, lineHgt - 2, lineHgt - 2); EditorGUI.DrawTextureTransparent(texThumbRect, ArchimatixEngine.nodeIcons[p.Type.ToString()], ScaleMode.ScaleToFit, 1.0F); } } else if (src_po == null) { if (src_p != null) { texThumbRect = new Rect((boxRect.x + boxRect.width - lineHgt + 1), cur_y + 1, lineHgt - 2, lineHgt - 2); EditorGUI.DrawTextureTransparent(texThumbRect, ArchimatixEngine.nodeIcons[p.Type.ToString()], ScaleMode.ScaleToFit, 1.0F); } else { // NEW TOOL texThumbRect = new Rect((boxRect.x + boxRect.width - lineHgt), cur_y - 1, lineHgt, lineHgt); if (GUI.Button(texThumbRect, ArchimatixEngine.nodeIcons[p.Type.ToString()])) //"+")) { src_po = AXEditorUtilities.addNodeToCurrentModel(p.Type.ToString()); src_po.Name = Regex.Replace(p.Name, @"\s+", ""); // remove spaces src_po.rect.x = p.parametricObject.rect.x - 220; src_po.rect.y = p.parametricObject.rect.y + 50; src_po.rect.height = 500; if (p.parametricObject.model.currentWorkingGroupPO != null) { p.parametricObject.model.currentWorkingGroupPO.addGroupee(src_po); } else { src_po.grouper = null; src_po.grouperKey = null; } //AXNodeGraphEditorWindow.zoomToRectIfOpen(src_po.rect); //src_po.inputControls.isOpen = true; src_po.geometryControls.isOpen = true; src_po.generator.pollInputParmetersAndSetUpLocalReferences(); //Debug.Log("here " + src_po.getParameter("Output")); p.makeDependentOn(src_po.getParameter("Output")); p.parametricObject.model.remapMaterialTools(); p.parametricObject.isAltered = true; p.parametricObject.model.autobuild(); } } } /* * // FOLDOUT (isOpen) * GUI.backgroundColor = new Color(1,1,1,1f); * * EditorGUI.BeginChangeCheck (); * p.isOpen = EditorGUI.Foldout (new Rect (cur_x, cur_y, 55, lineHgt), p.isOpen, ""); * if (EditorGUI.EndChangeCheck ()) * { * if (src_p == null) * { * src_po = AXEditorUtilities.addNodeToCurrentModel(p.Type.ToString(), false); * src_po.Name = Regex.Replace(p.Name, @"\s+", ""); // remove spaces * src_po.rect.x = p.parametricObject.rect.x - 200; * src_po.rect.y = p.parametricObject.rect.y + 50; * src_po.isOpen = false; * p.makeDependentOn(src_po.generator.P_Output); * p.parametricObject.model.autobuild(); * } * } * GUI.backgroundColor = shapeColor; * * if (p.DependsOn == null) * p.isOpen = false; * * cur_y += lineHgt+gap; * * if (p.isOpen) * { * * * * //Archimatix.cur_x += Archimatix.indent; * p.drawClosed = false; * * Rect tRect = pRect; * tRect.x = 20;//30; * tRect.width = pRect.width; * tRect.x += 2; * tRect.width -= 11; * * if (! src_po.isOpen) * { * foreach (AXParameter sp in src_po.getAllParametersOfPType(AXParameter.ParameterType.GeometryControl)) * { * * * * * * tRect.y = cur_y; * Rect cntlRect = tRect; // new Rect(x0, cur_y, wid, 16); * * * int hgt = ParameterGUI.OnGUI(cntlRect, editor, sp); * * cur_y += hgt + gap; * } * } * * * * * * * * * * //Archimatix.cur_x -= Archimatix.indent; * * * * } */ cur_y += lineHgt + gap; GUI.backgroundColor = oldBackgroundColor; return(cur_y); }
public static int OnGUI(AXHandle han, Rect pRect, AXNodeGraphEditorWindow editor) { int cur_y = (int)pRect.y; int lineHgt = 16; int margin = 24; int wid = (int)pRect.width - margin; int gap = 5; int indent = (int)pRect.x + 16; int indent2 = indent + 12; int indentWid = wid - indent; if (han.Name == null || han.Name == "") { han.Name = "Handle"; } if (han.isEditing) { if (han.expressions == null) { han.expressions = new List <string>(); } GUI.Box(new Rect(pRect.x, cur_y - 4, (pRect.width - 20), ((12 + han.expressions.Count) * lineHgt)), ""); // TITLE GUI.SetNextControlName("HanTitle_Text_" + han.parametricObject.Guid + "_" + han.param); han.Name = GUI.TextField(new Rect(pRect.x + 4, cur_y, pRect.width - 3 * lineHgt - 14, lineHgt), han.Name); cur_y += lineHgt; //if (expressions != null) //GUI.Box (new Rect(pRect.x, cur_y, wid, lineHgt*(8+expressions.Count)), GUIContent.none); // HANDLE_TYPE //EditorGUI.PropertyField( new Rect(indent, cur_y, pRect.width-3*lineHgt-14, lineHgt), hProperty.FindPropertyRelative("m_type"), GUIContent.none); AXModel model = han.parametricObject.model; //string[] options = Archimatix.getMenuOptions(p.Name); cur_y += gap * 2; // HANDLE TYPE string[] options = System.Enum.GetNames(typeof(AXHandle.HandleType)); EditorGUIUtility.labelWidth = wid - 50; EditorGUI.BeginChangeCheck(); han.Type = (AXHandle.HandleType)EditorGUI.Popup( new Rect(indent, cur_y, pRect.width - 3 * lineHgt - 14, lineHgt), "", (int)han.Type, options); if (EditorGUI.EndChangeCheck()) { Undo.RegisterCompleteObjectUndo(model, "value change for handle type"); model.autobuild(); } cur_y += lineHgt + gap; GUIStyle labelstyle = GUI.skin.GetStyle("Label"); labelstyle.alignment = TextAnchor.MiddleLeft; // RUNTIME HANDLE: expose in Model interface ------------ Rect cntlRect = new Rect(indent, cur_y, pRect.width - 3 * lineHgt - 14, lineHgt); EditorGUI.BeginChangeCheck(); han.exposeForRuntime = EditorGUI.Toggle(cntlRect, "Runtime", han.exposeForRuntime); if (EditorGUI.EndChangeCheck()) { Undo.RegisterCompleteObjectUndo(model, "Runtime Handle"); if (han.exposeForRuntime) { //Debug.Log(ArchimatixEngine.RuntimeHandlePrefab_PlanarKnob); //AXHandleRuntimeAlias rtHandleAlias = model.addHandleRuntimeAlias(han); if (ArchimatixEngine.RuntimeHandlePrefab_PlanarKnob != null) { // CREATE A GAME_OBJECT GameObject tmp = GameObject.Instantiate(ArchimatixEngine.RuntimeHandlePrefab_PlanarKnob); //GameObject tmp = GameObject.Instantiate(model.RuntimeHandlePrefab_PlanarKnob); tmp.name = han.Name; Debug.Log("han.Name=" + han.Name); if (tmp != null) { tmp.transform.parent = model.runtimeHandlesGameObjects.transform; AXRuntimeHandleBehavior rtHandleBehavior = tmp.GetComponent <AXRuntimeHandleBehavior>(); rtHandleBehavior.handleGuid = han.Guid; rtHandleBehavior.handle = han; } } } else { model.removeHandleRuntimeAlias(han); AXRuntimeHandleBehavior[] rhbs = model.runtimeHandlesGameObjects.GetComponentsInChildren <AXRuntimeHandleBehavior> (); for (int j = 0; j < rhbs.Length; j++) { if (rhbs[j] != null && rhbs[j].gameObject != null && rhbs[j].handleGuid == han.Guid) { // This GameObject and all its children... if (Application.isPlaying) { GameObject.Destroy(rhbs[j].gameObject); } else { GameObject.DestroyImmediate(rhbs[j].gameObject); } break; } } Resources.UnloadUnusedAssets(); } } cur_y += lineHgt + gap; // POSITION HEADER ------- GUI.Label(new Rect(indent, cur_y, pRect.width - 3 * lineHgt - 14, lineHgt), new GUIContent("Position", "Use a number, parameter name, or a mathematical expressions to define the handle position")); cur_y += lineHgt; // X_POS GUI.Label(new Rect(indent, cur_y, 12, lineHgt), "X"); GUI.SetNextControlName("x_Text_" + han.parametricObject.Guid + "_" + han.param); han.pos_x = EditorGUI.TextField(new Rect(indent2, cur_y, indentWid, lineHgt), han.pos_x); cur_y += lineHgt; // Y_POS GUI.Label(new Rect(indent, cur_y, 12, lineHgt), "Y"); GUI.SetNextControlName("y_Text_" + han.parametricObject.Guid + "_" + han.param); han.pos_y = EditorGUI.TextField(new Rect(indent2, cur_y, indentWid, lineHgt), han.pos_y); cur_y += lineHgt; // Z_POS GUI.Label(new Rect(indent, cur_y, 12, lineHgt), "Z"); GUI.SetNextControlName("z_Text_" + han.parametricObject.Guid + "_" + han.param); han.pos_z = EditorGUI.TextField(new Rect(indent2, cur_y, indentWid, lineHgt), han.pos_z); cur_y += lineHgt + gap; if (han.Type == AXHandle.HandleType.Circle) { // RADIUS GUI.Label(new Rect(indent, cur_y, pRect.width - 3 * lineHgt - 14, lineHgt), new GUIContent("Radius", "Use a number, parameter name, or a mathematical expressions to define the handle radius")); cur_y += lineHgt; GUI.Label(new Rect(indent, cur_y, 12, lineHgt), "R"); han.radius = EditorGUI.TextField(new Rect(indent2, cur_y, indentWid, lineHgt), han.radius); cur_y += lineHgt + gap; // TANGENT Color prevColor = Handles.color; Handles.color = Color.cyan; GUI.Label(new Rect(indent, cur_y, pRect.width - 3 * lineHgt - 14, lineHgt), new GUIContent("Tangent", "Use a number, parameter name, or a mathematical expressions to define the handle tangent")); cur_y += lineHgt; GUI.Label(new Rect(indent, cur_y, 12, lineHgt), "T"); han.tangent = EditorGUI.TextField(new Rect(indent2, cur_y, indentWid, lineHgt), han.tangent); cur_y += lineHgt + gap; /* * // OFFSET ANGLE * GUI.Label(new Rect(indent, cur_y, pRect.width-3*lineHgt-14, lineHgt), new GUIContent("Angle", "Use a number, parameter name, or a mathematical expressions to define the handle angle")); * cur_y += lineHgt; * * GUI.Label(new Rect(indent, cur_y, 12, lineHgt), "Z"); * angle = EditorGUI.TextField(new Rect(indent2, cur_y, indentWid, lineHgt), angle); * cur_y += lineHgt+gap; */ Handles.color = prevColor; } // EXPRESSIONS HEADER ------- GUI.Label(new Rect(indent, cur_y, pRect.width - 3 * lineHgt - 14, lineHgt), new GUIContent("Expressions", "These mathematical expressions interpret the handle's values.")); cur_y += lineHgt; if (han.expressions == null) { han.expressions = new List <string>(); } if (han.expressions.Count == 0) { han.expressions.Add(""); } for (int i = 0; i < han.expressions.Count; i++) { GUI.SetNextControlName("HandleExp_Text_" + han.parametricObject.Guid + "_" + han.param); han.expressions[i] = EditorGUI.TextField(new Rect(indent, cur_y, indentWid, 16), han.expressions[i]); if (GUI.Button(new Rect(pRect.width - lineHgt * 1.5f, cur_y - 1, lineHgt * 1.25f, lineHgt), "-")) { han.expressions.Remove(han.expressions[i]); //p.expressions.RemoveAt(i); } cur_y += lineHgt; } if (GUI.Button(new Rect(pRect.width - lineHgt * 1.5f, cur_y, lineHgt * 1.25f, lineHgt), new GUIContent("+", "Add an expression to this Handle"))) { han.expressions.Add(""); } cur_y += gap * 5; if (GUI.Button(new Rect(pRect.width - 3 * lineHgt - 5, cur_y, 3 * lineHgt, lineHgt), "Done")) { if (han.parametricObject != null) { han.parametricObject.stopEditingAllHandles(); } han.isEditing = false; } cur_y += lineHgt; } else { if (GUI.Button(new Rect(pRect.x, pRect.y, wid - 16, 16), new GUIContent(han.Name, "Click to edit this handle."))) { han.parametricObject.stopEditingAllHandlesExcept(han); han.isEditing = true; } } if (GUI.Button(new Rect(wid + 6, pRect.y, lineHgt, lineHgt), "-")) { //Debug.Log ("REMOVE HANDLE..."); if (han.parametricObject != null) { han.parametricObject.removeHandleFromReplicantsControlsWithName(han.Name); han.parametricObject.handles.Remove(han); } } cur_y += lineHgt; return(cur_y - (int)pRect.y); }
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 static void display(float imagesize = 64, AXNodeGraphEditorWindow editor = null) { //Debug.Log("imagesise="+imagesize); // called from an OnGUI //imagesize = 64; scrollPosition = EditorGUILayout.BeginScrollView(scrollPosition, GUIStyle.none, GUIStyle.none); EditorGUILayout.BeginVertical(); string[] itemStrings = null; // Select menu item list if (editor.OutputParameterBeingDragged == null) { if (editor.model != null && editor.model.selectedPOs.Count > 1) { //if (editor.model.selectedPOs[0].is2D()) // itemStrings = ArchimatixEngine.nodeStringsFrom2DMultiSelect; //else itemStrings = ArchimatixEngine.nodeStringsFromMultiSelect; } else { itemStrings = ArchimatixEngine.nodeStrings; } } else if (editor.OutputParameterBeingDragged.parametricObject.is2D()) { itemStrings = ArchimatixEngine.nodeStringsFrom2DOutput; } else if (editor.OutputParameterBeingDragged.parametricObject.is3D()) { if (editor.OutputParameterBeingDragged.Type == AXParameter.DataType.Spline) { itemStrings = ArchimatixEngine.nodeStringsFrom2DOutput; } else { itemStrings = ArchimatixEngine.nodeStringsFrom3DOutput; } } else if (editor.OutputParameterBeingDragged.parametricObject.generator is RepeaterTool) { itemStrings = ArchimatixEngine.nodeStringsFromRepeaterTool; } /* * if (Library.last2DItem != null) * { * if (GUILayout.Button(new GUIContent(Library.last2DItem.icon, Library.last2DItem.po.Name), new GUILayoutOption[] {GUILayout.Width(imagesize), GUILayout.Height(imagesize)})) * { * * } * } */ List <string> stringList = null; if (itemStrings != null) { stringList = itemStrings.ToList(); } if (stringList != null) { stringList.AddRange(Archimatix.customNodeNames); } // Build Menu string poName; if (stringList != null) { for (int i = 0; i < stringList.Count; i++) { string nodeName = stringList[i]; Texture2D nodeIcon = null; if (ArchimatixEngine.nodeIcons.ContainsKey(nodeName)) { nodeIcon = ArchimatixEngine.nodeIcons[nodeName]; } else { if (ArchimatixEngine.nodeIcons.ContainsKey("CustomNode")) { nodeIcon = ArchimatixEngine.nodeIcons["CustomNode"]; } else { continue; } } if (nodeIcon != null) { if (GUILayout.Button(new GUIContent(nodeIcon, nodeName), new GUILayoutOption[] { GUILayout.Width(imagesize), GUILayout.Height(imagesize) })) { //if (editor.DraggingOutputParameter != null) //{ AXModel model = AXEditorUtilities.getOrMakeSelectedModel(); Undo.RegisterCompleteObjectUndo(model, "Node Menu Selection"); AXParametricObject mostRecentPO = model.recentlySelectedPO; int index = nodeName.IndexOf("_"); poName = (index > 0) ? nodeName.Substring(0, index) : nodeName; // Support multi-select operation List <AXParametricObject> selectedPOs = new List <AXParametricObject>(); if (model.selectedPOs.Count > 0) { selectedPOs.AddRange(model.selectedPOs); } // ADD NEW PO TO MODEL (only this new po is selected after this) AXParametricObject po = AXEditorUtilities.addNodeToCurrentModel(poName, false); if (po == null || po.generator == null) { return; } float max_x = -AXGeometryTools.Utilities.IntPointPrecision; if (poName == "FreeCurve") { ArchimatixEngine.sceneViewState = ArchimatixEngine.SceneViewState.AddPoint; } // DRAGGING A PARAMETER? THEN RIG'R UP! if (editor.OutputParameterBeingDragged != null) { AXParametricObject draggingPO = editor.OutputParameterBeingDragged.parametricObject; AXParameter new_input_p = null; switch (nodeName) { case "Instance2D": case "ShapeOffsetter": po.getParameter("Input Shape").makeDependentOn(editor.OutputParameterBeingDragged); po.intValue("Axis", editor.OutputParameterBeingDragged.parametricObject.intValue("Axis")); if (po.geometryControls != null) { po.geometryControls.isOpen = true; } break; case "ShapeDistributor": List <AXParameter> deps = new List <AXParameter>(); for (int dd = 0; dd < editor.OutputParameterBeingDragged.Dependents.Count; dd++) { deps.Add(editor.OutputParameterBeingDragged.Dependents[dd]); } for (int dd = 0; dd < deps.Count; dd++) { deps[dd].makeDependentOn(po.getParameter("Output Shape")); } po.getParameter("Input Shape").makeDependentOn(editor.OutputParameterBeingDragged); po.intValue("Axis", editor.OutputParameterBeingDragged.parametricObject.intValue("Axis")); if (po.geometryControls != null) { po.geometryControls.isOpen = true; } break; case "ShapeMerger": po.generator.getInputShape().addInput().makeDependentOn(editor.OutputParameterBeingDragged); if (editor.OutputParameterBeingDragged.axis != Axis.NONE) { po.intValue("Axis", (int)editor.OutputParameterBeingDragged.axis); } else { po.intValue("Axis", editor.OutputParameterBeingDragged.parametricObject.intValue("Axis")); } break; case "PlanRepeater2D": case "PlanRepeater2D_Corner": po.getParameter("Corner Shape").makeDependentOn(editor.OutputParameterBeingDragged); po.intValue("Axis", editor.OutputParameterBeingDragged.parametricObject.intValue("Axis")); break; case "PlanRepeater_Corner": po.getParameter("Corner Mesh").makeDependentOn(editor.OutputParameterBeingDragged); break; case "PairRepeater2D": case "RadialRepeater2D": case "RadialRepeater2D_Node": case "LinearRepeater2D": case "LinearRepeater2D_Node": case "GridRepeater2D": case "GridRepeater2D_Node": po.getParameter("Node Shape").makeDependentOn(editor.OutputParameterBeingDragged); po.intValue("Axis", editor.OutputParameterBeingDragged.parametricObject.intValue("Axis")); break; case "RadialRepeater2D_Cell": case "LinearRepeater2D_Cell": case "GridRepeater2D_Cell": po.getParameter("Cell Shape").makeDependentOn(editor.OutputParameterBeingDragged); po.intValue("Axis", editor.OutputParameterBeingDragged.parametricObject.intValue("Axis")); break; case "Grouper": //po.addInputMesh().makeDependentOn(editor.OutputParameterBeingDragged); po.addGroupee(editor.OutputParameterBeingDragged.parametricObject); break; case "PlanRepeater2D_Plan": case "Polygon_Plan": case "Extrude_Plan": case "PlanSweep_Plan": case "PlanRepeater_Plan": case "PlanDeformer_Plan": // SYNC AXES if (editor.OutputParameterBeingDragged.axis != Axis.NONE) { po.intValue("Axis", (int)editor.OutputParameterBeingDragged.axis); } else { po.intValue("Axis", editor.OutputParameterBeingDragged.parametricObject.intValue("Axis")); } if (nodeName == "Extrude_Plan" && po.intValue("Axis") != (int)Axis.Y) { po.floatValue("Bevel", 0); } // INSERT SHAPE_DISTRIBUTOR? new_input_p = po.getParameter("Plan", "Input Shape"); //if (draggingPO.is2D() && !(draggingPO.generator is ShapeDistributor) && editor.OutputParameterBeingDragged.Dependents != null && editor.OutputParameterBeingDragged.Dependents.Count > 0) // model.insertShapeDistributor(editor.OutputParameterBeingDragged, new_input_p); //else new_input_p.makeDependentOn(editor.OutputParameterBeingDragged); // the output of the new node should match the shapestate of the input if (po.generator.P_Output != null) { po.generator.P_Output.shapeState = new_input_p.shapeState; } AXNodeGraphEditorWindow.repaintIfOpen(); break; case "Lathe_Section": case "PlanSweep_Section": case "PlanRepeater_Section": //po.getParameter("Section").makeDependentOn(editor.OutputParameterBeingDragged); // INSERT SHAPE_DISTRIBUTOR? new_input_p = po.getParameter("Section"); if (draggingPO.is2D() && !(draggingPO.generator is ShapeDistributor) && draggingPO.hasDependents()) { model.insertShapeDistributor(editor.OutputParameterBeingDragged, new_input_p); } else { new_input_p.makeDependentOn(editor.OutputParameterBeingDragged); } // the output of the new node should match the shapestate of the input //if (po.generator.P_Output != null) //Debug.Log(new_input_p.Name+" "+new_input_p.shapeState + " :=: " +editor.OutputParameterBeingDragged.Name + " " + editor.OutputParameterBeingDragged.shapeState); AXNodeGraphEditorWindow.repaintIfOpen(); break; case "NoiseDeformer": case "ShearDeformer": case "TwistDeformer": case "DomicalDeformer": case "TaperDeformer": case "InflateDeformer": case "PlanDeformer": po.getParameter("Input Mesh").makeDependentOn(editor.OutputParameterBeingDragged); break; //case "PlanDeformer_Plan": case "PairRepeater": case "StepRepeater": case "RadialStepRepeater": po.getParameter("Node Mesh").makeDependentOn(editor.OutputParameterBeingDragged); break; case "LinearRepeater_Node": AXParameter nodeMesh_p = po.getParameter("Node Mesh"); nodeMesh_p.makeDependentOn(editor.OutputParameterBeingDragged); // if the src is very long in x, assume you want to repeat in Z if (editor.OutputParameterBeingDragged.parametricObject.bounds.size.x > (6 * editor.OutputParameterBeingDragged.parametricObject.bounds.size.z)) { po.initiateRipple_setBoolParameterValueByName("zAxis", true); } break; case "LinearRepeater_Cell": case "PlanRepeater_Cell": po.getParameter("Cell Mesh").makeDependentOn(editor.OutputParameterBeingDragged); break; case "LinearRepeater_Span": po.getParameter("Bay SpanU").makeDependentOn(editor.OutputParameterBeingDragged); break; case "LinearRepeater": po.getParameter("RepeaterU").makeDependentOn(editor.OutputParameterBeingDragged); break; case "FloorRepeater": po.getParameter("Floor Mesh").makeDependentOn(editor.OutputParameterBeingDragged); break; case "RadialRepeater": case "RadialRepeater_Node": case "GridRepeater_Node": case "PlanRepeater_Node": po.getParameter("Node Mesh").makeDependentOn(editor.OutputParameterBeingDragged); break; case "RadialRepeater_Span": case "GridRepeater_Span": po.getParameter("Bay SpanU", "SpanU Mesh").makeDependentOn(editor.OutputParameterBeingDragged); break; case "GridRepeater_Cell": po.getParameter("Cell Mesh").makeDependentOn(editor.OutputParameterBeingDragged); break; case "ShapeRepeater_Plan": AXEditorUtilities.addNodeToCurrentModel("ShapeRepeater").getParameter("Plan").makeDependentOn(editor.OutputParameterBeingDragged); break; default: AXEditorUtilities.addNodeToCurrentModel(nodeName); break; } if (editor.OutputParameterBeingDragged.parametricObject != null) { mostRecentPO = editor.OutputParameterBeingDragged.parametricObject; //po.rect = editor.OutputParameterBeingDragged.parametricObject.rect; //po.rect.x += 325; } /* * else * { * po.rect.x = (model.focusPointInGraphEditor.x)+100;// + UnityEngine.Random.Range(-100, 300); * po.rect.y = (model.focusPointInGraphEditor.y - 250) + UnityEngine.Random.Range(-10, 0); * } */ } // NO DRAGGING - CONNECT ALL MULTI_SELECTED else if (selectedPOs != null && selectedPOs.Count > 0) { switch (nodeName) { case "ShapeMerger": AXShape shp = po.generator.getInputShape(); for (int j = 0; j < selectedPOs.Count; j++) { AXParametricObject poo = selectedPOs [j]; if (j == 0) { po.intValue("Axis", selectedPOs [j].intValue("Axis")); } max_x = Mathf.Max(max_x, poo.rect.x); if (poo.is2D()) { AXParameter out_p = poo.generator.getPreferredOutputParameter(); if (out_p != null) { shp.addInput().makeDependentOn(out_p); } } } po.rect.x = max_x + 250; break; case "Grouper": //Debug.Log("selectedPOs="+selectedPOs.Count); //if (model.currentWorkingGroupPO != null && ! selectedPOs.Contains(model.currentWorkingGroupPO)) //{ po.addGroupees(selectedPOs); Rect r = AXUtilities.getBoundaryRectFromPOs(selectedPOs); po.rect.x = r.center.x - po.rect.width / 2; po.rect.y = r.center.y - po.rect.height / 2; //} //po.rect.x = max_x+250; break; case "Channeler": //Debug.Log("selectedPOs="+selectedPOs.Count); //if (model.currentWorkingGroupPO != null && ! selectedPOs.Contains(model.currentWorkingGroupPO)) //{ foreach (AXParametricObject selpo in selectedPOs) { AXParameter inputer = po.addInputMesh(); inputer.makeDependentOn(selpo.generator.P_Output); } Rect cr = AXUtilities.getBoundaryRectFromPOs(selectedPOs); po.rect.x = cr.center.x - po.rect.width / 2; po.rect.y = cr.center.y - po.rect.height / 2; //} //po.rect.x = max_x+250; break; } } else { switch (nodeName) { case "ShapeMerger": po.assertInputControls(); //po.generator.getInputShape().addInput(); break; } } editor.OutputParameterBeingDragged = null; model.autobuild(); po.generator.adjustWorldMatrices(); if (mostRecentPO != null) { po.rect = mostRecentPO.rect; po.rect.x += (mostRecentPO.rect.width + 50); } else { po.rect.x = (model.focusPointInGraphEditor.x) + 100; // + UnityEngine.Random.Range(-100, 300); po.rect.y = (model.focusPointInGraphEditor.y - 250) + UnityEngine.Random.Range(-10, 0); } po.rect.height = 700; //AXNodeGraphEditorWindow.zoomToRectIfOpen(po.rect); //model.beginPanningToRect(po.rect); } } } } //GUILayout.Label (GUI.tooltip); EditorGUILayout.Space(); EditorGUILayout.EndVertical(); EditorGUILayout.EndScrollView(); /* Not sure why I was doing this - it took up a huge amount of CPU! * * * editor.Repaint(); * SceneView sv = SceneView.lastActiveSceneView; * if (sv != null) * sv.Repaint(); * */ }
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 (); }