Author Topic: NGUI camera hijacking my sprite!  (Read 4811 times)

Shifty Geezer

  • Full Member
  • ***
  • Thank You
  • -Given: 7
  • -Receive: 9
  • Posts: 226
    • View Profile
NGUI camera hijacking my sprite!
« on: March 16, 2014, 04:39:35 PM »
I have a quad, a normal-mapped balloon. It's drawn on screen using the (orthographic) game camera. If I add an NGUI UI (create UI, no content), the balloon is not drawn by the game camera and is drawn by NGUI's camera. Whether 2D or 3D, the quad is only drawn by the UI camera. This is with NGUI 3.0.9 and 3.5.3.

I am also unable to Ctrl-X cut the balloon object once NGUI UI is added. And removing NGUI, deleting the NGUI UI GameObject and the NGUI folder, the balloon remains drawn by the now-deleted NGUI camera.

How is that even possible??

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: NGUI camera hijacking my sprite!
« Reply #1 on: March 17, 2014, 01:29:40 AM »
What draws the balloon? NGUI won't have any effect on anything other than an NGUI widget. Check its layer as well. If you place your balloon on the same layer that NGUI uses, when NGUI creates its UI camera that camera will remove that layer from the main camera's culling mask.

Shifty Geezer

  • Full Member
  • ***
  • Thank You
  • -Given: 7
  • -Receive: 9
  • Posts: 226
    • View Profile
Re: NGUI camera hijacking my sprite!
« Reply #2 on: March 17, 2014, 04:16:05 AM »
I don't know what draws the balloon. My game structure:

  1. 3D Game
  2.    _Balloon
  3.    _MainCamera (orthographic)
  4.    Level objects
  5. NGUI UI
  6.    camera
  7.  
When I add the NGUI UI, the balloon is drawn by the NGUI camera despite being in the 3D Game tree. If I delete the NGUI Camera, the balloon is not drawn despite appearing in the 3D Game tree. I had it once where the balloon remained, but that hasn't happened on the most recent tests.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: NGUI camera hijacking my sprite!
« Reply #3 on: March 17, 2014, 11:44:36 AM »
Check the layer of the game object itself. It's the only thing that can possibly affect which camera it's drawn by. On the camera you can choose a culling mask which affects which layers the camera is able to "see".

Check Unity's documentation for the Camera class -- this is not an NGUI question.

Shifty Geezer

  • Full Member
  • ***
  • Thank You
  • -Given: 7
  • -Receive: 9
  • Posts: 226
    • View Profile
Re: NGUI camera hijacking my sprite!
« Reply #4 on: March 17, 2014, 05:51:52 PM »
That's it. I guess NGUI uses 'user layer 8' by default and where I was using that for a physics layer for my balloon, that also shifted it into NGUI's layer. Changing layer fixed it. Thanks.