private void AddControlPoint() { serializedObject.Update(); Undo.RecordObject(LineData, "Add Spline Control Point"); var newControlPoints = new MixedRealityPose[3]; Vector3 direction = LineData.GetVelocity(0.99f); float distance = Mathf.Max(LineData.UnClampedWorldLength * 0.05f, OverlappingPointThreshold * 5); newControlPoints[0].Position = LineData.LastPoint + (direction * distance); newControlPoints[1].Position = newControlPoints[0].Position + (direction * distance); newControlPoints[2].Position = newControlPoints[1].Position + (direction * distance); for (int i = 0; i < 3; i++) { controlPoints.arraySize = controlPoints.arraySize + 1; var newControlPointProperty = controlPoints.GetArrayElementAtIndex(controlPoints.arraySize - 1); newControlPointProperty.FindPropertyRelative("position").vector3Value = newControlPoints[i].Position; newControlPointProperty.FindPropertyRelative("rotation").quaternionValue = Quaternion.identity; } serializedObject.ApplyModifiedProperties(); }