- Home /
Object pooling and invisible UI objects
Hi!
We're having trouble with some UI objects becoming invisible after going way and back to a pool. We can't find a way to reproduce it really consistently, so I'll explain it as best I can, and maybe someone else had a similar problem?
You can have a look at our pool code linked below, it's nothing fancy but worked quite well for us with 3D elements, feel free to use it! The problem comes with UI elements. Sometimes, when an element is reused, it's invisible even though with the inspector everything looks fine. Here is a screenshot : https://dl.dropboxusercontent.com/u/24534393/PoolProblem.png Where the arrow points we should see some of those pink stars. They have been instantiated, then reset (disabled and parented to the pool), then re-used (enabled and parented to where it's needed). It happens fairly often, but not always, and we didn't find consistent reproduction steps.
We're using 5.3.3p1, a colleague tried with 5.3.4 and the problem is still there. Earlier versions and 5.4b10 have it too. Is there any known issues with enabling/disabling UI objects?
Pool Manager code : http://pastebin.com/T9Vv1qSN
Pool code : http://pastebin.com/ANJiJvyC
Hi @Teyofil
Did you ever sort this out? I'm having a similar issue with a pooling system I'm using as part of a 2D bullet package I got from the asset store. It seems like when a bullet is being reused from the pool (that is, it's already been used once, visibly), it is forever after rendered invisible. When I view the objects in Scene view set to wireframe I can see they have poly billboards and are moving as the bullets should, they are just not rendering in the game view.
Sadly not! In our case it wasn't too bad for perfs to Instantiate/Destroy for the cases where the problem happened, so we stayed with that.