Author Topic: Gui directly in front of the main camera?  (Read 2994 times)

Somoraze

  • Guest
Gui directly in front of the main camera?
« on: April 29, 2013, 12:01:02 AM »
Hi,

When I create a sprite with an image, I need to put it manually in front of the main camera (which is not always at 0,0,0).

Is there a way that the sprite goes automatically in front of the main cam?

How would it work for higher resolutions such as ipads? I think I saw it was automatic, could you tell me how, if we have to select the position manually? Thanks, sorry I am not a pro at NGUI yet ;-)

Thanks for your help

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Gui directly in front of the main camera?
« Reply #1 on: April 29, 2013, 06:29:50 PM »
Main camera? UI stuff should be drawn using a separate camera. Either NGUI-sane way of adding a sprite (ALT+SHIFT+S, NGUI menu -> Add Sprite) actually creates a UI hierarchy for you if it's not already present.

andrejvojtas

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 19
    • View Profile
Re: Gui directly in front of the main camera?
« Reply #2 on: April 30, 2013, 01:16:26 PM »
I ran into the same thing. I am on Unity 3.5.7 and nGUI 2.5.1, Win 7.

I tried to follow the new NGUI Basic Tutorial at http://www.youtube.com/watch?v=rI1vjXgKVTU

After adding a UITexture via the NGUI menu > Add Texture, and actually adding a texture from the resource to the component the texture is nowhere to be seen in the Game View. Also 'Make Pixel Perfect' doesn't work correctly.

This is all because the camera culling layers, and the created NGUI objects are not added to any layer as well (respectively the are added to an Unamed31 layer, and the camera under the UI Root is not set up to display that layer). The bottom line, to make it work as supposed to, you need to select the nGUI object (Texture/Sprite) and add them to a layer in the inspector. I clicked Add a Layer and named it NGUI. Then in the Main Camera in the Culling Mask dialogue disable the NGUI layer and in the camera that is under UI Root (2D) for culling mask select the NGUI layer only.

I don't know if that's how it supposed to work, but it seems to work ok now. It really got me confused for a while.

Somoraze

  • Guest
Re: Gui directly in front of the main camera?
« Reply #3 on: May 01, 2013, 12:44:12 AM »
Thanks for your answers, it works fine now! I just added the layer's name when I created the "UI", and disabled the "ui" layer in the main camera drop down list (in the inspector). And it works fine!

One thing though: about the automatic size of the UI, there are 3 options : Pixel Perfect, Fixed Size, Fixed Size for mobile.

Pixel Perfect : won't resize automatically?
Fixed Size : will do it
Fixed Size for mobile : What is the difference with "Fixed Size" ? And will it still resize the UI for tablets?

Thanks again

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Gui directly in front of the main camera?
« Reply #4 on: May 01, 2013, 03:29:15 AM »
Fixed size on mobiles acts as if it was pixel perfect on PC/mac/linux/web, and fixed size on ios/android.