Playmaker Forum
PlayMaker Help & Tips => PlayMaker Help => Topic started by: amaranth on August 27, 2012, 08:49:44 PM
-
I know how to call OnPress from PlayMaker and it works beautifully, but it gets called when the press begins and when the press ends. Does anyone know how to make an action happen only when the press begins?
-
Found a fix. :D If anyone else needs this, here's what you do:
In UIEventsToPlaymakerFSM.cs on line 23, add this:
public string onPressDownEvent = "OnPressDown";
public string onPressUpEvent = "OnPressUp";
In UIEventsToPlaymakerFSM.cs change void OnPress(bool pressed):
void OnPress(bool pressed)
{
if (!enabled || targetFSM == null) return;
Fsm.EventData.BoolData = pressed;
targetFSM.SendEvent(onPressEvent);
if (pressed)
targetFSM.SendEvent(onPressDownEvent);
else
targetFSM.SendEvent(onPressUpEvent);
}
Note: This assumes you have NGUI and you're using the PlayMaker NGUI implementation:
http://hutonggames.com/playmakerforum/index.php?topic=1356.0
-
Ah I was just looking for it!
it only compiles if I remove this line targetFSM.SendEvent(onPressEvent);
And by the way, how do I get that event? It's not in the event browser
-
Oooh, do you think this same method could be applied to the onHover system?
-
Hi,
ok, Ngui works with OnPress AND a boolean flag to know if the this is down or up.
This is nice addition however, and indeed is quicker I have added it to my existing code, so it will be available by default with the next update.
@mcdroid: you'll have to create that event manually. don't forget to set it as a global event as well just for clarity.
bye,
Jean
-
Hi,
can you update the NGUI Events To Playmaker sccript so it will catch these ?
At the moment it doesn't recognize when I use ON PRESS DOWN /UP
It's just a matter of visual feedback but it is confusing at first.
Yaniv
-
Hi,
Good point, Added a task for this:
https://trello.com/c/c5lhe9hh/30-ngui
Please up vote :)
Bye,
Jean