Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How does Pooling works across scene loading?
#1
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.

Code:
public void ReloadLevel()
{
SceneManager.LoadScene(SceneManager.GetActiveScene().name);
}

[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.
Reply
#2
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.
Reply
#3
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.
Reply
#4
@Jake
The stack trace is here:

Code:
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)


@bvance
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.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Compilation issues for iOS with a scene containing generators puzzlekings 2 717 05-13-2021, 06:53 PM
Last Post: _Aka_
  Activate Curvy Generator After Scene Load jdkirk1 7 1,585 05-07-2021, 02:14 PM
Last Post: _Aka_
  save spot generated gameobject to scene fortune53 1 505 03-18-2021, 06:25 PM
Last Post: _Aka_
  Asteroid scene missing from 7.1.4 puzzlekings 3 806 03-11-2021, 08:37 AM
Last Post: _Aka_

Forum Jump: