Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: homeworld on December 13, 2018, 05:37:40 PM

Title: How to control tons of instantiated buttons [SOLVED]
Post by: homeworld on December 13, 2018, 05:37:40 PM
Hi! I'm making some sort of basic weird inventory, so i'm instantiating tons of buttons; the buttons have a bunch of info in them (in an arraylist), but i'd rather avoid putting an individual FSM on each, since i'm already using tons of FSMs throughout the project.

What's the best way to make the instantiated buttons communicate with a manager FSM in the scene? I've tried a playmaker event proxy, as well as an onclick event on the button, but they can't keep their connection in prefab form. It'd be ideal if i could point it to a playmaker global gameobject variable from the inspector, but i doubt that's possible!

(http://danbkp.myqnapcloud.com/Web/2018-12-14_00-36-33.png)

Couldn't seem to find any tips for this in the forum search, although it seems like it'd be a common problem. Sorry if this is very basic! Thank you for reading!
Title: Re: How to control tons of instantiated buttons
Post by: djaydino on December 14, 2018, 10:14:03 AM
Hi,
Maybe you can use this : UiButtonFromArrayIndex (see attachment below)

Here you can trigger the buttons from an array. you must be on PlayMaker 1.9+

when a button get triggered you can get the index from the button.

That index you can use on a 2nd and/or 3rd array to (for example) get a event name and then use send event by name.
or highlight a corresponding object (button index matching object index)
or whatever you are using the buttons for :)
Title: Re: How to control tons of instantiated buttons
Post by: homeworld on December 14, 2018, 11:41:56 AM
Hi Djaydino! Thank you again for the help!

(http://danbkp.myqnapcloud.com/Web/buttons.gif)

I've made it so my button gameobjects are added to an array of gameobjects, but i can't seem to get the action to actually listen to the button presses. Did i misunderstand how it works? I've attached a pic with my array, action, as well as one of those button gameobjects, in case i got something wrong there!

I'm on unity 2018.3 (non-beta), as well as latest non-beta playmaker. Thanks again!
Title: Re: How to control tons of instantiated buttons
Post by: djaydino on December 15, 2018, 10:09:53 AM
Hi,
I have just tested on 2018.2.18f1 and PM 1.9.0f4

It is working there.

Playmaker is not yet supporting (but coming soon) 2018.3 and there are many breaking changes on 2018.3
So that might be the issue.
Are you getting some errors while using the actions?

Do you need to use 2018.3 for certain features?

I do most projects 1 version back (2017) as these version are more stable and are still getting bug fixes when bugs are found.
Title: Re: How to control tons of instantiated buttons
Post by: djaydino on December 15, 2018, 10:32:01 AM
Hi.
It seems that 2018.3 is supported since yesterday :D

http://hutonggames.com/playmakerforum/index.php?topic=19839.0;topicseen


let me know if that worked
Title: Re: How to control tons of instantiated buttons
Post by: homeworld on December 16, 2018, 10:33:39 AM
I updated and it works! Perfect, this is exactly what i needed!

You're right that i shouldn't update, but i really wanted the nested prefabs in 2018.3. I'll probably stick to this version till the end of my project!

Thanks again!

edit: those buttons in action!
(http://danbkp.myqnapcloud.com/Web/index.gif)