uGUI Button with Parameters (Now as OnClick Trigger BloxEvent)

(RaiuLyn) #1

Big news everyone! The script has been included into plyGame as an official thing now. It’s called OnClick Trigger BloxEvent and it’s located at ‘Component/plyGame/Misc/’. It’s a script that calls plyBlox custom events with defined parameters when OnClick() from a uGUI button occurs. What this means is that using plyBlox will be so much easier from now on. :wink:

Until Leslie makes it possible to send parameters through OnClick(), treat this as a temporary solution/workaround. Enjoy!

As of 1 June 2016, Leslie and I agreed to keep the plugin separate and thus removed from future plyGame updates. Nevertheless, v4 will be very likely the last major version I put out anyway. I would like to thank everyone who uses the plugin since it was first released.

v4 file: (4.1 KB)

Instruction: All you have to do is to click and drag the script provided into a uGUI Button(or anything with a Button component) then input the Blox, name of the Blox’s custom event and parameters to send. Click the button during gameplay and it will do its thing.

(Luka Andric) #2

Mmm i hope this will make me progress :smiley: ahh that gui makes me so much problems :smile:

(Leslie Young) #3

Seems like a good solution to this problem. I’ll add this for the next release.

(RaiuLyn) #4

Now that it’s included in plyGame/plyBlox as of now, this topic is no longer needed except for newbies looking for instruction on how to use it. I doubt it though.

For those who have not used it yet, you’ll be grateful for it like I did when I got it working after an hour of messing with the API. :smiley:

Seriously though, It’s an honor. Thanks Leslie.

I still haven’t forgotten the EasySave2 plugin. I’m working on it, just have to wait longer than initially planned at the moment. :sweat:

(Max Uguccioni) #5

I cannot find it … Where is it ?

(Marshall Heffernan) #6

Leslie wrote a tutorial Here.

In fact, you posted in that very thread.

All UGUI bottons come with an “On Click ()”.

Drop in a GameObject with a plyBlox component, choose plyBlox > Trigger Event, and type in the custom event name.

clicking the UGUI botton should do what’s in the event.

(RaiuLyn) #7

The difference between that tutorial itsmars referenced and this OnClick Trigger BloxEvent component is that you are able to send trigger blox events with parameters. Example

Once the OnClick Trigger BloxEvent component is on a uGUI button, it should trigger events according to whatever custom events defined by clicking the button. Think of it as the ‘Trigger Event’ Block but in component form and only works by button presses.

Note: You do not have to define the “On Click()” function as mentioned by itsmars. You can ignore it as the OnClick Trigger BloxEvent component handles it instead of “On Click”. All you have to do is define what Blox to send to, what the name of the custom event and what parameters you would like to send.

Edit: Oh darn. It seems like I left a little ‘something’ in the image I forgot to cut out. If you’re observant, you might be able to find it. :stuck_out_tongue:

(Marshall Heffernan) #8

Oh dang!

@raiulyn I saw you post this 17 days ago, but I didn’t really understand how it worked.

So all we gotta do is use temp var param1/param2/param3 as string or as int, etc. and we can get the same “shop” to handle all kinds of item names, prices, etc.


edit: I saw your first shop using multiple events 29 days ago, and then when I saw it again, 17 days ago (this time with the new integrated script) and I thought it was the same thing.

New post rocks, thanks for sharing.

(RaiuLyn) #9

I apologize for the unclear explanation. I’ll better myself on explaining next time.

In that sense, yes. So far, the parameters can be sent as strings, ints and floats. I’m looking into extending the parameters into accepting other types like Bool, Gameobject, Vector3, etc…

Reply to edit: Hooray for less unnecessary code typing!!!

(Max Uguccioni) #10

the most amazing things about @raiulyn script is that you don’t need to messup with Button(script) indeed OnClickTriggerBloxEvent works alone … nice job :slight_smile: :thumbsup:

(Ryan) #11

Raiulyn, this would be very useful.
Any progress on this?

(RaiuLyn) #12

Progressing well so far with Leslie’s help. I’ll post an update on it here when it’s ready.

I’m open for any ideas before I call it done. I got a couple of implementations to finish left.

(RaiuLyn) #13

I’m close to finishing v2. If you have ideas or requests, now’s the time to let me know.

I’ll be submitting v2 to Leslie tomorrow once I’m done double checking my scripts and all. Also as for @Ryan , parameters can now accept Bool, Vector3, Vector2, Gameobject and Component values as intended.

As always, I’m very excited to see this released and you guys playing with it once plyGame/plyBlox includes it in its next update. :smiley:

(Ryan) #14

Looks perfect!
My only request is that i’m always wanting more parameters. Maybe a drop down list to pick how many params to send.
Not sure if it can only be three, as its that way for all ply triggers?

Also maybe systemobjects.

(RaiuLyn) #15

Leslie did mention something about that to me, leaving room for me to look into potential ‘How many parameters you can send’ and ‘Being able to name temp vars instead of the usual param1,param2 and param3’.

For now, finishing v2 is priority before I look into that.

Systemobjects? I don’t really know much about how to handle systemobjects to be honest. If someone can explain it to me, I maybe can put it in afterwards.

(Ryan) #16

Yeah man you should focus on releasing what youve got done now, it will really be useful. Then if youre still interested on expanding this plugin get some help with those other features!
Leslie also should do something similiar with the trigger event block asking for how many params to send.

(RaiuLyn) #17

Good news everyone! (In Professor Farnsworth’s voice)

I’ve finished with v2 and submitted it to Leslie. Now wait anxiously till Leslie gives an ok and puts it in the next update.
In the meantime, here’s the change-log:

  • In addition to Strings, Integers and Floats. Now accepts Bools, Vector2s, Vector3s, Gameobjects and Components as Values for use in sending blox events with parameters
  • Fancy InspectorGUI - Made to accommodate different types of values in an organized way
  • No longer uses Button OnClick - Made it so you can stick it on any object and call it by script. Tick ‘Use Button Onclick’ to accept OnClicks from self Button or other Buttons if defined.
  • Supports multiple components in a single gameobject - Call specific trigger/component by SendMessage(“ClickMethod”, CustomName ). Note: Only works with SendMessage for some reason.

Enjoy! :smile:

(Leslie Young) #18

I’ll be adding the updated component for the next patch.
Here is the latest version of it until the next update, Simply extract to your project (in …/Assets/ folder) and choose yes when it asks to override existing file. (3.8 KB)

(Artie) #19

I just tried it out! Love the new update and such flexibility of it! (/) (°,°) (/) -zoidberg

(RaiuLyn) #20

Sneak peek at version 3. Self-explainatory.