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
  save spot generated gameobject to scene fortune53 1 100 03-18-2021, 06:25 PM
Last Post: _Aka_
  Asteroid scene missing from 7.1.4 puzzlekings 3 180 03-11-2021, 08:37 AM
Last Post: _Aka_
  Renaming gameObject in scene Locked when there are CurvyGenerator in scene UsernameHed 3 2,537 07-18-2019, 12:02 AM
Last Post: _Aka_
  UI button to start Curvy Spline in scene funkd 1 1,619 07-12-2019, 11:19 AM
Last Post: _Aka_

Forum Jump: