using UnityEditor.EditorTools; using UnityEngine; using UnityEngine.Splines; namespace Unity.Splines.Examples { public abstract class SplineDataToolBase : EditorTool { protected const float k_HandleSize = 0.15f; protected bool DrawDataPoints(ISpline spline, SplineData splineData) { var inUse = false; for(int dataFrameIndex = 0; dataFrameIndex < splineData.Count; dataFrameIndex++) { var dataPoint = splineData[dataFrameIndex]; var normalizedT = SplineUtility.GetNormalizedInterpolation(spline, dataPoint.Index, splineData.PathIndexUnit); spline.Evaluate(normalizedT, out var position, out var tangent, out var up); if(DrawDataPoint(position, tangent, up, dataPoint.Value, out var result)) { dataPoint.Value = result; splineData[dataFrameIndex] = dataPoint; inUse = true; } } return inUse; } /// /// User defined method, for simplicity here, all the SplineData Tools have to override the same DrawDataPoint method for consistency between tools /// /// /// /// /// /// /// True if the dataPoint is manipulated, else false. protected abstract bool DrawDataPoint( Vector3 position, Vector3 tangent, Vector3 up, DataType inValue, out DataType outValue); } }