playMaker

Author Topic: OnPress & NGUI  (Read 7003 times)

amaranth

  • Full Member
  • ***
  • Posts: 172
OnPress & NGUI
« 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?

amaranth

  • Full Member
  • ***
  • Posts: 172
Re: OnPress & NGUI
« Reply #1 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
« Last Edit: August 27, 2012, 09:20:30 PM by amaranth »

mcdroid

  • Playmaker Newbie
  • *
  • Posts: 1
Re: OnPress & NGUI
« Reply #2 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

Red

  • Hero Member
  • *****
  • Posts: 563
Re: OnPress & NGUI
« Reply #3 on: August 10, 2013, 12:35:55 AM »
Oooh, do you think this same method could be applied to the onHover system?

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: OnPress & NGUI
« Reply #4 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

Yanifska

  • Full Member
  • ***
  • Posts: 163
    • My Portfolio
Re: OnPress & NGUI
« Reply #5 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
« Last Edit: November 16, 2013, 01:03:57 PM by Yanifska »
Visit my portfolio: http://www.yanivcahoua.com/

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: OnPress & NGUI
« Reply #6 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