Skip to content

Commit 52059a8

Browse files
committed
Added previousPoint and nextPoint helper properties to BezierPoint
1 parent 4c6dd41 commit 52059a8

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed

.github/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ End points have the following properties to store their transformational data: `
7979

8080
Positions of control points can be tweaked using the following properties in BezierPoint: `precedingControlPointPosition`, `precedingControlPointLocalPosition`, `followingControlPointPosition` and `followingControlPointLocalPosition`. The local positions are relative to their corresponding end points.
8181

82-
End points also have read-only `spline` and `index` properties.
82+
End points also have read-only `spline`, `index`, `previousPoint` and `nextPoint` properties.
8383

8484
```csharp
8585
// Set first end point's (world) position to 2,3,5

Plugins/BezierSolution/BezierPoint.cs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,38 @@ public ExtraData extraData
309309
public BezierSpline spline { get; internal set; }
310310
public int index { get; internal set; }
311311

312+
public BezierPoint previousPoint
313+
{
314+
get
315+
{
316+
if( spline )
317+
{
318+
if( index > 0 )
319+
return spline.endPoints[index - 1];
320+
else if( spline.loop )
321+
return spline.endPoints[spline.endPoints.Count - 1];
322+
}
323+
324+
return null;
325+
}
326+
}
327+
328+
public BezierPoint nextPoint
329+
{
330+
get
331+
{
332+
if( spline )
333+
{
334+
if( index < spline.endPoints.Count - 1 )
335+
return spline.endPoints[index + 1];
336+
else if( spline.loop )
337+
return spline.endPoints[0];
338+
}
339+
340+
return null;
341+
}
342+
}
343+
312344
private void Awake()
313345
{
314346
transform.hasChanged = true;

0 commit comments

Comments
 (0)