Author Topic: Anchor features and problems  (Read 1620 times)

Eyello

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 5
    • View Profile
Anchor features and problems
« on: October 27, 2013, 10:04:12 AM »
Hello

With our latest update of NGUI (3.0.2) I faced a problem with the Anchor. If I set the Container to an Object which is a children of another object it mostly causes false results which didn't occur before. The coordinates are very wrong and often out of the screen.
It only works fine if I attach an Object of the same hirachy level or the root object. The problem is, I don't want that to happen because this object may does not have the desired boundaries as illustrated in the third image.

I know this is may not clear enough so I illustrated the desired effect and may you can tell me how to achieve it and if I am doing something wrong.



The next thing I just put in here. It is good that you added an absolute or pixel offset because I did this by myself. Another thing that I've added was a padding, which looked like this, may you want to add this, too?

  1.     public float Padding = 0;
  2.  
  3. if (side != Side.Center)
  4.                 {
  5.             if (side == Side.Right || side == Side.TopRight || side == Side.BottomRight) v.x = mRect.xMax - Padding;
  6.                         else if (side == Side.Top || side == Side.Center || side == Side.Bottom) v.x = cx;
  7.             else v.x = mRect.xMin + Padding;
  8.  
  9.             if (side == Side.Top || side == Side.TopRight || side == Side.TopLeft) v.y = mRect.yMax - Padding;
  10.                         else if (side == Side.Left || side == Side.Center || side == Side.Right) v.y = cy;
  11.             else v.y = mRect.yMin + Padding;
  12.                 }

It offsets the object depending on the anchor point settings. Anyhow, the problem described above occurs wih an unedited Anchor-Script.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Anchor features and problems
« Reply #1 on: October 27, 2013, 10:51:54 PM »
First, please see this sticky post: http://www.tasharen.com/forum/index.php?topic=6328.0

The anchor / stretch functionality of NGUI will be redone at some point. I'm not happy with how it is now.