Esempio n. 1
0
        protected override void OnInspectorGUIOverride()
        {
            if (m_spline == null)
            {
                m_spline = GetTarget() as Spline;
            }

            if (m_spline == null)
            {
                return;
            }

            int curveIndex = (SelectedIndex - 1) / 3;

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

                if (curveIndex == 0)
                {
                    if (GUILayout.Button("Prepend"))
                    {
                        Undo.RecordObject(m_spline, "Battlehub.Spline.Prepend");
                        m_spline.Extend(true);
                        EditorUtility.SetDirty(m_spline);
                        Selection.activeGameObject = m_spline.GetComponentsInChildren <SplineControlPoint>(true).First().gameObject;
                    }
                }
            }
            GUILayout.EndHorizontal();

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

            base.OnInspectorGUIOverride();
        }
Esempio n. 2
0
        private static void Prepend()
        {
            GameObject selected = Selection.activeObject as GameObject;
            Spline     spline   = selected.GetComponentInParent <Spline>();

            Undo.RecordObject(spline, "Battlehub.Spline.Prepend");
            spline.Extend(true);
            EditorUtility.SetDirty(spline);
            Selection.activeGameObject = spline.GetComponentsInChildren <SplineControlPoint>(true).First().gameObject;
        }
Esempio n. 3
0
 public virtual void Prepend()
 {
     if (SplineRuntimeEditor.Instance != null)
     {
         Spline spline = SplineRuntimeEditor.Instance.SelectedSpline as Spline;
         if (spline != null)
         {
             spline.Extend(true);
         }
     }
 }
Esempio n. 4
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);
            }
        }