Esempio n. 1
0
        public override void OnInspectorGUI()
        {
            EditorGUILayout.HelpBox("This component is obsolete! Use SplineController instead!", MessageType.Warning);
            serializedObject.UpdateIfDirtyOrScript();

            if (CurvyGUI.Foldout(ref mFoldouts[0], "Source", CurvyEditorUtility.HelpURL("aligntospline", "source")))
            {
                var ppSpline = serializedObject.FindProperty("m_Spline");
                EditorGUILayout.PropertyField(ppSpline);
                if (ppSpline.objectReferenceValue == null)
                {
                    EditorGUILayout.HelpBox("No Source provided!", MessageType.Warning);
                }

                EditorGUILayout.PropertyField(serializedObject.FindProperty("m_Dynamic"));
                EditorGUILayout.PropertyField(serializedObject.FindProperty("FastInterpolation"));
                EditorGUILayout.PropertyField(serializedObject.FindProperty("UpdateIn"));
            }

            if (CurvyGUI.Foldout(ref mFoldouts[1], "Options", CurvyEditorUtility.HelpURL("aligntospline", "options")))
            {
                EditorGUILayout.PropertyField(serializedObject.FindProperty("m_Mode"));
                EditorGUILayout.PropertyField(serializedObject.FindProperty("m_Position"));
                EditorGUILayout.PropertyField(serializedObject.FindProperty("SetOrientation"));
                EditorGUILayout.PropertyField(serializedObject.FindProperty("Use2DOrientation"));
            }


            serializedObject.ApplyModifiedProperties();
        }
Esempio n. 2
0
        public override void OnInspectorGUI()
        {
            serializedObject.UpdateIfDirtyOrScript();

            if (CurvyGUI.Foldout(ref mFoldouts[0], "Source", CurvyEditorUtility.HelpURL("followspline", "source")))
            {
                var ppSpline = serializedObject.FindProperty("m_Spline");
                EditorGUILayout.PropertyField(ppSpline);
                if (ppSpline.objectReferenceValue == null)
                {
                    EditorGUILayout.HelpBox("No Source provided!", MessageType.Warning);
                }
                EditorGUILayout.PropertyField(serializedObject.FindProperty("m_Dynamic"));
                EditorGUILayout.PropertyField(serializedObject.FindProperty("FastInterpolation"));
                EditorGUILayout.PropertyField(serializedObject.FindProperty("UpdateIn"));
            }

            if (CurvyGUI.Foldout(ref mFoldouts[1], "Options", CurvyEditorUtility.HelpURL("followspline", "options")))
            {
                EditorGUILayout.PropertyField(serializedObject.FindProperty("m_Mode"));
                EditorGUILayout.PropertyField(serializedObject.FindProperty("Speed"));
                EditorGUILayout.PropertyField(serializedObject.FindProperty("Clamping"));
                EditorGUILayout.PropertyField(serializedObject.FindProperty("SetOrientation"));
                EditorGUILayout.PropertyField(serializedObject.FindProperty("Use2DOrientation"));
            }
            EditorGUILayout.PropertyField(serializedObject.FindProperty("m_Initial"));

            serializedObject.ApplyModifiedProperties();

            ShowPreviewButtons();
        }
Esempio n. 3
0
 protected override void OnCustomInspectorGUI()
 {
     if (CurvyGUI.Foldout(ref mPreviewFoldout, "Preview"))
     {
         GUILayout.BeginHorizontal();
         if (GUILayout.Toggle(mRunningInEditor, new GUIContent("Play/Replay in Editor"), GUI.skin.button) != mRunningInEditor)
         {
             StartPreview();
         }
         if (GUILayout.Button(new GUIContent("Stop")))
         {
             StopPreview();
         }
         GUILayout.EndHorizontal();
     }
 }
 /// <summary>
 /// Show the preview buttons
 /// </summary>
 protected void ShowPreviewButtons()
 {
     if (CurvyGUI.Foldout(ref mPreviewFoldout, "Preview"))
     {
         GUILayout.BeginHorizontal();
         if (GUILayout.Toggle(mRunningInEditor, new GUIContent(mTexPlay, "Play/Replay in Editor"), GUI.skin.button) != mRunningInEditor)
         {
             StartPreview();
         }
         if (GUILayout.Button(new GUIContent(mTexStop, "Stop")))
         {
             StopPreview();
         }
         GUILayout.EndHorizontal();
     }
 }
Esempio n. 5
0
        public override void OnInspectorGUI()
        {
            Toolbar.RegisterTargets(targets);

            EditorGUILayout.PropertyField(tInterpolation, new GUIContent("Interpolation", "Interpolation Method"));
            EditorGUILayout.PropertyField(tClosed, new GUIContent("Close Spline", "Close spline?"));
            GUI.enabled = !tClosed.boolValue && tInterpolation.enumNames[tInterpolation.enumValueIndex] != "Linear" && tInterpolation.enumNames[tInterpolation.enumValueIndex] != "Bezier";
            EditorGUILayout.PropertyField(tAutoEndTangents, new GUIContent("Auto End Tangents", "Handle End Control Points automatically?"));
            GUI.enabled = true;
            EditorGUILayout.PropertyField(tGranularity, new GUIContent("Granularity", "Approximation resolution"));
            tGranularity.intValue = Mathf.Max(1, tGranularity.intValue);

            if (CurvyGUI.Foldout(ref mFoldouts[0], "Orientation", CurvyEditorUtility.HelpURL("curvyspline", "orientation")))
            {
                EditorGUILayout.PropertyField(tOrientation, new GUIContent("Orientation", "How the Up-Vector should be calculated"));
                GUI.enabled = Target.Interpolation != CurvyInterpolation.Bezier;
                EditorGUILayout.PropertyField(tSetCPRotation, new GUIContent("Set CP Rotation", "Rotate CP to match calculated Up-Vector3"));
                GUI.enabled = true;
                if (tOrientation.enumNames[tOrientation.enumValueIndex] == "Tangent")
                {
                    EditorGUILayout.PropertyField(tInitialUp, new GUIContent("Initial Up-Vector", "How the first Up-Vector should be determined"));
                    EditorGUILayout.PropertyField(tSwirl, new GUIContent("Swirl", "Orientation swirl mode"));
                    if (tSwirl.enumNames[tSwirl.enumValueIndex] != "None")
                    {
                        EditorGUILayout.PropertyField(tSwirlTurns, new GUIContent("Turns", "Swirl turns"));
                    }
                }
            }
            if (CurvyGUI.Foldout(ref mFoldouts[1], "Updates", CurvyEditorUtility.HelpURL("curvyspline", "updates")))
            {
                EditorGUILayout.PropertyField(tAutoRefresh, new GUIContent("Auto Refresh", "Refresh when Control Point position change?"));
                EditorGUILayout.PropertyField(tAutoRefreshLength, new GUIContent("Auto Refresh Length", "Recalculate Length on Refresh?"));
                EditorGUILayout.PropertyField(tAutoRefreshOrientation, new GUIContent("Auto Refresh Orientation", "Recalculate tangent normals and Up-Vectors on Refresh?"));
            }
            if (tInterpolation.enumNames[tInterpolation.enumValueIndex] == "TCB" && CurvyGUI.Foldout(ref mFoldouts[2], "TCB Settings", CurvyEditorUtility.HelpURL("curvyspline", "tcb")))
            {
                EditorGUILayout.PropertyField(tT, new GUIContent("Tension", "Tension for TCB-Spline"));
                EditorGUILayout.PropertyField(tC, new GUIContent("Continuity", "Continuity for TCB-Spline"));
                EditorGUILayout.PropertyField(tB, new GUIContent("Bias", "Bias for TCB-Spline"));

                EditorGUILayout.BeginHorizontal();
                if (GUILayout.Button(new GUIContent("Set Catmul", "Set TCB to match Catmul Rom")))
                {
                    tT.floatValue = 0; tC.floatValue = 0; tB.floatValue = 0;
                }
                if (GUILayout.Button(new GUIContent("Set Cubic", "Set TCB to match Simple Cubic")))
                {
                    tT.floatValue = -1; tC.floatValue = 0; tB.floatValue = 0;
                }
                if (GUILayout.Button(new GUIContent("Set Linear", "Set TCB to match Linear")))
                {
                    tT.floatValue = 0; tC.floatValue = -1; tB.floatValue = 0;
                }
                EditorGUILayout.EndHorizontal();
            }



            if (serializedObject.targetObject && serializedObject.ApplyModifiedProperties())
            {
                Target.Refresh(true, true, false);
                SceneView.RepaintAll();
            }

            if (CurvyGUI.Foldout(ref mFoldouts[3], "Spline Info"))
            {
                EditorGUILayout.LabelField("Control Points: " + Target.ControlPointCount);
                EditorGUILayout.LabelField("Segments: " + Target.Count);
                EditorGUILayout.LabelField("Total Length: " + Target.Length);
                EditorGUILayout.LabelField(new GUIContent("User Value Size: " + Target.UserValueSize, "Size of User Value array"));
            }
            Repaint();
        }
Esempio n. 6
0
        public override void OnInspectorGUI()
        {
            Toolbar.RegisterTargets(targets);

            serializedObject.UpdateIfDirtyOrScript();
            if (Event.current.type == EventType.Layout)
            {
                mValid = Target.IsValidSegment;
            }

            if (mValid && (Target.Spline.Closed || !Target.IsFirstSegment))
            {
                EditorGUILayout.PropertyField(tSmoothTangent, new GUIContent("Smooth Tangent", "Smooth end tangent?"));
            }

            if (Target.Spline.Interpolation == CurvyInterpolation.Bezier && CurvyGUI.Foldout(ref mFoldouts[0], "Bezier Handles", CurvyEditorUtility.HelpURL("curvysplinesegment", "bezier")))
            {
                EditorGUILayout.PropertyField(tFreeHandles, new GUIContent("Free Move", "Move Handles individually?"));
                EditorGUILayout.Slider(tHandleScale, 0, 10, new GUIContent("Scale", "Handle Scaling"));

                Vector3 v = tHandleIn.vector3Value;
                EditorGUILayout.PropertyField(tHandleIn);
                if (v != tHandleIn.vector3Value && !tFreeHandles.boolValue)
                {
                    tHandleOut.vector3Value = -tHandleIn.vector3Value;
                }
                v = tHandleIn.vector3Value;
                EditorGUILayout.PropertyField(tHandleOut);
                if (v != tHandleOut.vector3Value && !tFreeHandles.boolValue)
                {
                    tHandleIn.vector3Value = -tHandleOut.vector3Value;
                }

                EditorGUILayout.LabelField("Smooth Handles", EditorStyles.boldLabel);

                SmoothingOffset = EditorGUILayout.Slider(new GUIContent("Offset", "Smoothing Offset"), SmoothingOffset, 0.1f, 1f);
                if (GUILayout.Button(new GUIContent("Smooth", "Set Handles by Catmul-Rom")))
                {
#if OLD_UNDO
                    Undo.RegisterUndo(targets, "Smooth Bezier Handles");
#else
                    Undo.RecordObjects(targets, "Smooth Bezier Handles");
#endif
                    foreach (CurvySplineSegment tgt in targets)
                    {
                        CurvyUtility.InterpolateBezierHandles(CurvyInterpolation.CatmulRom, SmoothingOffset, tgt.FreeHandles, tgt);
                    }
                    Target.Spline.RefreshImmediately(true, true, false);
                    SceneView.RepaintAll();
                }
            }


            if (mValid && Target.Spline.Interpolation == CurvyInterpolation.TCB && CurvyGUI.Foldout(ref mFoldouts[0], "TCB Settings", CurvyEditorUtility.HelpURL("curvysplinesegment", "tcb")))
            {
                EditorGUILayout.PropertyField(tSyncStartEnd, new GUIContent("Synchronize TCB", "Synchronize Start and End Values"));
                EditorGUILayout.PropertyField(tOT, new GUIContent("Local Tension", "Override Spline Tension?"));
                if (tOT.boolValue)
                {
                    EditorGUILayout.PropertyField(tT0, Target.SynchronizeTCB ? new GUIContent("Tension", "Tension") : new GUIContent("Start Tension", "Start Tension"));
                    if (!Target.SynchronizeTCB)
                    {
                        EditorGUILayout.PropertyField(tT1, new GUIContent("End Tension", "End Tension"));
                    }
                    else
                    {
                        tT1.floatValue = tT0.floatValue;
                    }
                }
                EditorGUILayout.PropertyField(tOC, new GUIContent("Local Continuity", "Override Spline Continuity?"));
                if (tOC.boolValue)
                {
                    EditorGUILayout.PropertyField(tC0, Target.SynchronizeTCB ? new GUIContent("Continuity", "Continuity") : new GUIContent("Start Continuity", "Start Continuity"));
                    if (!Target.SynchronizeTCB)
                    {
                        EditorGUILayout.PropertyField(tC1, new GUIContent("End Continuity", "End Continuity"));
                    }
                    else
                    {
                        tC1.floatValue = tC0.floatValue;
                    }
                }
                EditorGUILayout.PropertyField(tOB, new GUIContent("Local Bias", "Override Spline Bias?"));
                if (tOB.boolValue)
                {
                    EditorGUILayout.PropertyField(tB0, Target.SynchronizeTCB ? new GUIContent("Bias", "Bias") : new GUIContent("Start Bias", "Start Bias"));
                    if (!Target.SynchronizeTCB)
                    {
                        EditorGUILayout.PropertyField(tB1, new GUIContent("End Bias", "End Bias"));
                    }
                    else
                    {
                        tB1.floatValue = tB0.floatValue;
                    }
                }

                if (tOT.boolValue || tOC.boolValue || tOB.boolValue)
                {
                    EditorGUILayout.BeginHorizontal();

                    if (GUILayout.Button("Set Catmul"))
                    {
                        tT0.floatValue = 0; tC0.floatValue = 0; tB0.floatValue = 0;
                        tT1.floatValue = 0; tC1.floatValue = 0; tB1.floatValue = 0;
                    }
                    if (GUILayout.Button("Set Cubic"))
                    {
                        tT0.floatValue = -1; tC0.floatValue = 0; tB0.floatValue = 0;
                        tT1.floatValue = -1; tC1.floatValue = 0; tB1.floatValue = 0;
                    }
                    if (GUILayout.Button("Set Linear"))
                    {
                        tT0.floatValue = 0; tC0.floatValue = -1; tB0.floatValue = 0;
                        tT1.floatValue = 0; tC1.floatValue = -1; tB1.floatValue = 0;
                    }
                    EditorGUILayout.EndHorizontal();
                }
            }

            if (CurvyGUI.Foldout(ref mFoldouts[1], "User Values", CurvyEditorUtility.HelpURL("curvysplinesegment", "uservalues")))
            {
                EditorGUILayout.BeginHorizontal();
                if (GUILayout.Button(new GUIContent(mTexAddUserData, "Add User Value slot"), GUILayout.ExpandWidth(false), GUILayout.Height(mTexAddUserData.height)))
                {
                    Target.Spline.UserValueSize++;
                    Target.Spline.Refresh();
                    EditorUtility.SetDirty(Target.Spline);
                }


                if (GUILayout.Button(new GUIContent(mTexRemoveUserData, "Remove User Value slot"), GUILayout.ExpandWidth(false), GUILayout.Height(mTexRemoveUserData.height)))
                {
                    Target.Spline.UserValueSize--;
                    Target.Spline.Refresh();
                    EditorUtility.SetDirty(Target.Spline);
                }

                EditorGUILayout.EndHorizontal();

                if (Target.UserValues != null && Target.UserValues.Length > 0)
                {
                    ArrayGUI(serializedObject, "UserValues", false);
                }
            }


            if ((Target.Connection != null || Target.ConnectedBy.Count > 0) && CurvyGUI.Foldout(ref mFoldouts[2], "Connections", CurvyEditorUtility.HelpURL("curvysplinesegment", "connections")))
            {
                ConnectionGUI();
            }

            //EditorGUILayout.PropertyField(serializedObject.FindProperty("Node"));


            if ((serializedObject.targetObject && serializedObject.ApplyModifiedProperties()))
            {
                Target.Spline.Refresh(true, true, false);
                SceneView.RepaintAll();
            }

            if (mValid && CurvyGUI.Foldout(ref mFoldouts[3], "Segment Info"))
            {
                EditorGUILayout.LabelField(new GUIContent("Distance: " + Target.Distance, "Distance from first Control Point"));
                EditorGUILayout.LabelField(new GUIContent("Length: " + Target.Length, "Length of this segment"));
            }
            if (CurvyGUI.Foldout(ref mFoldouts[4], "Spline Info"))
            {
                EditorGUILayout.LabelField("Total Length: " + Target.Spline.Length);
            }
        }
Esempio n. 7
0
        void OnGUI()
        {
            if (Curves.Count == 0)
            {
                return;
            }

            scroll = EditorGUILayout.BeginScrollView(scroll);

            Mode = GUILayout.SelectionGrid(Mode, new GUIContent[]
            {
                new GUIContent("Closed Shape", "Export a closed shape with triangles"),
                new GUIContent("Vertex Line", "Export a vertex line")
            }, 2);

            if (!string.IsNullOrEmpty(TriangulationMessage) && !TriangulationMessage.Contains("Angle must be >0"))
            {
                EditorGUILayout.HelpBox(TriangulationMessage, MessageType.Error);
            }

            // OUTLINE
            if (CurvyGUI.Foldout(ref FoldOuts[0], "Outline Spline"))
            {
                CurveGUI(Curves[0], false);
            }
            if (Mode == CLOSEDSHAPE)
            {
                // HOLES
                if (CurvyGUI.Foldout(ref FoldOuts[1], "Holes"))
                {
                    for (int i = 1; i < Curves.Count; i++)
                    {
                        CurveGUI(Curves[i], true);
                    }
                    if (GUILayout.Button("Add Hole"))
                    {
                        Curves.Add(new SplinePolyLine(null));
                    }
                }
            }

            // TEXTURING
            if (CurvyGUI.Foldout(ref FoldOuts[2], "Texturing"))
            {
                Mat      = (Material)EditorGUILayout.ObjectField("Material", Mat, typeof(Material), true);
                UVTiling = EditorGUILayout.Vector2Field("Tiling", UVTiling);
                UVOffset = EditorGUILayout.Vector2Field("Offset", UVOffset);
            }
            // EXPORT

            if (CurvyGUI.Foldout(ref FoldOuts[3], "Export"))
            {
                EditorGUILayout.HelpBox("Export is 2D (x/y) only!", MessageType.Info);
                MeshName = EditorGUILayout.TextField("Mesh Name", MeshName);
                UV2      = EditorGUILayout.Toggle("Add UV2", UV2);

                GUILayout.BeginHorizontal();

                if (GUILayout.Button(new GUIContent(mTexSave, "Save as Asset")))
                {
                    string path = EditorUtility.SaveFilePanelInProject("Save Mesh", MeshName + ".asset", "asset", "Choose a file location");
                    if (!string.IsNullOrEmpty(path))
                    {
                        Mesh msh = clonePreviewMesh();
                        if (msh)
                        {
                            msh.name = MeshName;
                            AssetDatabase.DeleteAsset(path);
                            AssetDatabase.CreateAsset(msh, path);
                            AssetDatabase.SaveAssets();
                            AssetDatabase.Refresh();
                            Debug.Log("Curvy Export: Mesh Asset saved!");
                        }
                    }
                }

                if (GUILayout.Button(new GUIContent(mTexGO, "Create GameObject")))
                {
                    Mesh msh = clonePreviewMesh();
                    if (msh)
                    {
                        msh.name = MeshName;
                        var go = new GameObject(MeshName, typeof(MeshRenderer), typeof(MeshFilter));
                        go.GetComponent <MeshFilter>().sharedMesh       = msh;
                        go.GetComponent <MeshRenderer>().sharedMaterial = Mat;
                        Selection.activeGameObject = go;
                        Debug.Log("Curvy Export: GameObject created!");
                    }
                    else
                    {
                        Debug.LogWarning("Curvy Export: Unable to triangulate spline!");
                    }
                }
                GUILayout.EndHorizontal();
            }
            EditorGUILayout.EndScrollView();

            refreshNow = GUI.changed;
        }