コード例 #1
0
    public static void DrawSplineFit(AXParameter p, Vector2 offset, float size, Color splineColor)
    {
        AXSpline s = p.spline.clone();

        s.rotate(p.Parent.floatValue("Rot_Z"));

        if (s == null)
        {
            return;
        }

        // scale the spline to fit in "size" in pixels
        AXSpline os = s.clone();

        os.calcStats();
        os.shift(-os.cenX, -os.cenY);

        float maxdim = (os.width > os.height) ? os.width : os.height;
        float scale  = size / maxdim;

        os.scale(scale);

        GUIDrawing.DrawSpline(os, offset, splineColor);
    }
コード例 #2
0
    public void doPO(AXParametricObject po)
    {
        Color guiColorOrig        = GUI.color;
        Color guiContentColorOrig = GUI.contentColor;

        GUI.color        = Color.white;
        GUI.contentColor = Color.white;

        Color textColor    = new Color(.82f, .80f, .85f);
        Color textColorSel = new Color(.98f, .95f, 1f);


        GUIStyle labelstyle = new GUIStyle(GUI.skin.label);

        //int fontSize = labelstyle.fontSize;
        labelstyle.fixedHeight = 30;
        labelstyle.alignment   = TextAnchor.UpperLeft;

        labelstyle.normal.textColor = textColorSel;

        labelstyle.fontSize = 20;

//		GUIStyle labelstyleTmp = GUI.skin.GetStyle("Label");
//		labelstyleTmp.normal.textColor = Color.red;

        Color bgcolorOrig = GUI.backgroundColor;
        //GUI.backgroundColor = Color.cyan;



        GUIStyle gsTest = new GUIStyle();

        gsTest.normal.background = ArchimatixEngine.nodeIcons ["Blank"];        // //Color.gray;
        gsTest.normal.textColor  = Color.white;

        GUIStyle foldoutStyle = new GUIStyle(EditorStyles.foldout);

        foldoutStyle.normal.textColor  = textColor;
        foldoutStyle.active.textColor  = textColorSel;
        foldoutStyle.hover.textColor   = textColor;
        foldoutStyle.focused.textColor = textColorSel;

        foldoutStyle.onNormal.textColor  = textColor;
        foldoutStyle.onActive.textColor  = textColorSel;
        foldoutStyle.onHover.textColor   = textColor;
        foldoutStyle.onFocused.textColor = textColorSel;

        GUIStyle smallFoldoutStyle = new GUIStyle(EditorStyles.foldout);

        smallFoldoutStyle.fixedWidth = 0;



        GUILayout.BeginVertical(gsTest);


        GUILayout.BeginHorizontal(gsTest);
        GUILayout.Space(40);
        Rect rect = GUILayoutUtility.GetLastRect();

        //GUI.DrawTexture(new Rect(position.x, rect.y, EditorGUIUtility.currentViewWidth, 100), ArchimatixEngine.nodeIcons["Blank"], ScaleMode.ScaleToFit, true, 1.0F);

        GUILayout.Space(10);

        // TITLE
        GUILayout.Label(po.Name, labelstyle);


        labelstyle.fontSize = 12;
        GUILayout.EndHorizontal();



        if (po.is2D() && po.generator.hasOutputsReady())
        {
            AXParameter output_p = po.generator.getPreferredOutputParameter();
            GUIDrawing.DrawPathsFit(output_p, new Vector2(42, rect.y + 15), 28, ArchimatixEngine.AXGUIColors ["ShapeColor"]);
        }
        else if (ArchimatixEngine.nodeIcons != null && ArchimatixEngine.nodeIcons.ContainsKey(po.Type))
        {
            //Rect thumbRect = new Rect (28, rect.y - 0, 36, 36);
            //GUI.DrawTexture(thumbRect,    po.renTex, ScaleMode.ScaleToFit, true, 1.0F);
            EditorGUI.DrawTextureTransparent(new Rect(28, rect.y - 0, 36, 36), ArchimatixEngine.nodeIcons [po.Type], ScaleMode.ScaleToFit, 1.0F);
        }
        Rect rectthumb2 = GUILayoutUtility.GetLastRect();


        if (po.is3D() && po.renTex != null)
        {
            GUIStyle thumbLgStyle = new GUIStyle();
            float    thumbLgSize  = 64;

            thumbLgStyle.fixedHeight = thumbLgSize;
            GUILayout.BeginHorizontal(thumbLgStyle);
            GUILayout.Space(thumbLgSize);

            Rect thumbRectLG = new Rect(40, rectthumb2.y + 35, thumbLgSize, thumbLgSize);
            EditorGUI.DrawTextureTransparent(thumbRectLG, po.renTex, ScaleMode.ScaleToFit, 1.0F);

            GUILayout.EndHorizontal();
        }



        EditorGUI.indentLevel++;


        //GUILayout.Space(20);

        GUILayout.BeginHorizontal();

        EditorGUIUtility.labelWidth = 35;

        EditorGUI.BeginChangeCheck();
        //EditorGUIUtility.labelWidth = 65;

        po.isActive = EditorGUILayout.ToggleLeft("Enabled", po.isActive);
        if (EditorGUI.EndChangeCheck())
        {
            Undo.RegisterCompleteObjectUndo(po.model, "isActive value change for " + po.Name);
            po.model.autobuild();
            po.generator.adjustWorldMatrices();
        }

        GUILayout.FlexibleSpace();

        if (GUILayout.Button("Select in Node Graph"))
        {
            po.model.selectAndPanToPO(po);
        }

        GUILayout.EndHorizontal();



        // FLAGS, TAGS & LAYERS
        if (po.is3D())
        {
            po.displayFlagsTagsLayers = EditorGUILayout.Foldout(po.displayFlagsTagsLayers, "Name, Flags, Tags & Layers", true, foldoutStyle);
        }
        else
        {
            po.displayFlagsTagsLayers = EditorGUILayout.Foldout(po.displayFlagsTagsLayers, "Name", true, foldoutStyle);
        }



        if (po.displayFlagsTagsLayers)
        {
            //EDIT TITLE
//			if (showTitle(po))
//			{
            //GUILayout.BeginHorizontal();



            GUILayout.BeginHorizontal();
            GUILayout.Space(35);
            GUILayout.Label("Name: ");

            EditorGUIUtility.labelWidth = 65;
            po.Name = GUILayout.TextField(po.Name);
            GUILayout.EndHorizontal();



            if (po.is3D())
            {
                EditorGUIUtility.labelWidth = 75;

                EditorGUI.BeginChangeCheck();
                po.axStaticEditorFlags = (AXStaticEditorFlags)EditorGUILayout.EnumMaskField("Static: ", po.axStaticEditorFlags);
                if (EditorGUI.EndChangeCheck())
                {
                    Undo.RegisterCompleteObjectUndo(po.model, "Static value change for " + po.Name);

                    po.setUpstreamersToYourFlags();
                    // post dialog to change all children...
                    ArchimatixEngine.scheduleBuild();
                }


                GUI.backgroundColor = bgcolorOrig;



                EditorGUIUtility.labelWidth = 75;



                // TAGS
                EditorGUI.BeginChangeCheck();
                po.tag = EditorGUILayout.TagField("Tag:", po.tag);
                if (EditorGUI.EndChangeCheck())
                {
                    Undo.RegisterCompleteObjectUndo(po.model, "Tag value change for " + po.Name);
                    ArchimatixEngine.scheduleBuild();
                }



                // LAYERS
                EditorGUI.BeginChangeCheck();
                int intval = EditorGUILayout.LayerField("Layer:", po.layer);

                if (EditorGUI.EndChangeCheck())
                {
                    Undo.RegisterCompleteObjectUndo(po.model, "Layer value change for " + po.Name);
                    po.layer = intval;
                    ArchimatixEngine.scheduleBuild();
                }



                bool hasMeshRenderer = !po.noMeshRenderer;
                EditorGUI.BeginChangeCheck();
                hasMeshRenderer = EditorGUILayout.ToggleLeft("Mesh Renderer", hasMeshRenderer);
                if (EditorGUI.EndChangeCheck())
                {
                    Undo.RegisterCompleteObjectUndo(po.model, "hasMeshRenderer");
                    po.noMeshRenderer = !hasMeshRenderer;
                    ArchimatixEngine.scheduleBuild();
                }
            }
            else if (po.generator is MaterialTool)
            {
                EditorGUI.BeginChangeCheck();

                //float thumbSize = 16;

                po.axMat.mat = (Material)EditorGUILayout.ObjectField(po.axMat.mat, typeof(Material), true);
                if (EditorGUI.EndChangeCheck())
                {
                    Undo.RegisterCompleteObjectUndo(po.model, "Material");

                    po.model.remapMaterialTools();
                    po.model.autobuild();
                }
            }
        }         // FLAGS< TAGS & LAYERS



        // POSITION CONTROLS

        if (po.positionControls != null && po.positionControls.children != null)
        {
            po.positionControls.isOpenInInspector = EditorGUILayout.Foldout(po.positionControls.isOpenInInspector, "Transform", true, foldoutStyle);

            if (po.positionControls.isOpenInInspector)
            {
                InspectorParameterGUI.OnGUI(po.positionControls.children);
            }
        }



        // GEOMETRY CONTROLS

        if (po.geometryControls != null && po.geometryControls.children != null)
        {
            po.geometryControls.isOpenInInspector = EditorGUILayout.Foldout(po.geometryControls.isOpenInInspector, "Geometry Controls", true, foldoutStyle);
            if (po.geometryControls.isOpenInInspector)
            {
                InspectorParameterGUI.OnGUI(po.geometryControls.children);
            }
        }


        // PROTOTYPES

        if (po.is3D())
        {
            po.displayPrototypes = EditorGUILayout.Foldout(po.displayPrototypes, "Prototypes", true, foldoutStyle);

            if (po.displayPrototypes)
            {
                EditorGUI.BeginChangeCheck();
                po.prototypeGameObject = (GameObject)EditorGUILayout.ObjectField(po.prototypeGameObject, typeof(GameObject), true);
                if (EditorGUI.EndChangeCheck())
                {
                    Undo.RegisterCompleteObjectUndo(po.model, "Prototype GameObject set for " + po.model.name);
                    if (po.prototypeGameObject != null)
                    {
                        AXPrototype proto = (AXPrototype)po.prototypeGameObject.GetComponent("AXPrototype");
                        if (proto == null)
                        {
                            proto = po.prototypeGameObject.AddComponent <AXPrototype> ();
                        }
                        if (!proto.parametricObjects.Contains(po))
                        {
                            proto.parametricObjects.Add(po);
                        }
                    }
                    po.model.autobuild();
                }
            }
        }


        if (po.selectedAXGO != null)
        {
            GUILayout.Label(po.selectedAXGO.consumerAddress);
        }



//		if (po.is3D() && po.renTex != null)
//		{
//		GUIStyle thumbLgStyle = new GUIStyle();
//			float thumbLgSize = 194;
//
//			thumbLgStyle.fixedHeight = thumbLgSize;
//			GUILayout.BeginHorizontal(thumbLgStyle);
//			GUILayout.Space(40);
//			Rect rectthumb = GUILayoutUtility.GetLastRect();
//			Rect thumbRectLG = new Rect(28, rectthumb.y-0, thumbLgSize, thumbLgSize);
//		GUI.DrawTexture(thumbRectLG,    po.renTex, ScaleMode.ScaleToFit, true, 1.0F);
//
//		GUILayout.EndHorizontal();
//		}
//


        EditorGUI.indentLevel--;



        GUILayout.EndVertical();
        GUILayout.Space(30);


        GUI.color        = guiColorOrig;
        GUI.contentColor = guiContentColorOrig;
    }
コード例 #3
0
        // 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();
            }
        }
コード例 #4
0
    public static void DrawSpline(AXSpline _spline, Vector2 offset, Color splineColor)
    {
        Handles.BeginGUI();
        Handles.color = splineColor;


        if (_spline != null)
        {
            List <AXSpline> subs = _spline.getSubsplines();
            if (subs != null && subs.Count > 0)
            {
                foreach (AXSpline sub in subs)
                {
                    if (sub.verts == null || sub.vertCount == 0)
                    {
                        continue;
                    }

                    List <AXSpline> parts = sub.getSolidAndHoles();


                    AXSpline contour = parts[0];

                    Color closeColor = splineColor;
                    closeColor.a = splineColor.a / 3;

                    // origin
                    Handles.color = new Color(0, 1, 0, .5f);
                    GUIDrawing.drawSquare(new Vector2(contour.verts[0].x + offset.x, -contour.verts[0].y + offset.y), 2);

                    for (int i = 1; i < contour.vertCount; i++)
                    {
                        Handles.color = splineColor;
                        Handles.DrawLine(new Vector3(contour.verts[i - 1].x + offset.x, -contour.verts[i - 1].y + offset.y, 0), new Vector3(contour.verts[i].x + offset.x, -contour.verts[i].y + offset.y, 0));
                    }
                    Handles.color = closeColor;
                    if (contour.isClosed)
                    {
                        Handles.DrawLine(new Vector3(contour.verts[contour.vertCount - 1].x + offset.x, -contour.verts[contour.vertCount - 1].y + offset.y, 0), new Vector3(contour.verts[0].x + offset.x, -contour.verts[0].y + offset.y, 0));
                    }

                    Handles.color = Color.magenta;
                    for (int pc = 1; pc < parts.Count; pc++)
                    {
                        // origin
                        Handles.color = new Color(0, 1, 0, .5f);
                        GUIDrawing.drawSquare(new Vector2(parts[pc].verts[0].x + offset.x, -parts[pc].verts[0].y + offset.y), 2);


                        Handles.color = Color.cyan;
                        for (int i = 1; i < parts[pc].vertCount; i++)
                        {
                            Handles.DrawLine(new Vector3(parts[pc].verts[i - 1].x + offset.x, -parts[pc].verts[i - 1].y + offset.y, 0), new Vector3(parts[pc].verts[i].x + offset.x, -parts[pc].verts[i].y + offset.y, 0));
                        }
                        Handles.DrawLine(new Vector3(parts[pc].verts[parts[pc].vertCount - 1].x + offset.x, -parts[pc].verts[parts[pc].vertCount - 1].y + offset.y, 0), new Vector3(parts[pc].verts[0].x + offset.x, -parts[pc].verts[0].y + offset.y, 0));
                    }



                    //Debug.Log ("close= "+(contour.vertCount-1));
                }
            }
        }


        Handles.EndGUI();
    }
コード例 #5
0
    public void doPO(AXParametricObject po)
    {
        GUIStyle labelstyle = GUI.skin.GetStyle("Label");

        //int fontSize = labelstyle.fontSize;



        labelstyle.fontSize = 20;


        GUILayout.BeginHorizontal();
        GUILayout.Space(40);
        Rect rect = GUILayoutUtility.GetLastRect();

        // NAME
        GUILayout.Label(po.Name);


        labelstyle.fontSize = 12;
        GUILayout.EndHorizontal();

        if (po.is2D() && po.generator.hasOutputsReady())
        {
            AXParameter output_p = po.generator.getPreferredOutputParameter();
            GUIDrawing.DrawPathsFit(output_p, new Vector2(32, rect.y + 10), 32);
        }
        else if (ArchimatixEngine.nodeIcons != null && ArchimatixEngine.nodeIcons.ContainsKey(po.Type))
        {
            GUI.DrawTexture(new Rect(16, rect.y - 5, 32, 32), ArchimatixEngine.nodeIcons[po.Type], ScaleMode.ScaleToFit, true, 1.0F);
        }

        if (showTitle(po))
        {
            GUILayout.BeginHorizontal();

            EditorGUI.BeginChangeCheck();
            EditorGUIUtility.labelWidth = 0;
            po.isActive = EditorGUILayout.Toggle(po.isActive, GUILayout.MaxWidth(20));
            if (EditorGUI.EndChangeCheck())
            {
                Undo.RegisterCompleteObjectUndo(po.model, "isActive value change for " + po.Name);
                po.model.autobuild();
                po.generator.adjustWorldMatrices();
            }

            EditorGUIUtility.labelWidth = 0;
            po.Name = GUILayout.TextField(po.Name);



            if (po.is3D())
            {
                EditorGUIUtility.labelWidth = 35;
                EditorGUI.BeginChangeCheck();
                po.axStaticEditorFlags = (AXStaticEditorFlags)EditorGUILayout.EnumMaskField("Static", po.axStaticEditorFlags);
                if (EditorGUI.EndChangeCheck())
                {
                    Undo.RegisterCompleteObjectUndo(po.model, "Static value change for " + po.Name);

                    po.setUpstreamersToYourFlags();
                    // post dialog to change all children...
                    po.model.autobuild();

                    /*
                     * int option = EditorUtility.DisplayDialogComplex("Change Static Flags?",
                     *      "Do you want to disable the Lightmap Static flag for all the child objects as well? ",
                     *
                     *      "No, only this ParametricObject",
                     *      "Yes, change children",
                     *      "Cancel");
                     *
                     *
                     * switch( option )
                     * {
                     *      // Save Scene
                     *      case 0:
                     *              Debug.Log("ONLY");
                     *              break;
                     *
                     *      // Save and Quit.
                     *
                     *      // SAVE THIS MASK FOR CHILDREN AS WELL.
                     *      case 1:
                     *              Debug.Log("CHILDREN");
                     *              break;
                     *
                     *      case 2:
                     *              Debug.Log("CANCEL");
                     *              break;
                     *
                     *
                     *      default:
                     *              Debug.LogError( "Unrecognized option." );
                     *              break;
                     * }
                     */
                }
            }

            GUILayout.FlexibleSpace();

            if (GUILayout.Button("Select"))
            {
                po.model.selectAndPanToPO(po);
            }


            GUILayout.EndHorizontal();
        }


        if (po.is3D())
        {
            EditorGUIUtility.labelWidth = 35;

            GUILayout.BeginHorizontal();


            // TAGS
            EditorGUI.BeginChangeCheck();
            po.tag = EditorGUILayout.TagField("Tag:", po.tag);

            if (EditorGUI.EndChangeCheck())
            {
                Undo.RegisterCompleteObjectUndo(po.model, "Tag value change for " + po.Name);
            }



            // LAYERS
            EditorGUI.BeginChangeCheck();
            int intval = EditorGUILayout.LayerField("Layer:", po.layer);

            if (EditorGUI.EndChangeCheck())
            {
                Undo.RegisterCompleteObjectUndo(po.model, "Layer value change for " + po.Name);
                po.layer = intval;
            }


            GUILayout.EndHorizontal();

            bool hasMeshRenderer = !po.noMeshRenderer;
            EditorGUI.BeginChangeCheck();
            hasMeshRenderer = EditorGUILayout.ToggleLeft("Mesh Renderer", hasMeshRenderer);
            if (EditorGUI.EndChangeCheck())
            {
                Undo.RegisterCompleteObjectUndo(po.model, "hasMeshRenderer");
                po.noMeshRenderer = !hasMeshRenderer;
            }
        }
        else if (po.generator is MaterialTool)
        {
            EditorGUI.BeginChangeCheck();

            //float thumbSize = 16;

            po.axMat.mat = (Material)EditorGUILayout.ObjectField(po.axMat.mat, typeof(Material), true);
            if (EditorGUI.EndChangeCheck())
            {
                Undo.RegisterCompleteObjectUndo(po.model, "Material");

                po.model.remapMaterialTools();
                po.model.autobuild();
            }
        }



        AXParameter p;



        //EditorGUIUtility.labelWidth = 200;//EditorGUIUtility.currentViewWidth-16;

        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;

                EditorGUIUtility.labelWidth = 150;



                // PARAMETERS
                switch (p.Type)
                {
                // ANIMATION_CURVE

                case AXParameter.DataType.AnimationCurve:

                    EditorGUI.BeginChangeCheck();
                    EditorGUILayout.CurveField(p.animationCurve);
                    if (EditorGUI.EndChangeCheck())
                    {
                        Undo.RegisterCompleteObjectUndo(p.parametricObject.model, "ModifierCurve");
                        p.parametricObject.model.isAltered(28);
                    }

                    break;

                // FLOAT
                case AXParameter.DataType.Float:
                    AXEditorUtilities.assertFloatFieldKeyCodeValidity("FloatField_" + p.Name);

                    GUILayout.BeginHorizontal();



                    EditorGUI.BeginChangeCheck();
                    GUI.SetNextControlName("FloatField_" + p.Name);
                    p.FloatVal = EditorGUILayout.FloatField(p.Name, p.FloatVal);
                    if (EditorGUI.EndChangeCheck())
                    {
                        //Debug.Log(p.FloatVal);
                        Undo.RegisterCompleteObjectUndo(po.model, "value change for " + p.Name);
                        p.parametricObject.initiateRipple_setFloatValueFromGUIChange(p.Name, p.FloatVal);
                        p.parametricObject.model.isAltered(27);
                        p.parametricObject.generator.adjustWorldMatrices();
                    }

                    // Expose
                    EditorGUI.BeginChangeCheck();
                    p.exposeAsInterface = EditorGUILayout.Toggle(p.exposeAsInterface, GUILayout.MaxWidth(20));
                    if (EditorGUI.EndChangeCheck())
                    {
                        Undo.RegisterCompleteObjectUndo(p.parametricObject.model, "Expose Parameter");

                        if (p.exposeAsInterface)
                        {
                            p.parametricObject.model.addExposedParameter(p);
                        }
                        else
                        {
                            p.parametricObject.model.removeExposedParameter(p);
                        }
                    }


                    GUILayout.EndHorizontal();
                    break;

                // INT
                case AXParameter.DataType.Int:

                    GUILayout.BeginHorizontal();



                    EditorGUI.BeginChangeCheck();
                    GUI.SetNextControlName("IntField_" + p.Name);
                    p.intval = EditorGUILayout.IntField(p.Name, p.intval);
                    if (EditorGUI.EndChangeCheck())
                    {
                        Undo.RegisterCompleteObjectUndo(po.model, "value change for " + p.Name);
                        p.parametricObject.initiateRipple_setFloatValueFromGUIChange(p.Name, p.intval);
                        p.parametricObject.model.isAltered(28);
                        p.parametricObject.generator.adjustWorldMatrices();
                    }

                    // Expose
                    EditorGUI.BeginChangeCheck();
                    p.exposeAsInterface = EditorGUILayout.Toggle(p.exposeAsInterface, GUILayout.MaxWidth(20));
                    if (EditorGUI.EndChangeCheck())
                    {
                        Undo.RegisterCompleteObjectUndo(p.parametricObject.model, "Expose Parameter");

                        if (p.exposeAsInterface)
                        {
                            p.parametricObject.model.addExposedParameter(p);
                        }
                        else
                        {
                            p.parametricObject.model.removeExposedParameter(p);
                        }
                    }


                    GUILayout.EndHorizontal();
                    break;

                // BOOL
                case AXParameter.DataType.Bool:
                    //EditorGUIUtility.currentViewWidth-16;

                    GUILayout.BeginHorizontal();



                    //EditorGUIUtility.labelWidth = 150;
                    EditorGUI.BeginChangeCheck();
                    p.boolval = EditorGUILayout.Toggle(p.Name, p.boolval);
                    if (EditorGUI.EndChangeCheck())
                    {
                        Undo.RegisterCompleteObjectUndo(po.model, " value change for " + p.Name);
                        p.parametricObject.initiateRipple_setBoolParameterValueByName(p.Name, p.boolval);
                        //p.parametricObject.model.autobuild();
                        p.parametricObject.model.isAltered(27);
                        //p.parametricObject.generator.adjustWorldMatrices();
                    }

                    GUILayout.FlexibleSpace();

                    // Expose
                    EditorGUI.BeginChangeCheck();
                    p.exposeAsInterface = EditorGUILayout.Toggle(p.exposeAsInterface, GUILayout.MaxWidth(20));
                    if (EditorGUI.EndChangeCheck())
                    {
                        Undo.RegisterCompleteObjectUndo(p.parametricObject.model, "Expose Parameter");

                        if (p.exposeAsInterface)
                        {
                            p.parametricObject.model.addExposedParameter(p);
                        }
                        else
                        {
                            p.parametricObject.model.removeExposedParameter(p);
                        }
                    }


                    GUILayout.EndHorizontal();
                    break;


                case AXParameter.DataType.CustomOption:
                {
                    // OPTION POPUP

                    string[] options = p.optionLabels.ToArray();

                    EditorGUI.BeginChangeCheck();
                    GUI.SetNextControlName("CustomOptionPopup_" + p.Guid + "_" + p.Name);
                    p.intval = EditorGUILayout.Popup(
                        p.Name,
                        p.intval,
                        options);
                    if (EditorGUI.EndChangeCheck())
                    {
                        Undo.RegisterCompleteObjectUndo(p.Parent.model, "value change for " + p.Name);
                        p.parametricObject.model.autobuild();

                        if (p.PType == AXParameter.ParameterType.PositionControl)
                        {
                            p.parametricObject.generator.adjustWorldMatrices();
                        }
                    }

                    break;
                }
                }

                //if (p.PType != AXParameter.ParameterType.None && p.PType != AXParameter.ParameterType.GeometryControl)
                //	continue;
            }
        }


        // PROTOTYPE
        if (po.is3D())
        {
            po.displayPrototypes = EditorGUILayout.Foldout(po.displayPrototypes, "Prototypes");

            if (po.displayPrototypes)
            {
                EditorGUI.BeginChangeCheck();
                po.prototypeGameObject = (GameObject)EditorGUILayout.ObjectField(po.prototypeGameObject, typeof(GameObject), true);
                if (EditorGUI.EndChangeCheck())
                {
                    Undo.RegisterCompleteObjectUndo(po.model, "Prototype GameObject set for " + po.model.name);
                    if (po.prototypeGameObject != null)
                    {
                        AXPrototype proto = (AXPrototype)po.prototypeGameObject.GetComponent("AXPrototype");
                        if (proto == null)
                        {
                            proto = po.prototypeGameObject.AddComponent <AXPrototype>();
                        }
                        if (!proto.parametricObjects.Contains(po))
                        {
                            proto.parametricObjects.Add(po);
                        }
                    }
                    po.model.autobuild();
                }
            }
        }


        if (po.selectedAXGO != null)
        {
            GUILayout.Label(po.selectedAXGO.consumerAddress);
        }
        GUILayout.Space(30);
    }