Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: OnlineCop on July 17, 2013, 01:06:29 PM

Title: Request: UIButton alignment options
Post by: OnlineCop on July 17, 2013, 01:06:29 PM
EDITED for clarity:

There are three UIWidget-derived objects in NGUI: UILabel, UISprite, and UITexture. The UIWidgetInspector class utilizes this fact and offers a pivot alignment control within the Unity Inspector, which is awesome for when I want to align these against one edge, then change my mind and align them against a different edge.

The UIButton and UIImageButton classes do NOT derive from UIWidget, however, and I wonder how difficult it would be to create the same kind of pivot alignment controls for those. I find myself resizing buttons (by resizing the UISprite and UILabels within them) in the editor, which requires adjustment to the parent GameObject and its BoxCollider each time.

In order to manually set a button's pivot to the bottom-right, I need to:

.. ...

Once the button's pivot is in the bottom-right corner, if I decide to increase the offset from the edge of the panel, there's no need to recalculate the UISprite's dimensions (plus the edge offset) each time: I can simply set the GameObject's position directly to the desired offset.

But if I want to change the pivot (like if I decide the button should go in a different corner, or even centered in the panel), I have to repeat steps 1-4 again with the new offsets.

Could I request a similar "one-button solution" like we have with the UIWidgetInspector's alignment tools, for UIButtons an UIImageButtons? That would be awesome!
Title: Re: Request: UIButton alignment options
Post by: ArenMook on July 18, 2013, 04:32:03 AM
I resolved this properly in the upcoming UI system, but there is no easy way to do it correctly in NGUI as it relies on transform.scale for widget size. I may back-port this feature to NGUI in the near future, but my only concern is backwards compatibility.