Author Topic: Using NGUI as a HUD, having issues with GUI placement  (Read 3288 times)

johnnyr

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 7
    • View Profile
Using NGUI as a HUD, having issues with GUI placement
« on: March 14, 2014, 10:20:39 AM »
Hey guys,

I'm having an issue in a scene with a regular main camera, and the NGUI camera created with the UIRoot.

When I try to place elements, they use the NGUI camera for placement, and it doesn't line up with my game camera. I can get the GUi elements where I want them by trian and error, but it is pretty frustrating so far not to be able to just place them based on the Main camera size/view.

If I click "snap" while in the game tab (viewing the main camera) the elements in the editor then look correct, but as soon as I try to move one element they all change position.

I know this is something simple and silly, but I just can't figure it out. How am I supposed to be doing this? Do I even need the NGUI camera? (I'm assuming I do)

Help!

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Using NGUI as a HUD, having issues with GUI placement
« Reply #1 on: March 14, 2014, 10:34:57 AM »
Doesn't line up with your game camera... hmm? Different cameras result in different things. Unless your UIRoot is set to be Pixel Perfect, and both main camera and UI camera use the same orthographic size (of 1).

johnnyr

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 7
    • View Profile
Re: Using NGUI as a HUD, having issues with GUI placement
« Reply #2 on: March 14, 2014, 11:08:23 AM »
I'm confused - My Main camera is what I use to play the game - so it can't be orthographic (it is in perspective mode) UIRoot is set to pixel perfect. So how am I supposed to place UI Elements so that in the editor I can actually see what they are going to look in-game?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Using NGUI as a HUD, having issues with GUI placement
« Reply #3 on: March 14, 2014, 11:22:13 AM »
If your game camera is not orthographic then what is it you're trying to do exactly? A perspective camera is very different from an orthographic one. What is there to align?

johnnyr

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 7
    • View Profile
Re: Using NGUI as a HUD, having issues with GUI placement
« Reply #4 on: March 14, 2014, 11:35:34 AM »
So, I have a game camera - meaning the camera the player sees. Its in perspective mode. I want a Hud to be on the screen. So far When I line up UI elements in the editor I can only see where that are going to be on the UICamera. Pressing play shows the UI elements, but obviously they are not in the correct place in respect the main game camera.

If I get the elements lined up correctly via trial and error, press play, and then go back to the editor, all of the elements are all squished together.

« Last Edit: March 14, 2014, 11:45:48 AM by johnnyr »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Using NGUI as a HUD, having issues with GUI placement
« Reply #5 on: March 14, 2014, 11:48:53 AM »
Example 1 - Anchors. Also watch the Layout System video. Choose Help from the NGUI menu to be taken to the list of all the videos.