public int IndexOf(BezierPoint point) { return(endPoints.IndexOf(point)); }
public void Internal_MovePoint(int previousIndex, int newIndex, string undo) { if (previousIndex == newIndex) { return; } if (previousIndex < 0 || previousIndex >= endPoints.Count || newIndex < 0 || newIndex >= endPoints.Count) { Debug.LogError("Indices must be in range [0," + (endPoints.Count - 1) + "]"); return; } BezierPoint point1 = endPoints[previousIndex]; BezierPoint point2 = endPoints[newIndex]; if (previousIndex < newIndex) { for (int i = previousIndex; i < newIndex; i++) { endPoints[i] = endPoints[i + 1]; } } else { for (int i = previousIndex; i > newIndex; i--) { endPoints[i] = endPoints[i - 1]; } } endPoints[newIndex] = point1; Transform point2Parent = point2.transform.parent; if (point1.transform.parent != point2Parent) { #if UNITY_EDITOR if (undo != null) { UnityEditor.Undo.SetTransformParent(point1.transform, point2Parent, undo); UnityEditor.Undo.RegisterCompleteObjectUndo(point2Parent, undo); } else #endif point1.transform.SetParent(point2Parent, true); int point2SiblingIndex = point2.transform.GetSiblingIndex(); if (previousIndex < newIndex) { if (point1.transform.GetSiblingIndex() < point2SiblingIndex) { point1.transform.SetSiblingIndex(point2SiblingIndex); } else { point1.transform.SetSiblingIndex(point2SiblingIndex + 1); } } else { if (point1.transform.GetSiblingIndex() < point2SiblingIndex) { point1.transform.SetSiblingIndex(point2SiblingIndex - 1); } else { point1.transform.SetSiblingIndex(point2SiblingIndex); } } } else { point1.transform.SetSiblingIndex(point2.transform.GetSiblingIndex()); } #if UNITY_EDITOR Refresh(); #endif }