playMaker

Author Topic: Dynamic UI Buttons [Solved]  (Read 1711 times)

Wolfe

  • Playmaker Newbie
  • *
  • Posts: 4
Dynamic UI Buttons [Solved]
« on: July 06, 2020, 09:12:44 AM »
Hello,

I'm new to all this to a degree so I'd appreciate even just input about my question. I'm probably getting ahead of myself but I'm creating a text based adventure-ish type of game and I'm trying to get the best use out of a set of UI buttons that I have. I've set up 8 UI buttons but I'd like for them to change their function based on some other predetermined information.

IE: Enter a room and the options of what you can do in that room show up as the clickable buttons. (I've not even created these 'rooms' or a way to navigate between them, but I'm just trying to get the features at hand to work first)

What I've come up with is a sort of ArrayList that gets updated based on the room entered and then an ArrayListGet that would activate the buttons with what's in that List and turn the buttons uninteractable that come up as a Failure Event. But I'm not even sure what to put in that Array, be it a gameobject or something more complex? I don't know if I'm even thinking in the right direction, but I don't believe the answer is anything too complex.

Maybe I'm not even explaining anything right, but I'd be happy to try and explain better if need be.
« Last Edit: July 07, 2020, 10:07:09 PM by Wolfe »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15620
  • Official Playmaker Support
Re: Dynamic UI Buttons
« Reply #1 on: July 07, 2020, 09:31:32 AM »
Hi,

 you have two main ways to go about this:

- you either create the buttons on the fly and assign them specific ids, or string based events ( you can send event using a string, the action is SendEventByName)

this way you have a manager that knows what to show fore a given context, you can then properly set  the button label, icon, etc etc.

- you have the buttons already present during editing, and they send each a predefined event, it's then up to a manager to catch these and depending on the context, forward the right event or do that right thing for this context.

you have then several variants in between, it depends how far you want to take dynamic buttons handling.

your array list of all buttons that you then activate/deactivate is ok, but could become cumbersome if you expect the number of buttons to grow as you develop further your project.

Bye,

 Jean

Wolfe

  • Playmaker Newbie
  • *
  • Posts: 4
Re: Dynamic UI Buttons
« Reply #2 on: July 07, 2020, 10:06:29 PM »
Jean,

Thank you for providing me with insight and possibilities to tackle my problem, I think that I can do what I want with the first suggestion you made.