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 helps immensely. Thank you.
Available for freelance work—feel free to reach out.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Disable a spline's gizmo when not selected or disabled. mikechr2000 1 141 02-03-2025, 09:34 AM
Last Post: _Aka_
Information Questions regarding spline colliders and collisions with rigidbodies Spyboticer 7 515 01-20-2025, 12:25 PM
Last Post: _Aka_
  Extrude mesh along spline. New and confused user GhostStalker 3 215 01-02-2025, 09:58 AM
Last Post: _Aka_
  Newly created spline is invisible quickytools 7 503 12-21-2024, 10:14 AM
Last Post: _Aka_

Forum Jump: