Author Topic: Best way to get panel world space bounds ?  (Read 3353 times)

oddurmagg

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 12
    • View Profile
Best way to get panel world space bounds ?
« on: November 05, 2013, 08:36:35 AM »
I'm looking at ways to "cull" UI panels based on whether they are visible by the camera or not. It seems like unity itself is not culling them out, at least the drawcalls incurred by uipanels which are not in the view frustum are still accounted for.

I would like to enable and disable the uipanels based on whether their world position bounds are visible by the camera, but to do that I need to get at the world bounds of the panel. What would be the best way to do that ?


ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Best way to get panel world space bounds ?
« Reply #1 on: November 05, 2013, 12:50:57 PM »
NGUIMath.Calculate series of functions is what you'd want to use to calculate bounds, however I strongly advise you to save this value after running it once, and just go by the panel's position. It will be an expensive operation otherwise.