Author Topic: Fake an event  (Read 5030 times)

N3uRo

  • Guest
Fake an event
« 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!

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Fake an event
« Reply #1 on: June 20, 2013, 01:33:56 PM »
Why?

Nicki

  • Global Moderator
  • Hero Member
  • *****
  • Thank You
  • -Given: 33
  • -Receive: 141
  • Posts: 1,768
    • View Profile
Re: Fake an event
« Reply #2 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. :)

N3uRo

  • Guest
Re: Fake an event
« Reply #3 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.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Fake an event
« Reply #4 on: June 21, 2013, 05:40:56 AM »
UICamera.currentTouch.pressed = yourNewGameObject;
yourNewGameObject.SendMessage("OnPress", true);

N3uRo

  • Guest
Re: Fake an event
« Reply #5 on: June 21, 2013, 01:31:55 PM »
Thanks Aren!