Ejemplo n.º 1
0
    public override void OnInspectorGUI()
    {
        AXPrototype proto = (AXPrototype)target;

        if (proto.parametricObjects != null && proto.parametricObjects.Count > 0)
        {
            GUIStyle labelstyle = GUI.skin.GetStyle("Label");
            labelstyle.fixedWidth = 350;

            String nodesWord = (proto.parametricObjects.Count == 1) ? "node" : "nodes";
            GUILayout.Label(proto.parametricObjects.Count + " " + nodesWord + " using this as a prototype:");
            for (int i = 0; i < proto.parametricObjects.Count; i++)
            {
                //GUILayout.Label(proto.parametricObjects[i].Name);
                if (GUILayout.Button(proto.parametricObjects[i].Name))
                {
                    proto.parametricObjects[i].model.selectAndPanToPO(proto.parametricObjects[i]);
                    Selection.activeGameObject = proto.parametricObjects[i].model.gameObject;
                }
            }
        }
    }
Ejemplo n.º 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;
    }
Ejemplo n.º 3
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);
    }