Author Topic: UIWidget anchor - setting via code  (Read 3685 times)

SamVickery

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 3
    • View Profile
UIWidget anchor - setting via code
« 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

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIWidget anchor - setting via code
« Reply #1 on: March 26, 2014, 07:35:07 PM »
You have them backwards. First you need to ResetAnchors(), then UpdateAnchors(). Look inside UIRect.SetAnchor.

SamVickery

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 3
    • View Profile
Re: UIWidget anchor - setting via code
« Reply #2 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.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIWidget anchor - setting via code
« Reply #3 on: March 28, 2014, 12:16:42 AM »
What's anchored to what?

SamVickery

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 3
    • View Profile
Re: UIWidget anchor - setting via code
« Reply #4 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