playMaker

Author Topic: How to remove/add buttons in GUILayout? [SOLVED]  (Read 2051 times)

mitchelq

  • Guest
How to remove/add buttons in GUILayout? [SOLVED]
« on: May 09, 2014, 04:13:47 PM »
Hello,

I'm trying to make a list in which you can add items. For example I have a menu and in the menu is a button to add an item. This item is another button.

example:
Menu
<Add item button>
<item 1 button>
<item 2 button>
<item 3 button>



Now I want it to be that if you press the <add item button> it adds a button below. So in this case <item 4 button>, and if you then press it again it will add <item 5 button> and so on.

How can I achieve this with an infinite amount of buttons to add? (so by not making a state for each number of buttons)

Thanks a lot in advance!

Mitchel
« Last Edit: May 12, 2014, 11:59:21 AM by mitchelq »

mitchelq

  • Guest
Re: How to remove/add buttons in GUILayout?
« Reply #1 on: May 11, 2014, 12:28:07 PM »
I do also have Daikon Forge btw, maybe easier to achieve with this?

TrentSterling

  • Junior Playmaker
  • **
  • Posts: 89
  • Someday I'll make games!
    • My Blog
Re: How to remove/add buttons in GUILayout?
« Reply #2 on: May 11, 2014, 09:23:26 PM »
Daikon forge would make things a bit easier, as the heirarchy can contain your 'list', however, what I suggest is that you look at ArrayMaker.

It's a PlayMaker addon that Jean made, and it lets you handle and iterate over lists.

Obviously you can't keep adding more actions to your state machine as your list gets bigger. But you can LOOP your actions using a simple iterator, or by using ArrayMaker. I believe his inventory example has a GUILayout list of buttons.

Check it out!
https://hutonggames.fogbugz.com/?W715

mitchelq

  • Guest
Re: How to remove/add buttons in GUILayout?
« Reply #3 on: May 12, 2014, 11:58:45 AM »
Hi Trent,

Thanks! this seems to be what I'm looking for.

Best regards,

Mitchel