Playmaker Forum
PlayMaker Help & Tips => PlayMaker Help => Topic started by: VascBogdan on February 24, 2015, 11:53:21 AM
-
Is there a way to send an event when an UI Button or Image is clicked/touched ? I used Mouse Pick Event on an image in the scene (a sprite) and it worked, but is there a way for an UI ?
-
Hi,
Yes, you can get the PlayMaker UI support here:
https://hutonggames.fogbugz.com/default.asp?W1192
you'll find videos and samples to go along and explain how it works. I am also working on a raw PointerInfo system which will allow you to implement dragging and access to down, up exit and enter pointer events.
Bye,
Jean
-
Alternatively you can also use the built in functionality. I've been messing with it lately and it works pretty well. OnClick is already included by default for Button components, you can see it there at the bottom of the Button Component where it says "On Click ()".
Here's how you can use that:
- Hit the + sign to add a new trigger for it
- Drag the GameObject with the FSM you want to send the event to
- Choose PlayMakerFSM.SendEvent from the dropdown
- Type the name of the event to send
If you want to use the built in event system for other events you must add a Event Trigger component (this is part of the new Unity UI Event System) and the prompt is similar, you only need to choose which trigger type to fire on... ie Hover, Pressed, Released, etc...
So there are actually several options available to you =)
-
Sorry I'm late.
I will try Lane's thing first, because in my past I worked with OnClick() a lot so I may know how to use it. If I can't make it work I will try Jean's ideea.
Thank's !
Edit: It worked with the OnClick() :).
-
OMG THANK YOU LANE U HERO!!!! How is this the only place on THE INTERNET that has this critical instruction? Ive been searching for days and gave up by creating an invisible cube as my button XD THANKS LANE!!! ;D ;D ;D ;D ;D
-
Horray! ;D
It is a little hard to find, probably because it's not a part of Playmaker, but rather a feature of Unity UI. So you have to study UI which has scripting stuff tied into the tutorials almost always and thats probably a deterrent for Playmaker users but there's actually a lot of information on the inspector tools alone.
Unity's UI and Event system has a pretty legit front end, though. It's worth digging around in.
-
Thanks for the advice I will take it on board! ;D
-
OMG!! Thank you for this