Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
When is it required to check if the spline / generator as initialized?
#1
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?
Reply
#2
Hi
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.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
Exclamation Extending Curvy Generator for Advanced Lofting - Feasibility Check amutp 2 4 Yesterday, 07:25 AM
Last Post: amutp
  8.8.0 is live, and it improves Curvy Generator greatly _Aka_ 0 6 Yesterday, 03:23 AM
Last Post: _Aka_
Bug Changing spline connection in inspector causes splines to revert to defaults lacota 3 6 03-18-2024, 07:55 PM
Last Post: _Aka_
  GO can't fit end of the spline GameDeveloperek4123 3 13 03-04-2024, 11:06 AM
Last Post: _Aka_

Forum Jump: