Author Topic: NGUI3.5.8 Anchor Problem  (Read 5675 times)

visperc

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 6
    • View Profile
NGUI3.5.8 Anchor Problem
« on: June 19, 2014, 11:53:26 PM »
When i use NGUI3.5.8 to create my ui , i found some problem .
1.when i want to anchor base on the screen , i don't know which object should i set.
2.sometimes i want scale a sprite with fixed aspect and anchor it to the screen , in this case , i think i just need 3 parameters, left to the anchor left , right to the anchor right , and because its fixed aspect ,so i just need a parameter to decide the y axis . but ngui need i set 4 parameter, so i don't know how to do this ..
 sorry for my poor English, i will appreciate for anyone gives any idea.

Nicki

  • Global Moderator
  • Hero Member
  • *****
  • Thank You
  • -Given: 33
  • -Receive: 141
  • Posts: 1,768
    • View Profile
Re: NGUI3.5.8 Anchor Problem
« Reply #1 on: June 20, 2014, 11:08:02 AM »
Set it to unified, and anchor left to left, right to right, top to top and bottom to bottom. If you set the container to be a UIPanel without any clipping, it will stretch with the screen size.

visperc

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 6
    • View Profile
Re: NGUI3.5.8 Anchor Problem
« Reply #2 on: June 25, 2014, 04:00:21 AM »
Set it to unified, and anchor left to left, right to right, top to top and bottom to bottom. If you set the container to be a UIPanel without any clipping, it will stretch with the screen size.

sorry for reply so late...
yes , i try and it works  but some thing strange happens. when i change to game view ,it show the right sprites size ,but when i change to scene view, anything i make a change will lead the sprite scales its size automatically, do you know why ?

visperc

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 6
    • View Profile
Re: NGUI3.5.8 Anchor Problem
« Reply #3 on: June 25, 2014, 04:21:15 AM »
i update to the latest NGUI , but seems no change. i think this is very strange that there is no unique object for screen . because i once read the ngui codes, i think the panel's boundary is base on all its child widget. so if there is
a large sprite under the panel .uhhh i mean the sprite is large and out of screen , i anchor a sprite to this panel actually means i anchor this big sprite . that's usually not expected.
     i don't know if i misunderstanding this .anyone knows this ? Is anyone use the anchor before ?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: NGUI3.5.8 Anchor Problem
« Reply #4 on: June 25, 2014, 07:39:53 AM »
Don't hide your game view behind your scene view. It's not possible to determine the game view's dimensions properly when it's hidden.

visperc

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 6
    • View Profile
Re: NGUI3.5.8 Anchor Problem
« Reply #5 on: June 25, 2014, 09:51:48 PM »
Don't hide your game view behind your scene view. It's not possible to determine the game view's dimensions properly when it's hidden.
   Awesome! now it works correctly. Thank you very much .
   Another question is that if i want to anchor an sprite which must scale with fixed aspect to the screen. i think i just need 3 parameters in the anchor setting ,left to the screen left,right to the screen right .because i use fixed aspect. so i just need a parameter to decide the y position .but the anchor setting panel always need 4 parameters. so i use a trick to do this , i set anchor type to Advanced . and set the left ,right , and bottom. but set the top to the sprite itself's top. it seems works .but i think this is not the perfect solution .so  any idea about it ? thanks

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: NGUI3.5.8 Anchor Problem
« Reply #6 on: June 26, 2014, 10:59:13 AM »
That's how you are supposed to do it, yes. Advanced anchoring lets you choose 4 independent points, or leave some not anchored.

visperc

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 6
    • View Profile
Re: NGUI3.5.8 Anchor Problem
« Reply #7 on: June 26, 2014, 08:24:12 PM »
That's how you are supposed to do it, yes. Advanced anchoring lets you choose 4 independent points, or leave some not anchored.
cool ,thanks a lot