Tasharen Entertainment Forum
Support => NGUI 3 Support => Topic started by: par on February 12, 2014, 06:39:01 PM
-
I'll try and make this as quick and easy of an explanation as possible :)
Edit: I am using Unity 4.3.2f1 and NGUI 3.4.9
I created a UISprite that I will be using as a game mechanic. Basically, I will be changing its scale on the fly via code. When I created the UISprite I needed to resize it from the default (Snap) dimensions as it is too big for my purposes. So I change its GameObject transform scale to 0.5, 0.5, 0.5.
Here you can see the UISprite placed exactly where I want it w/ regards to the UIRoot (UIRoot is of course the red outline). This is prior to clicking anything on the Anchor UI.
(http://oi59.tinypic.com/saxon4.jpg)
Now, this image is right after I choose "Unified" for the anchor choice.
(http://oi60.tinypic.com/1256zh5.jpg)
As you can see, it automatically modified the size and position of the sprite as soon as I chose "Unified" for the anchor type.
At this point I am in positioning hell because I need to mess w/ those 4 anchor values to get it back to its correct size and its correct position.
To make it worse, I will be adding more UISprites that completely depend on the very center of this UISprite.
Is there any easier way to do this?
Thank you!
PAR
-
Change the pivot to top-left. That should help a bit. The anchoring system is ideal for things that aren't scaled though, keep that in mind. I would also advise you to make an invisible widget (ALT+SHIFT+W), and anchor that instead. Make your scaled sprite a child of the anchored widget (and don't anchor the sprite).
-
Hey Mook, thanks for the reply.
Yes, I found out just a bit ago that if I leave the GameObject transform alone when placing the Sprite and use the Widget dimensions for scaling prior to runtime that now the anchoring options work very smoothly. I didn't see the mention of "keeping the GameObject scaling alone" anywhere in the documentation so that might be a point of confusion to some (certainly was my problem). Now, if I kept to that rule, things rock.
Thanks much!
PAR