Author Topic: How to Anchor to Screen edge with a 3d UI  (Read 5350 times)

gdg

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 3
    • View Profile
How to Anchor to Screen edge with a 3d UI
« on: October 20, 2014, 12:27:41 AM »
Hi guys
I need some help positioning a sprite so that it is anchored to the left of the screen in a 3d ui. I can do this correctly with a 2d ui but 3d does not give correct results and the sprite does not remain at the edge when the window resizes. Any suggestions?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: How to Anchor to Screen edge with a 3d UI
« Reply #1 on: October 20, 2014, 11:26:51 PM »
So what's the issue exactly? I just did a quick test:

1. New scene.
2. New 3D UI.
3. ALT+SHIFT+S, moved it to the left edge of the screen.
4. Enabled anchoring on the sprite, made it anchored to the left side.
5. Adjusted Z position of the camera -- the sprite remained where I anchored it.

gdg

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 3
    • View Profile
Re: How to Anchor to Screen edge with a 3d UI
« Reply #2 on: October 21, 2014, 04:51:11 AM »
I have attached some screenshots. The sprite stays anchored correctly in the aspect ratio I am working in but does moves when the aspect ratio is changed. I have included my settings too. I intend to animate the anchor in code as well.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: How to Anchor to Screen edge with a 3d UI
« Reply #3 on: October 22, 2014, 05:06:09 AM »
Hit the Play button. It will update. Change aspect ratios during play time -- it will also update.

P.S. What version of NGUI are you using? You seem to be missing some fields like when to update the anchors... you must have some very old version. You need to update.

gdg

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 3
    • View Profile
Re: How to Anchor to Screen edge with a 3d UI
« Reply #4 on: October 23, 2014, 12:58:57 AM »
The problem appears even in play mode with free aspect and the sprite moves unpredictably. I have not upgraded ngui because that will need me to upgrade unity as well and I dint want to do that in the middle of a project but if you think that this problem is resolved in newer version then I will update it