Esempio n. 1
0
 public static void Insert(Spline spline, int controlPointIndex)
 {
     RecordHierarchy(spline.Root, "Battlehub.Spline.Insert");
     spline.Insert((controlPointIndex + 2) / 3);
     EditorUtility.SetDirty(spline);
 }
Esempio n. 2
0
 public static void Prepend(Spline spline)
 {
     RecordHierarchy(spline.Root, "Battlehub.Spline.Prepend");
     spline.Prepend();
     EditorUtility.SetDirty(spline);
 }
Esempio n. 3
0
        protected override void OnInspectorGUIOverride()
        {
            if (m_spline == null)
            {
                m_spline = (Spline)GetTarget();
            }

            if (m_spline == null)
            {
                return;
            }

            EditorGUI.BeginChangeCheck();
            bool loop = EditorGUILayout.Toggle("Loop", m_spline.Loop);

            if (EditorGUI.EndChangeCheck())
            {
                ToggleLoop(loop);
            }

            GUILayout.BeginHorizontal();
            {
                GUILayout.BeginVertical();
                if (m_spline.NextSpline == null)
                {
                    if (GUILayout.Button("Append"))
                    {
                        Append(m_spline);
                    }
                }

                if (m_spline.PrevSpline == null)
                {
                    if (GUILayout.Button("Prepend"))
                    {
                        Prepend(m_spline);
                    }
                }
                if (GUILayout.Button("Set Free"))
                {
                    SetMode(m_spline, ControlPointMode.Free);
                }

                if (GUILayout.Button("Set Aligned"))
                {
                    SetMode(m_spline, ControlPointMode.Aligned);
                }
                GUILayout.EndVertical();

                GUILayout.BeginVertical();


                if (m_spline.NextSpline == null)
                {
                    if (SceneView.lastActiveSceneView != null && SceneView.lastActiveSceneView.camera)
                    {
                        if (GUILayout.Button("To Cam"))
                        {
                            AppendThrough(m_spline, SceneView.lastActiveSceneView.camera.transform);
                        }
                    }
                }

                if (m_spline.PrevSpline == null)
                {
                    if (SceneView.lastActiveSceneView != null && SceneView.lastActiveSceneView.camera)
                    {
                        if (GUILayout.Button("To Cam"))
                        {
                            PrependThrough(m_spline, SceneView.lastActiveSceneView.camera.transform);
                        }
                    }
                }

                if (GUILayout.Button("Set Mirrored"))
                {
                    SetMode(m_spline, ControlPointMode.Mirrored);
                }

                if (GUILayout.Button("Smooth"))
                {
                    Smooth(m_spline);
                }
                GUILayout.EndVertical();
            }
            GUILayout.EndHorizontal();
        }
Esempio n. 4
0
        protected override SplineBase GetTarget()
        {
            Spline spline = (Spline)target;

            return(spline);
        }
Esempio n. 5
0
 public void Awake()
 {
     m_spline = GetSelectedSpline();
     RuntimeSelection.SelectionChanged += OnRuntimeSelectionChanged;
 }
Esempio n. 6
0
        protected override void OnInspectorGUIOverride()
        {
            if (m_spline == null)
            {
                m_spline = (Spline)GetTarget();
            }

            if (m_spline == null)
            {
                return;
            }

            EditorGUI.BeginChangeCheck();
            bool loop = EditorGUILayout.Toggle("Loop", m_spline.Loop);

            if (EditorGUI.EndChangeCheck())
            {
                Undo.RecordObject(m_spline, UNDO_TOGGLELOOP);
                EditorUtility.SetDirty(m_spline);
                m_spline.Loop = loop;
            }

            GUILayout.BeginHorizontal();
            {
                if (GUILayout.Button("Append"))
                {
                    Undo.RecordObject(m_spline, "Battlehub.Spline.Append");
                    m_spline.Extend();
                    EditorUtility.SetDirty(m_spline);
                }

                if (GUILayout.Button("Prepend"))
                {
                    Undo.RecordObject(m_spline, "Battlehub.Spline.Prepend");
                    m_spline.Extend(true);
                    EditorUtility.SetDirty(m_spline);
                }
            }
            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal();
            {
                if (GUILayout.Button("Set Free Mode"))
                {
                    Undo.RecordObject(m_spline, "Battlehub.Spline.SetMode");
                    m_spline.SetControlPointMode(ControlPointMode.Free);
                    EditorUtility.SetDirty(m_spline);
                }

                if (GUILayout.Button("Set Aligned Mode"))
                {
                    Undo.RecordObject(m_spline, "Battlehub.Spline.SetMode");
                    m_spline.SetControlPointMode(ControlPointMode.Aligned);
                    EditorUtility.SetDirty(m_spline);
                }

                if (GUILayout.Button("Set Mirrored Mode"))
                {
                    Undo.RecordObject(m_spline, "Battlehub.Spline.SetMode");
                    m_spline.SetControlPointMode(ControlPointMode.Mirrored);
                    EditorUtility.SetDirty(m_spline);
                }
            }
            GUILayout.EndHorizontal();

            if (GUILayout.Button("Smooth"))
            {
                Undo.RecordObject(m_spline, "Battlehub.Spline.SetMode");
                m_spline.Smooth();
                EditorUtility.SetDirty(m_spline);
            }
        }
Esempio n. 7
0
        protected override void OnInspectorGUIOverride()
        {
            if (m_spline == null)
            {
                m_spline = GetTarget() as Spline;
            }

            if (m_spline == null)
            {
                return;
            }

            if (targets.Length == 1)
            {
                int curveIndex = (SelectedIndex - 1) / 3;
                GUILayout.BeginHorizontal();
                {
                    if (curveIndex == 0)
                    {
                        if (GUILayout.Button("Prepend"))
                        {
                            Undo.RecordObject(m_spline, "Battlehub.Spline.Prepend");
                            m_spline.Prepend();
                            EditorUtility.SetDirty(m_spline);
                            Selection.activeGameObject = m_spline.GetComponentsInChildren <SplineControlPoint>(true).First().gameObject;
                        }
                    }

                    if (GUILayout.Button("Insert"))
                    {
                        Undo.RecordObject(m_spline, "Battlehub.Spline.Insert");
                        m_spline.Insert((SelectedIndex + 2) / 3);
                        EditorUtility.SetDirty(m_spline);
                        Selection.activeGameObject = m_spline.GetComponentsInChildren <SplineControlPoint>(true).ElementAt(SelectedIndex + 3).gameObject;
                    }


                    if (curveIndex == m_spline.CurveCount - 1)
                    {
                        if (GUILayout.Button("Append"))
                        {
                            Undo.RecordObject(m_spline, "Battlehub.Spline.Append");
                            m_spline.Append();
                            EditorUtility.SetDirty(m_spline);
                            Selection.activeGameObject = m_spline.GetComponentsInChildren <SplineControlPoint>(true).Last().gameObject;
                        }
                    }
                }
                GUILayout.EndHorizontal();

                if (SelectedIndex >= 0 && curveIndex < m_spline.CurveCount)
                {
                    if (GUILayout.Button("Remove"))
                    {
                        Remove();
                    }
                }
            }

            base.OnInspectorGUIOverride();
        }