Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: SamVickery on March 26, 2014, 05:51:30 AM

Title: UIWidget anchor - setting via code
Post by: SamVickery on March 26, 2014, 05:51:30 AM
Hi this is my first post and I have searched everywhere on this forum but sorry if it has already been answered.

I know how to set anchors via code but it takes a few frames to move everything to their correct positions.
I have tried using:
  1. Widget.UpdateAnchors();
  2. Widget.ResetAnchors ();
But they don't seem to do anything.
Is there anyway to set an anchor and the widget to immediately snap to the correct position?

If anyone has any solution please let me know
Thanks
Sam
Title: Re: UIWidget anchor - setting via code
Post by: ArenMook on March 26, 2014, 07:35:07 PM
You have them backwards. First you need to ResetAnchors(), then UpdateAnchors(). Look inside UIRect.SetAnchor.
Title: Re: UIWidget anchor - setting via code
Post by: SamVickery on March 27, 2014, 05:02:26 AM
Thanks for the quick response.
I changed those lines of code around and still had the same issue.
I was doing some testing and it seems if you set all 4 anchors the issue disappears.
Title: Re: UIWidget anchor - setting via code
Post by: ArenMook on March 28, 2014, 12:16:42 AM
What's anchored to what?
Title: Re: UIWidget anchor - setting via code
Post by: SamVickery on March 28, 2014, 03:25:09 AM
It was a list of options that were all anchored to each other (say an absolute of 40 bellow the one above) I ended up using relative anchors to the parent container. This made sure that all the items were evenly spaced out in the container regardless of the size and allowed for other options to be taken out or added.
Thanks for your help anyway