Author Topic: UIPanels (menus) rendering issues.  (Read 1615 times)

Erbacher

  • Newbie
  • *
  • Thank You
  • -Given: 3
  • -Receive: 0
  • Posts: 17
    • View Profile
UIPanels (menus) rendering issues.
« on: December 23, 2013, 04:51:05 PM »
Hi all, thanks for taking the time to look at my issue.

This is kind of a 2 part question. As I been having some issues with my UIPanles not rendering correctly in the 'Game' window within Unity after pressing play.

So every time a menu (UIPanel and NGUI widgets as children) is created within my project I add these to a stack so I can loop over and update the depths and position of these menus in run time.

Issue (1):
For some reason I am having to move my menus by 120 in the Z axis. (Just confirming: this is 120 pixels away from the camera).
If they are closer to the camera than the number above, they will not render within the 'Game' window within Unity.


Issue (2):
During run time, when I create a new menu I again loop over both menus and change the position so both menus can be seen/rendered within the 'Game' window.
My problem is that when I create a second menu the menus seem to transform to 43200 in the Z axis.

Here is the code which changes the menus position in the Z axis:
  1. // Get the current menus position
  2. Vector3 position = newMenu.gameObject.transform.position;
  3. // Create the menus new position by changing the Z axis, when this.__offset = 120
  4. Vector3 newPosition = new Vector3(position.x, position.y, this.__offset);
  5. // Apply the the menus new position
  6. newMenu.gameObject.transform.position = newPosition;
  7.  

Here is a screen shot of the Debug.Logs showing the newMenu.gameObject.transform.position after I have set it. So it seems that something is moving my UIPanels after I have set it where I want it to be.


I would really appreciate any feedback to do with either or both of these issues if anyone has run across them, or something similar, before and know of a mistake that I might me doing or a solution to fix these issues.

Thanks for your time, and Merry Christmas to all :)
Erbacher
« Last Edit: December 23, 2013, 04:58:10 PM by Erbacher »

Erbacher

  • Newbie
  • *
  • Thank You
  • -Given: 3
  • -Receive: 0
  • Posts: 17
    • View Profile
Re: UIPanels (menus) rendering issues.
« Reply #1 on: December 23, 2013, 05:40:17 PM »
So it looks like the reason for the first issue is due to the nearClippingPlane on my camera. By default it was set to 0.3.
Changing this to 0 now enables my menus to spawn at 0 on the Z axis and be rendered/seen within in the 'Game' view port.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIPanels (menus) rendering issues.
« Reply #2 on: December 24, 2013, 12:47:07 PM »
0.3 is the default near clipping plane on 3D cameras. Orthographic camera used for UI created by NGUI has a range of (-10, 10). You can see this by starting a new scene and hitting ALT+SHIFT+W to add an invisible widget. The UI hierarchy will be created for you with all the default settings.