Author Topic: Example 3, OnHover problem when UICamera use Touch only  (Read 11196 times)

yuewah

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 180
    • View Profile
Example 3, OnHover problem when UICamera use Touch only
« on: May 28, 2012, 01:04:32 AM »
In Unity Editor,

If I only checked UICamera's "use Touch" = true, UIButton does not receive OnHover event when I move the mouse cursor over it.

However, when I click on it, the UIButtonColor and UIButton Play Animation will receive OnHover event.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Example 3, OnHover problem when UICamera use Touch only
« Reply #1 on: May 28, 2012, 01:18:44 AM »
Hmm... there should be no hover events with the touch-only mode. I'll look into this, thanks.

loopyllama

  • Guest
Re: Example 3, OnHover problem when UICamera use Touch only
« Reply #2 on: May 28, 2012, 03:04:46 AM »
that is because it is missing the mouse check before sending onhover. you have already posted this before...here is the old post
http://www.tasharen.com/forum/index.php?topic=441.msg2097#msg2097

once again, try this:
UICamera.cs line 896, change:
  1. if (currentTouch.pressed == mHover)

to
  1. if (currentTouch.pressed == mHover && useMouse)

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Example 3, OnHover problem when UICamera use Touch only
« Reply #3 on: May 28, 2012, 03:30:53 AM »
This change went live a while ago.

yuewah

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 180
    • View Profile
Re: Example 3, OnHover problem when UICamera use Touch only
« Reply #4 on: May 28, 2012, 04:27:56 AM »
I am using 2.0.7c, and see the line of code. But it didn't fix it .

yuewah

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 180
    • View Profile
Re: Example 3, OnHover problem when UICamera use Touch only
« Reply #5 on: May 28, 2012, 04:44:05 AM »
UICamera.cs line 712
  1. if ( !isPressed && mHover != null && mHover != mMouse[0].current)
to
  1. if ( useMouse && !isPressed && mHover != null && mHover != mMouse[0].current)

UICamera.cs line 738
  1. if (!isPressed && mHover != mMouse[0].current)
to
  1. if (useMouse && !isPressed && mHover != mMouse[0].current)


« Last Edit: May 28, 2012, 05:33:18 AM by yuewah »

loopyllama

  • Guest
Re: Example 3, OnHover problem when UICamera use Touch only
« Reply #6 on: May 28, 2012, 10:01:45 AM »
I started a reply about how that isn't quite correct, then I dug a little deeper and you are right.
NGUI uses ProcessMouse() to handle "touches" while in the editor, but it still sends out OnHover in ProcessMouse() unless you change the lines you mention.

This means if you have only useTouch checked, in the editor you will get OnHover messages that you will never get on a mobile device.
Nice catch.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Example 3, OnHover problem when UICamera use Touch only
« Reply #7 on: May 28, 2012, 12:50:19 PM »
Ok, I've made the change on my end as well. Thanks!

seandanger

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 2
  • Posts: 32
    • View Profile
    • Bit By Bit Studios
Re: Example 3, OnHover problem when UICamera use Touch only
« Reply #8 on: May 30, 2012, 04:47:35 PM »
In a related note, would you agree that a gameObject should receive the OnHover(false) event even when moving out of the collider with the mouse pressed down?  I'd like my buttons to behave that way, and in order to do so, I have to remove the !isPressed check.  Here's what my line looks like:

  1. if (useMouse && mHover != null && mHover != mMouse[0].current)

This functions as I would expect. 

If this change is incorrect and the hover behavior is as-designed, how should I register to be notified in script that the mouse button is down but the cursor is no longer above the collider?  I'm writing a tool that I intend to distribute with NGUI free and I want this behavior to work for people without forcing each user to hand edit NGUI's camera code.

Thanks!

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Example 3, OnHover problem when UICamera use Touch only
« Reply #9 on: May 31, 2012, 01:41:45 AM »
You can always keep an eye on UICamera.currentTouch and its hovered object to see what's under the touch. The code you've mentioned is highly likely to interfere with how the current event system functions, in particular with how button highlighting works. It's cleaner to handle via your drag script instead.

Belfort

  • Guest
Re: Example 3, OnHover problem when UICamera use Touch only
« Reply #10 on: August 28, 2012, 07:24:39 AM »
Hi,

I have the 2.0.7c free version of NGUI and there is still that problem (button has onHover behavior after click with useTouch only). Unfortunately I discovered my UICamera has only few lines of code (without functions mentioned above).

So how can I fix that?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Example 3, OnHover problem when UICamera use Touch only
« Reply #11 on: August 28, 2012, 07:45:27 AM »
You can't fix it in the free version. You need the full version for that, and it's already been fixed there.

Belfort

  • Guest
Re: Example 3, OnHover problem when UICamera use Touch only
« Reply #12 on: August 29, 2012, 06:15:31 AM »
 ???

Why is that? Are there any additional shortage?
I thought:

"What's the catch? Aside from the non-commercial usage restrictions, NGUI's "Free Edition" message will be shown when you launch your application, and NGUI's watermark will appear in the top-left corner. Example 3 is also missing (orc inventory), because it's a bonus example."

I wanted to implement as much GUI as I can without any money spending, and buy full version of NGUI just before software realase. Is that possible?

PhilipC

  • Guest
Re: Example 3, OnHover problem when UICamera use Touch only
« Reply #13 on: August 29, 2012, 08:30:51 AM »
For us to release NGUI Free we lock down a lot of the key code into the dll's. Doing this is a lot of work and sometimes issues arise which take even more time to solve. Because of this we don't release a new free version when we release the paid version. Currently the paid version is at 2.1.6 so the free version is roughly 10 version and 3 months behind.

Some other short comings from the free version are related to mobile devices. We have had reports that NGUI does receive input properly on mobile and possibly some other issues.