Author Topic: UIButtonOffset not working with controller or keyboard  (Read 7206 times)

diederik

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 2
  • Posts: 31
    • View Profile
UIButtonOffset not working with controller or keyboard
« on: August 29, 2016, 03:44:37 AM »
Hi all!

I have a weird issue:

My UIButtonOffset works fine with the mouse, but it does not seem to work with keyboard or controller input.
I did some Debug.Logging in the script.
Using keyboard or controller input, it seems that the OnHover is also called at the start of the press (after OnPress and OnSelect)
It is NOT called when pressing with the left mouse button.
This is probably causing a conflict in the tween target vector I'm guessing.

My solution was to comment out the OnHover behavior, which seems to fix it for me.
(Luckily I am not using this functionality!)

Any ideas?

Diederik / Xform

EDIT: I noticed that I WAS using the OnHover functionality somewhere else in my project :(.
« Last Edit: August 29, 2016, 12:46:12 PM by diederik »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIButtonOffset not working with controller or keyboard
« Reply #1 on: August 30, 2016, 09:29:02 PM »
UIButtonOffset is just an example. Check its code -- its very trivial. You can write a custom script that takes parts of UIButtonOffset if you like, or just use UIPlayTween to trigger a tween on the event you desire.

Alternatively, have a look at the UIButtonColor code. It handles controller and mouse input separately (just look at its OnPress function).

diederik

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 2
  • Posts: 31
    • View Profile
Re: UIButtonOffset not working with controller or keyboard
« Reply #2 on: August 31, 2016, 06:38:18 AM »
Hi Arenmook,

Thanks for your response.
As I mentioned, I had commented out the OnHover behavior which kindof 'fixed' it.
And indeed I could create custom scripts that would work on either OnHover or OnPress so that they would not interfere.
I sometimes edit (or copy parts of) NGUI scripts and I always end up regretting it when updating to a newer version ;).

The question I meant to pose is:
What could cause this difference between mouse and controller/keyboard behavior?

Maybe I could then fix it that it would actually work in all cases! :)


Diederik / Xform

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIButtonOffset not working with controller or keyboard
« Reply #3 on: September 03, 2016, 01:48:09 AM »
To be honest with you, UIButtonOffset is a very old component. The button component has been kept up to date as NGUI developed,  but the button offset component likely didn't. I don't think NGUI even uses it anywhere right now... I'm guessing one of the event changes that was handled in the UIButtonColor simply never got back ported to the button offset.

Modifying NGUI's files isn't advisable for keeping NGUI up to date, but creating custom components for your own project is a good way to go.

diederik

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 2
  • Posts: 31
    • View Profile
Re: UIButtonOffset not working with controller or keyboard
« Reply #4 on: September 05, 2016, 05:03:37 AM »
Hi ArenMook,

Thanks for your thoughts.
I will take a look at the UIButtonColor script, and maybe I can create a fix for UIButtonOffset.
If I can, I will post it here!

Custom components of course can also 'break' when NGUI itself is updated ;)

Diederik / Xform

P.S. Still a big fan of NGUI so keep up the good work!