Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: VascBogdan on February 24, 2015, 11:53:21 AM

Title: UI Button[SOLVED]
Post 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 ?
Title: Re: Button
Post by: jeanfabre on February 24, 2015, 12:07:37 PM
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
Title: Re: Button
Post by: Lane on February 24, 2015, 12:14:22 PM
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:

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 =)
Title: Re: Button
Post by: VascBogdan on February 25, 2015, 09:40:29 AM
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() :).
Title: Re: UI Button[SOLVED]
Post by: ETGgames on August 06, 2015, 10:56:27 AM
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
Title: Re: UI Button[SOLVED]
Post by: Lane on August 06, 2015, 11:28:51 AM
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.
Title: Re: UI Button[SOLVED]
Post by: ETGgames on August 06, 2015, 03:49:40 PM
Thanks for the advice I will take it on board!  ;D
Title: Re: UI Button[SOLVED]
Post by: nikosurfing on June 15, 2016, 02:59:52 AM
OMG!! Thank you for this