Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: N3uRo on June 20, 2013, 11:08:20 AM

Title: Fake an event
Post by: N3uRo on June 20, 2013, 11:08:20 AM
Hi,

We are trying to make a virtual joystick that appears when you touch the screen anywhere.

Our problem is that when you press on the screen it has to trigger the OnPress of the joystick and then it has to act like it was UICamera that sent the event (trigger other events like OnDrag and OnPress false).

It's possible to do that?

Thanks!
Title: Re: Fake an event
Post by: ArenMook on June 20, 2013, 01:33:56 PM
Why?
Title: Re: Fake an event
Post by: Nicki on June 20, 2013, 03:37:11 PM
You can call the methods manually, but you can't fake everything, because some scripts access the UICamera to get more information.

Short answer: Sorta. :)
Title: Re: Fake an event
Post by: N3uRo on June 20, 2013, 04:46:35 PM
Why?

Because:

1. The user touches anywhere on the screen.
2. It has to appear a joystick and it has to be in the pressed state.
3. So you can start dragging it.

Thats why I would want to fake it.
Title: Re: Fake an event
Post by: ArenMook on June 21, 2013, 05:40:56 AM
UICamera.currentTouch.pressed = yourNewGameObject;
yourNewGameObject.SendMessage("OnPress", true);
Title: Re: Fake an event
Post by: N3uRo on June 21, 2013, 01:31:55 PM
Thanks Aren!