Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: bagomints on June 21, 2013, 02:40:05 AM

Title: Dynamically add/remove sprites with resizing
Post by: bagomints on June 21, 2013, 02:40:05 AM
Hello,

I'm confused about how to do this. I would like to implement a GUI where I can add/remove character portraits in the bottom of the screen, with different positioning depending on how many portraits are available.

If I have 1, it's in the middle, 2 would be side-by-side but centered on middle, 3 would also be centered.

If someone could guide me in the right direction, that'd be appreciated. (I'm new)

EDIT: Would it be simpler to just prefab all 6 positions and AddChild to Panel when I need to change?
Title: Re: Dynamically add/remove sprites with resizing
Post by: ArenMook on June 21, 2013, 02:52:20 AM
Bottom anchor, underneath position children offset by the (number of children * width * 0.5). Add a grid to it for easy spacing, and there you go.
Title: Re: Dynamically add/remove sprites with resizing
Post by: bagomints on June 21, 2013, 03:07:28 AM
This isn't clear to me.

Am I making a grid that I'm resizing depending on the # of its children? I can't seem to find where the UIGrid is, how do I add one?
Title: Re: Dynamically add/remove sprites with resizing
Post by: bagomints on June 21, 2013, 03:30:43 AM
Oh nevermind! UIGrid is in the Scroll View (example 7).

When you said "underneath position children offset by the (number of children * width * 0.5)", I'm unclear what you mean. Could you explain a little bit more please?
Title: Re: Dynamically add/remove sprites with resizing
Post by: bagomints on June 21, 2013, 04:25:29 AM
Nevermind I understand now. :)

For those searching for centering children on a grid like I wanted, search the forums for uigrid/table center alignment.