diff --git a/CatmullRomSpline.cs b/CatmullRomSpline.cs index ca2821b..9c75e75 100644 --- a/CatmullRomSpline.cs +++ b/CatmullRomSpline.cs @@ -19,6 +19,8 @@ public class CatmullRomSpline : UdonSharpBehaviour [HideInInspector] public bool drawTangents; [HideInInspector] public float normalExtrusion; [HideInInspector] public float tangentExtrusion; + + [HideInInspector] public bool save; public Transform[] controlPointTransforms; @@ -187,6 +189,14 @@ private void GenerateSplinePoints() normals[currentPoint * resolution + tesselatedPoint] = pointNormal; } } + +#if !COMPILER_UDONSHARP && UNITY_EDITOR + if (save) + { + this.ApplyProxyModifications(); + save = false; + } +#endif } #region CALCULATE POINTS //Calculates curve position at t[0, 1] @@ -228,6 +238,10 @@ public Vector3 NormalFromTangent(Vector3 tangent) /// New transform array public void UpdateControlPointTransforms(Transform[] newControlPoints) { +#if !COMPILER_UDONSHARP && UNITY_EDITOR + this.UpdateProxy(); +#endif + if (newControlPoints == null || newControlPoints.Length <= 0) { Debug.LogError("Invalid control points"); @@ -247,6 +261,10 @@ public void UpdateControlPointTransforms(Transform[] newControlPoints) /// New vector3 array public void UpdateControlPointVectors(Vector3[] newControlPoints) { +#if !COMPILER_UDONSHARP && UNITY_EDITOR + this.UpdateProxy(); +#endif + if (newControlPoints == null || newControlPoints.Length <= 0) { Debug.LogError("Invalid control points"); @@ -372,8 +390,8 @@ public override void OnInspectorGUI() tangentExtrusion = EditorGUILayout.Slider("Tangent length", tangentExtrusion, 0, 3); } - //bool updatePositions = GUILayout.Button("Update spline positions"); - + bool save = GUILayout.Button("Save Spline Changes"); + if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(catmullRomSpline, "Modify CatmullRomSpline values"); @@ -389,6 +407,8 @@ public override void OnInspectorGUI() catmullRomSpline.normalExtrusion = normalExtrusion; catmullRomSpline.tangentExtrusion = tangentExtrusion; + catmullRomSpline.save = save; + // else // { // catmullRomSpline.SetupCatmullRom(controlPoints, resolution, closedLoop);