Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Best practice when Instantiating game object with spline
#1
Hi, I create splines many times using a prefab which is a simple GameObject with a Curvy Spline component. I create it like this:

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
Reply


Messages In This Thread
Best practice when Instantiating game object with spline - by GenericJoe - 08-21-2020, 12:51 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Method of scattering objects along spline joebain 1 3 11-26-2024, 03:20 PM
Last Post: _Aka_
  Curvy Line Renderer for UI Spline? gekido 5 13 10-29-2024, 10:19 AM
Last Post: _Aka_
  Bug: Save Generator Outputs still saves outputs if object is disabled curvymesher 1 3 08-30-2024, 09:19 AM
Last Post: _Aka_
  Player move with object mcarman 4 8 07-29-2024, 06:49 PM
Last Post: mcarman

Forum Jump: