Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: amaranth on August 27, 2012, 08:49:44 PM

Title: OnPress & NGUI
Post 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?
Title: Re: OnPress & NGUI
Post by: amaranth on August 27, 2012, 09:17:38 PM
Found a fix. :D If anyone else needs this, here's what you do:

In UIEventsToPlaymakerFSM.cs on line 23, add this:

Code: [Select]
public string onPressDownEvent = "OnPressDown";
public string onPressUpEvent = "OnPressUp";

In UIEventsToPlaymakerFSM.cs change void OnPress(bool pressed):

Code: [Select]
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
Title: Re: OnPress & NGUI
Post by: mcdroid on August 09, 2013, 07:50:03 PM
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
Title: Re: OnPress & NGUI
Post by: Red on August 10, 2013, 12:35:55 AM
Oooh, do you think this same method could be applied to the onHover system?
Title: Re: OnPress & NGUI
Post by: jeanfabre on August 12, 2013, 07:55:40 AM
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
Title: Re: OnPress & NGUI
Post by: Yanifska on November 16, 2013, 04:11:04 AM
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
Title: Re: OnPress & NGUI
Post by: jeanfabre on November 18, 2013, 02:09:12 AM
Hi,

 Good point, Added a task for this:

https://trello.com/c/c5lhe9hh/30-ngui

Please up vote :)

 Bye,

 Jean