08-21-2020, 12:51 PM
(This post was last modified: 08-22-2020, 09:29 AM by GenericJoe.)
Hi, I create splines many times using a prefab which is a simple GameObject with a Curvy Spline component. I create it like this:
Immediately after this, I grab the spline component and set properties on it, including the actual spline points:
However, should I be checking spline.IsInitialized first before fiddling with the spline? In other words, do I need to be waiting for some form of initialisation in the CurvySpline componenrt before I set it's control points, even though it doesn't have any control points to start with?
In addition, should I be calling Refresh after adding the control points or before?
As a general rule of thumb when doing everything via the API, when should I be checking the IsInitialized property and calling Refresh?
Thank you
Code:
splineClone = GameObject.Instantiate(splinePrefab, new Vector3(), Quaternion.identity);
Immediately after this, I grab the spline component and set properties on it, including the actual spline points:
Code:
spline = splineClone.GetComponent<CurvySpline>();
spline.Orientation = CurvyOrientation.Static;
CurvySplineSegment[] cps = spline.Add(pathPoints.ToArray());
However, should I be checking spline.IsInitialized first before fiddling with the spline? In other words, do I need to be waiting for some form of initialisation in the CurvySpline componenrt before I set it's control points, even though it doesn't have any control points to start with?
In addition, should I be calling Refresh after adding the control points or before?
As a general rule of thumb when doing everything via the API, when should I be checking the IsInitialized property and calling Refresh?
Thank you