playMaker

Author Topic: Canvas Button and GUI Button  (Read 365 times)

kentcheung2000

  • Playmaker Newbie
  • *
  • Posts: 9
    • View Profile
Canvas Button and GUI Button
« on: May 12, 2018, 11:21:08 PM »
Hi,

I am new to playmaker and unity.  I want to create a button for touch screen game.  Do I use GUI buttons or Canvas button?  Are they similar or have difference?

Thanks.

KC

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 3181
    • View Profile
    • jinxtergames
Re: Canvas Button and GUI Button
« Reply #1 on: May 13, 2018, 06:24:48 AM »
Hi,
Gui Buttons are outdated, you should use Canvas buttons.

to send an event with the button : press + in the On Click () section
Then under 'runtime Only' drop in the gameobject with the fsm.
(warning! if there are multiple fsms on an object you need to move the fsm with the event above all the other fsms in the inspector)
Then on 'No Function' select "PlayMakerFsm/SendEvent (string)"
Then in the field below, place the event name that you wish to trigger.

if you need multiple fsms to have a button connected on the same object,
Then its better to use some actions or playMaker Event Proxy Component


You can get ugui action on the Ecosystem (search for : ugui proxy full)

OR

You can wait for the Playmaker 1.9 version (which should be released any time now) which includes ui actions.

Broken Stylus

  • Playmaker Newbie
  • *
  • Posts: 39
    • View Profile
Re: Canvas Button and GUI Button
« Reply #2 on: June 09, 2018, 03:12:01 PM »
I use the Event Trigger component, it's very fast and does wonders, although like all components that use references, it will detect only one FSM per game object (I haven't been able to send an event to several FSMs at once on a single targeted game object).
This component allows for much more control than being limited to just onClick.

uGUI is a good system, the canvas scaling system is fantastic, but if you plan on animating stuff, it's more complicated...

verybinary

  • Junior Playmaker
  • **
  • Posts: 77
    • View Profile
    • The Museum of Digital
Re: Canvas Button and GUI Button
« Reply #3 on: June 20, 2018, 01:42:43 PM »
Are you using the send event thing in the inspector option for the button?
try this
create fsm on button
start with blank state with one event "click"
"click" routes to state 2. state two triggers events on all the objects you want to be affected
in the inspector, in the On Click area, send event "click"

Broken Stylus

  • Playmaker Newbie
  • *
  • Posts: 39
    • View Profile
Re: Canvas Button and GUI Button
« Reply #4 on: June 22, 2018, 07:34:26 AM »
I use the Event Trigger component, it's very fast and does wonders...
This component allows for much more control than being limited to just onClick.

https://docs.unity3d.com/Manual/script-EventTrigger.html

This component allows to to many things rather intuitively, like creating an event that will change a colour, a text or start a monobehaviour script.

However, beware!
As of Unity 2017, you cannot reorder the events in the list though; i.e. you can't move an event up or down the list.
This limitation is not important when doing things that don't require PlayMaker, but anything directly done through Unity's "native" functions will take precedence over PlayMaker.

So if you have a game object that you want to deactivate through an event such as GameObject.SetActive (false) and if you're also using another event such as PlayMakerFSM.SendEvent to send and event to that same game object (whatever the reason), the FSM won't have time to do anything.

FSMs seem to have something like a frame of lag when using proxies or the Event Trigger component.

Putting the event that "talks" to the FSM at the top of the Event Trigger's list of events circumvented that problem.
Because the event at the top of the list is going to be sent first.

Another solution is to add a second Event Trigger component that sends events to your FSM on the same game object.

Notice that the order of your components on the game object will matter too. So place the Trigger Event that sends events to a FSM above any other Trigger Event (you can drag and slide components, even if the Unity interface isn't giving you any visual clue that there's something going on).
« Last Edit: June 22, 2018, 12:09:38 PM by Broken Stylus »

Ajay Ahlawat

  • Guest
Re: Canvas Button and GUI Button
« Reply #5 on: July 03, 2018, 02:30:05 AM »
Hi, I’m Ajay Ahlawat  Retd. Colonel in Indian Army. I like to play Polo.