Author Topic: Dynamically add/remove sprites with resizing  (Read 2370 times)

bagomints

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 13
    • View Profile
Dynamically add/remove sprites with resizing
« 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?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Dynamically add/remove sprites with resizing
« Reply #1 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.

bagomints

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 13
    • View Profile
Re: Dynamically add/remove sprites with resizing
« Reply #2 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?

bagomints

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 13
    • View Profile
Re: Dynamically add/remove sprites with resizing
« Reply #3 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?

bagomints

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 13
    • View Profile
Re: Dynamically add/remove sprites with resizing
« Reply #4 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.