Author Topic: Culling Mask on (UI)Camera being changed unknowningly  (Read 2181 times)

WakeZero

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 3
    • View Profile
Culling Mask on (UI)Camera being changed unknowningly
« on: December 16, 2014, 01:10:22 AM »
Hey, I just wanted to point out an obscure bug I finally tracked down. Occasionally on my mobile device, the foreground NGUI widgets would fail to show up when loading a level etc. and I couldn't find the root cause. It finally reproduced itself in the editor, where I found out the camera responsible for those widgets had somehow had it's culling mask reset. I have no idea how it's happening, because I load those cameras in as prefabs at launch and don't touch them. My setup is as follows.

I have my main camera rendering my game objects, and two UICameras handling my UI (one for the background, and one for the foreground) which basically sandwich the main camera. Each of the UI cameras is on it's own layer, and their culling mask is set to that layer. They are both children of UI root, and whenever I add a panel/widget to those layers, I parent them to their respective camera. The root is marked DontDestroyOnLoad so it persists through scene changes. Whenever I add widgets/panels I use NGUITools.AddChild, and whenever I dispose of them I call NGUITools.Destroy.

Anyway, as far as I can tell I'm not making any calls that would affect the culling mask being changed. Any ideas on what the issue could be, or how I might go about fixing it? So far I think I'm just going to have to make sure they are set properly each update.

Thanks!


ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Culling Mask on (UI)Camera being changed unknowningly
« Reply #1 on: December 17, 2014, 02:57:54 PM »
Make sure that both UI cameras see only the layer they are supposed to, and that the main camera doesn't see either of the two UI layers.

WakeZero

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 3
    • View Profile
Re: Culling Mask on (UI)Camera being changed unknowningly
« Reply #2 on: December 17, 2014, 10:46:52 PM »
Yea, that's how they are setup (so they all can use 0,0,0 world space). Still not sure what's causing it, but now that I check in the update call if the culling mask changes, I just set it back to the original value with no issue.