Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
When is it required to check if the spline / generator as initialized?
As the title says, when is it required to check if the spline / generator as initialized?
I noticed in some threads and the documentation that its required to use a coroutine to check if the spline is finished initializing. What information is this for? Is it just for the very start?

Will this lead to occasional race condition errors otherwise? 

I'm making a level editor that uses splines and I instantiate splines for previewing and then placing walls. 

Should I wait for the spline to be instantiated before trying to add points/modify the spline at all?
When instantiating objects via Unity's API, the Start method is not directly called (information based on my memories of tests done years ago). So if you want to use that object the same frame, it might not be initialized yet.The consequence can be that the spline is not refreshed yet for example, and it will be automatically refreshed by next frame. No race condition or any other serious issue, just potential delay.

Through the years, and with the enhancements on the code of Curvy Splines (and maybe some changes on the initialization code handling inside Unity itself?), those issues do not seem to be as problematic as before. I am hesitating about removing that part of the documentation (about using the coroutine to check the initialization), but I never took the time to do that. I need to do a thourough assessment of the code + tests before doing so.

So short answer: just use the curvy objects as you please, and if you witness that a spline is refreshed with a frame delay, then in your code check if the spline is initialized, and call refresh if it is.
Please consider leaving a review for Curvy. This will help a lot keeping Curvy relevant in the eyes of the Asset Store algorithm.

Possibly Related Threads…
Thread Author Replies Views Last Post
  Can Curve Spline be used for an in game level editor. Lupos 30 53 06-03-2023, 10:58 AM
Last Post: _Aka_
  Switch Spline Problem erenjeagerot 4 5 05-30-2023, 10:49 AM
Last Post: _Aka_
  Way to get objects script from generator Lupos 10 21 05-26-2023, 09:51 AM
Last Post: _Aka_
  Programming a first-person player/camera to follow a Curvy Spline kenmarold 1 2 05-21-2023, 05:03 PM
Last Post: _Aka_

Forum Jump: