PlayMaker News > General Discussion

Canvas Button and GUI Button

(1/2) > >>

kentcheung2000:
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:
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:
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:
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:

--- Quote from: Broken Stylus on June 09, 2018, 06:12:01 PM ---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.

--- End quote ---

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).

Navigation

[0] Message Index

[#] Next page

Go to full version