Author Topic: OnHover and OnPress behaviour for touch screens  (Read 4680 times)

Vijay Poduval

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 2
    • View Profile
OnHover and OnPress behaviour for touch screens
« on: December 05, 2014, 08:33:47 PM »
Hi,

I currently have NGUI 3.7.6 and I encountered a couple of issues on my Lenovo Yoga touch screen.

When I press and hold a sprite on the touch screen:

1) OnHover event of the sprite is triggered. Are they supposed to be triggered for touch screens?
2) OnPress is NOT triggered even after press and hold.

OnPress only seems to be triggered on a double tap and hold (Tap once, and tap twice and hold). Is this an issue or is this the normal behaviour for OnPress and OnHover.

Looking forward to the replies !

- Vijay

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: OnHover and OnPress behaviour for touch screens
« Reply #1 on: December 07, 2014, 12:15:18 AM »
You need to choose which events you want -- mouse or touch -- on the UICamera. Choosing both will lead to issues, as Unity tends to send both events from one action in some cases.

Vijay Poduval

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 2
    • View Profile
Re: OnHover and OnPress behaviour for touch screens
« Reply #2 on: December 08, 2014, 01:19:05 PM »
Thanks for the reply ! In my case I am making a game which is to be deployed on a laptop with touchscreen and mouse capabilities. Is there any way to to choose both mouse and touch events?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: OnHover and OnPress behaviour for touch screens
« Reply #3 on: December 09, 2014, 01:45:14 PM »
Different touches can result in different events. Even Mac touchpad gives different events in Unity -- there is on release event without onpress. I suggest examining what events are coming from Unity and going from there. Everything that deals with touch and mouse events is inside UICamera.cs. Add some Debug.Log statements to see what Unity is sending. My guess -- you will get both touch and mouse events from the same action. Unity ends to do that.