Hi, so I want to add a spline (which I will call Spline2) to another spline ( which I will call Spline1) between 2 existing control points, which I have achieved by doing the following :
1. Storing the data for each control point in Spline1 ( including the connection if it has one )
2. Calculating the position on spline1 where spline2 should start.
3. Delete the control points of spline1 .... Spline.clear() and Spline.Refresh()
4. Adding the control points back to spline1 using the stored data for each Control point and adding the addition Control point at the appropriate place, with a connection.
The above works fine when adding spline 2 to spline 1.
Here's where it doesnt go as intended :
If I want to add another spline ( call it spline3 ) to spline1 and therefore another connection ( it might be in a different place to spline 2 so cant just add spline3 to the connection )
When I'm adding the control points back to the spline as in step 4 above.
I try to add spline2/CP0000 to Spline 1 BUT because that Control point already has a connection ( from when I added spline2 to spline 1) it won't add to the connection.
I've tried deleteing the connection & refreshing the spline but it makes no difference.
Is there somthing else that needs to be "refreshed" or called for this to work.
1. Storing the data for each control point in Spline1 ( including the connection if it has one )
2. Calculating the position on spline1 where spline2 should start.
3. Delete the control points of spline1 .... Spline.clear() and Spline.Refresh()
4. Adding the control points back to spline1 using the stored data for each Control point and adding the addition Control point at the appropriate place, with a connection.
The above works fine when adding spline 2 to spline 1.
Here's where it doesnt go as intended :
If I want to add another spline ( call it spline3 ) to spline1 and therefore another connection ( it might be in a different place to spline 2 so cant just add spline3 to the connection )
When I'm adding the control points back to the spline as in step 4 above.
I try to add spline2/CP0000 to Spline 1 BUT because that Control point already has a connection ( from when I added spline2 to spline 1) it won't add to the connection.
I've tried deleteing the connection & refreshing the spline but it makes no difference.
Is there somthing else that needs to be "refreshed" or called for this to work.
Code:
static void AddControlPointDataTOSeg ( CurvySplineSegment seg, ControlPoint ControlPoints, int index )
{
seg.AutoHandles = false;
seg.transform.position = ControlPoints.Position;
seg.transform.eulerAngles = ControlPoints.Rotation;
seg.HandleIn = ControlPoints.HandleINLocal;
seg.HandleOut = ControlPoints.HandleOUTLocal;
if (ControlPoints.Connection != null) {
Debug.Log (" A connection should be added for CP " + index + " control points to add = "+ ControlPoints.Connection.Count);
CurvyConnection.Create (seg);
foreach (CurvySplineSegment SegInConnection in ControlPoints.Connection.ControlPointsList) {
Debug.Log (SegInConnection.name + " / " + SegInConnection.transform.parent.name + " should be added to " + index + " " + seg.transform.parent.name);
SegInConnection.Connection.Delete ();
GameObject obj = SegInConnection.transform.transform.parent.gameObject;
Debug.Log (obj.name);
CurvySpline spline = obj.GetComponent<CurvySpline> ();
spline.Refresh ();
seg.Connection.AddControlPoints (SegInConnection);
}
}
}