Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: jz87 on July 28, 2012, 12:29:18 AM

Title: Anchor relative to an object?
Post by: jz87 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?
Title: Re: Anchor relative to an object?
Post by: ArenMook 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.
Title: Re: Anchor relative to an object?
Post by: electrodruid 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.
Title: Re: Anchor relative to an object?
Post by: ArenMook on January 16, 2013, 10:48:33 AM
Yes, UIAnchor can be used to anchor to widgets now.
Title: Re: Anchor relative to an object?
Post by: electrodruid on January 16, 2013, 11:44:09 AM
Doh! I completely missed that you could do that! It works a treat, thank you  :D