Author Topic: Anchor relative to an object?  (Read 3575 times)

jz87

  • Guest
Anchor relative to an object?
« on: July 28, 2012, 12:29:18 AM »
I'm trying to build a dialog box. I want to anchor a button to the top left of the dialog box. UIAnchor only allows me to anchor relative to the screen. Is there anyway to specify an object/bounding box to anchor to?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Anchor relative to an object?
« Reply #1 on: July 28, 2012, 11:39:33 AM »
Phil is currently working on creating a built-in version of the community-created UIStick script that does what you want. In the meantime you will have to code that logic yourself -- but it's fairly trivial. Given the dimensions of the sprite (say, width), you can change the position accordingly. It's a 1 line of code inside an Update function.

electrodruid

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 48
    • View Profile
Re: Anchor relative to an object?
« Reply #2 on: January 16, 2013, 09:43:56 AM »
I know this is an old thread, but did anything ever come of this? It would still be useful to have something like UIStick. I'm trying to do the same thing as jz87 wanted to do - build a dialog box from a UISlicedSprite (scaled by a UIStretch to take up a specific proportion of the screen regardless of resolution and aspect ration), and then arrange the text, buttons and other elements relative to that UISlicedSprite.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Anchor relative to an object?
« Reply #3 on: January 16, 2013, 10:48:33 AM »
Yes, UIAnchor can be used to anchor to widgets now.

electrodruid

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 48
    • View Profile
Re: Anchor relative to an object?
« Reply #4 on: January 16, 2013, 11:44:09 AM »
Doh! I completely missed that you could do that! It works a treat, thank you  :D