Author Topic: PoolManager + UIPanel = Pooled Widgets!  (Read 2965 times)

Rafe

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 78
    • View Profile
PoolManager + UIPanel = Pooled Widgets!
« on: July 25, 2012, 02:06:08 AM »
I just implemented our enemy life-bars and found out two great things...

1) I added a PoolManager SpawnPool component to the same GameObject as a UIPanel and it just works! Awesome! PoolManager, by default, parents everything under the SpawnPool's Transform, which is also what the UIPanel wants. I just dropped my life-bar prefab, set the pool to preload 10 bars and started the game. All the UISliders came in disabled (despawned) and when I spawn one it show up and everything works; still one draw call.

This is really really cool! It means I can add pools anywhere in my UI...flashes, etc, and it is still all one draw call with nothing ever being destroyed, which is huge on Mobile devices.

P.S. I'll add this to the PoolManager example patterns portion of our website and post it to the Unity Forums.

2) Thank you for the how-to, it worked perfectly. I ended up centering the UISlider using startPos.x -= this.bar.fullSize.x * 0.5f;  where startPos i the target position before casting in to the camera viewport space. Someone in the thread mentioned it, but I didn't see it in the posted sample code.