Author Topic: Set Anchor to current position in script  (Read 1579 times)

abrk

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 3
    • View Profile
Set Anchor to current position in script
« on: September 13, 2016, 11:43:25 AM »
Hi
I know there are similar topics but i couldn't find my answer :(
In UIWidget anchors there's a "Set to current Position" option.
I have a lot of widgets in my scene and want to write a editor script to anchor all of them to "Set to current position" mode.
How should i do this by code?
Thanks in advance :)

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Set Anchor to current position in script
« Reply #1 on: September 13, 2016, 12:03:48 PM »
Search for "Set to Current", arrive on line 316 of UIRectEditor.cs. The math is right there. It gets the sides, sets the anchor's relative value based on it and removes the absolute part. You can do something similar in your script.