Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How does Pooling works across scene loading?
Hi Jake.

I tried use CurvySpline's pooling in my game but it crashes my game.
I wasn't sure if the CurvySpline pooling works across LoadScene().
My spline is sitting under a GameObject that persist across levels (DontDestroyOnLoad).

So, to repeat that, I have added a new button in the "97_Pooling" scene just to reload the same scene again.

public void ReloadLevel()

[Image: u0njWDd.png]

And I'm getting the same error.
"The object of type 'CurvySplineSegment' has been destroyed but you are still trying to access it."

Any idea how to address that?

Note: I'm still using version 2.0.3.

BTW, Thanks for adding the pooling capability in version 2.0.3.
That doesn't need to be caused by pooling, what's the stacktrace of the above error?

In general pooling (btw, it was introduced with 2.0.0, just the example came with 2.0.3) works by keeping the CP-GameObjects under _CurvyGlobal_ (which is DontDestroyOnLoad() as well). So it should work with scene loading as well - though I didn't tested this explicitely.

Note: For 2.0.5 I worked around the bug introduced by Unity 5.3 that makes _CurvyGlobal_ invisible in the hierarchy.
I am also getting crashes to do with scene loading! It would appear that the curvy segments are being destroyed before they get moved into the singleton (perhaps due to Unity's never-ending update order problems). Then, when the pool attempts to remove excess segments (which in fact have already been destroyed), it gets exceptions

The simple solution, I expect, is to null-check the collection of pooled segments before manipulating it.
The stack trace is here:

MissingReferenceException: The object of type 'CurvySplineSegment' has been destroyed but you are still trying to access it.
Your script should either check if it is null or you should not destroy the object.
FluffyUnderware.Curvy.CurvySpline.InsertAfter (FluffyUnderware.Curvy.CurvySplineSegment controlPoint) (at Assets/Packages/Curvy/Base/CurvySpline.cs:1292)
FluffyUnderware.Curvy.CurvySpline.Add () (at Assets/Packages/Curvy/Base/CurvySpline.cs:1188)
FluffyUnderware.Curvy.CurvySpline.Add (UnityEngine.Vector3[] controlPoints) (at Assets/Packages/Curvy/Base/CurvySpline.cs:1202)
Curvy.Examples.PoolTestRunner.AddCP () (at Assets/Packages/Curvy Examples/Scripts/PoolTestRunner.cs:41)
Curvy.Examples.PoolTestRunner.checkForSpline () (at Assets/Packages/Curvy Examples/Scripts/PoolTestRunner.cs:34)
Curvy.Examples.PoolTestRunner.Start () (at Assets/Packages/Curvy Examples/Scripts/PoolTestRunner.cs:17)

I found the issue with my own pooling code.  It crashed right after LoadScene().  I fixed the problem by recalling all my pooled objects before LoadScene() is called.  May be i can do the same for CurvySpline... I will try it later.

Possibly Related Threads…
Thread Author Replies Views Last Post
  Does Curvy has gameobjects pooling system function? Chanon 7 13 09-07-2023, 12:43 PM
Last Post: _Aka_
  Animating a shape on along a spline will not playback in scene or game views sam_bond 3 9 05-03-2023, 11:41 AM
Last Post: _Aka_
  Select Point in Scene soccertrash 1 6 07-04-2022, 04:03 PM
Last Post: _Aka_
  Scene 51 questions lukasynthetic 3 12 06-22-2022, 04:12 AM
Last Post: _Aka_

Forum Jump: