Exemple #1
0
        private static void Insert()
        {
            GameObject         selected  = Selection.activeObject as GameObject;
            Spline             spline    = selected.GetComponentInParent <Spline>();
            SplineControlPoint ctrlPoint = selected.GetComponent <SplineControlPoint>();

            Undo.RecordObject(spline, "Battlehub.Spline.Insert");

            spline.Insert((ctrlPoint.Index + 2) / 3);

            EditorUtility.SetDirty(spline);
            Selection.activeGameObject = spline.GetComponentsInChildren <SplineControlPoint>(true).ElementAt(ctrlPoint.Index + 3).gameObject;
        }
Exemple #2
0
        public virtual void Insert()
        {
            Spline spline = SplineRuntimeEditor.Instance.SelectedSpline as Spline;

            if (spline != null)
            {
                GameObject selection = RuntimeSelection.activeGameObject;
                if (selection != null)
                {
                    SplineControlPoint ctrlPoint = selection.GetComponent <SplineControlPoint>();
                    if (ctrlPoint != null)
                    {
                        spline.Insert((ctrlPoint.Index + 2) / 3);
                    }
                }
            }
        }
Exemple #3
0
 public static void Insert(Spline spline, int controlPointIndex)
 {
     RecordHierarchy(spline.Root, "Battlehub.Spline.Insert");
     spline.Insert((controlPointIndex + 2) / 3);
     EditorUtility.SetDirty(spline);
 }
Exemple #4
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();
        }