public static bool CanConverge() { if (SplineBaseEditor.ConvergingSpline) { return(false); } GameObject selected = Selection.activeObject as GameObject; if (selected == null) { return(false); } SplineControlPoint ctrlPoint = selected.GetComponent <SplineControlPoint>(); Spline spline = selected.GetComponentInParent <Spline>(); if (spline == null || ctrlPoint == null) { return(false); } if (ctrlPoint.Index == 0 && spline.PrevSpline == null || ctrlPoint.Index == spline.ControlPointCount - 1 && spline.NextSpline == null) { if (!spline.HasBranches(ctrlPoint.Index)) { return(true); } } return(false); }
public static bool CanSeparate() { if (SplineBaseEditor.ConvergingSpline) { return(false); } GameObject selected = Selection.activeObject as GameObject; if (selected == null) { return(false); } SplineControlPoint ctrlPoint = selected.GetComponent <SplineControlPoint>(); Spline spline = selected.GetComponentInParent <Spline>(); if (spline == null || ctrlPoint == null) { return(false); } return(spline.HasBranches(ctrlPoint.Index)); }
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(); }