protected override void ShowPointOverride(SplineBase spline, int index, Vector3 point, Quaternion handleRotation, float size) { if (!spline.Loop) { if (index == spline.ControlPointCount - 1) { if (SceneView.lastActiveSceneView != null && SceneView.lastActiveSceneView.camera != null) { if ((SceneView.lastActiveSceneView.camera.transform.position - point).magnitude > 4.0f) { if (Handles.Button(point + spline.GetDirection(1.0f) * 1.5f, handleRotation, size * HandleSize, size * PickSize2, (id, p, r, s, e) => CapFunction(size, id, p, m_addButton, e))) { SplineEditor.Append((Spline)spline); Selection.activeGameObject = spline.GetSplineControlPoints().Last().gameObject; } } } } else if (index == 0) { if (SceneView.lastActiveSceneView != null && SceneView.lastActiveSceneView.camera != null) { if ((SceneView.lastActiveSceneView.camera.transform.position - point).magnitude > 4.0f) { if (Handles.Button(point - spline.GetDirection(0.0f) * 1.5f, handleRotation, size * HandleSize, size * PickSize2, (id, p, r, s, e) => CapFunction(size, id, p, m_addButton, e))) { SplineEditor.Prepend((Spline)spline); Selection.activeGameObject = spline.GetSplineControlPoints().First().gameObject; } } } } } }
public static void Prepend() { GameObject selected = Selection.activeObject as GameObject; Spline spline = selected.GetComponentInParent <Spline>(); SplineEditor.Prepend(spline); Selection.activeGameObject = spline.GetSplineControlPoints().First().gameObject; }
protected override void OnInspectorGUIOverride() { if (m_spline == null) { return; } if (ConvergingSpline) { if (GUILayout.Button("Cancel")) { ConvergingSpline = null; } return; } GUILayout.BeginHorizontal(); { GUILayout.BeginVertical(); int curveIndex = (SelectedIndex - 1) / 3; if (GUILayout.Button("OUT -> Branch")) { CreateBranch(m_spline, SelectedIndex, false); } if (curveIndex == m_spline.CurveCount - 1 && m_spline.NextSpline == null) { if (m_spline.NextSpline == null) { if (GUILayout.Button("Append")) { SplineEditor.Append(m_spline); Selection.activeGameObject = m_spline.GetSplineControlPoints().Last().gameObject; } } } if (curveIndex == 0 && m_spline.PrevSpline == null) { if (m_spline.PrevSpline == null) { if (GUILayout.Button("Prepend")) { SplineEditor.Prepend(m_spline); Selection.activeGameObject = m_spline.GetSplineControlPoints().First().gameObject; } } } if (GUILayout.Button("Insert")) { SplineEditor.Insert(m_spline, SelectedIndex); Selection.activeGameObject = m_spline.GetSplineControlPoints().ElementAt(SelectedIndex + 3).gameObject; } GUILayout.EndVertical(); GUILayout.BeginVertical(); if (GUILayout.Button("Branch -> IN")) { CreateBranch(m_spline, SelectedIndex, true); } if (curveIndex == m_spline.CurveCount - 1 && m_spline.NextSpline == null) { if (m_spline.NextSpline == null) { if (SceneView.lastActiveSceneView != null && SceneView.lastActiveSceneView.camera) { if (GUILayout.Button("To Cam")) { SplineEditor.AppendThrough(m_spline, SceneView.lastActiveSceneView.camera.transform); Selection.activeGameObject = m_spline.GetSplineControlPoints().Last().gameObject; } } } } if (curveIndex == 0 && m_spline.PrevSpline == null) { if (m_spline.PrevSpline == null) { if (SceneView.lastActiveSceneView != null && SceneView.lastActiveSceneView.camera) { if (GUILayout.Button("To Cam")) { SplineEditor.PrependThrough(m_spline, SceneView.lastActiveSceneView.camera.transform); Selection.activeGameObject = m_spline.GetSplineControlPoints().First().gameObject; } } } } if (SelectedIndex >= 0 && curveIndex < m_spline.CurveCount) { if (GUILayout.Button("Remove")) { Remove(m_spline, SelectedIndex); } } GUILayout.EndVertical(); } GUILayout.EndHorizontal(); if (SelectedIndex == 0 && m_spline.PrevSpline == null || SelectedIndex == m_spline.ControlPointCount - 1 && m_spline.NextSpline == null) { if (!m_spline.HasBranches(SelectedIndex)) { if (GUILayout.Button("Converge")) { if (m_spline.Loop) { EditorUtility.DisplayDialog("Unable to converge", "Unable to converge. Selected spline has loop.", "OK"); } else { ConvergingSpline = m_spline; } } } } if (SelectedIndex < m_spline.ControlPointCount && SelectedIndex >= 0) { if (m_spline.HasBranches(SelectedIndex)) { if (GUILayout.Button("Separate")) { Separate(m_spline, SelectedIndex); } } } if (GUILayout.Button("Align View To Point")) { if (SceneView.lastActiveSceneView != null) { SplineControlPoint controlPoint = (SplineControlPoint)target; SceneView.lastActiveSceneView.AlignViewToObject(controlPoint.transform); SceneView.lastActiveSceneView.Repaint(); } } base.OnInspectorGUIOverride(); }