05-15-2023, 12:04 PM
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.
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.