Author Topic: UI Key Navigation starts selected, but color is not on "hover"  (Read 3454 times)

maruka

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 3
    • View Profile
UI Key Navigation starts selected, but color is not on "hover"
« on: September 28, 2015, 07:56:46 AM »
Hello!

I'm having a problem: I have 4 buttons, the first one is marked as "starts selected" and doesn't appear as selected when the object is activated. If I press down or up it changes as intented, so the buton is, in fact, selected, but the "hover" color doesn't appear.

It looks a lot like the problem solved here (the second one, messages by sh0v0r) : http://www.tasharen.com/forum/index.php?topic=3949.0
The answer he is given is this :

Try replacing your Start and OnEnable functions with this combo function instead:
  1.         void OnEnable ()
  2.         {
  3.                 if (startsSelected)
  4.                 {
  5.                         if (UICamera.selectedObject == null || !NGUITools.GetActive(UICamera.selectedObject))
  6.                         {
  7.                                 UICamera.selectedObject = gameObject;
  8.                         }
  9.                         else
  10.                         {
  11.                                 UICamera.Notify(gameObject, "OnHover", true);
  12.                         }
  13.                 }
  14.         }

My questions are : is this solution still the one to choose? Can you explain more precisely how i should do this? (I'm really not used to script in Unity, I do everything with Playmaker)

Thank you very much.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UI Key Navigation starts selected, but color is not on "hover"
« Reply #1 on: September 28, 2015, 01:11:29 PM »
That post is from 2013 and the handling of controller navigation was significantly different back then.

The button will only be selected if you are actually using controller input. Try disabling mouse and touch input on the UICamera before hitting Play.

maruka

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 3
    • View Profile
Re: UI Key Navigation starts selected, but color is not on "hover"
« Reply #2 on: September 28, 2015, 01:22:45 PM »
I tried this yesterday, disabling mouse and touch input in the first camera (and I just checked again, to be sure). It doesn't change anything : the first button is selected and work as intended (I can press it, or select the second button with "down"), but it doesn't have the "hover color" when the object is activated.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UI Key Navigation starts selected, but color is not on "hover"
« Reply #3 on: September 28, 2015, 01:25:40 PM »
Make sure you are on the latest version of NGUI (3.9.3) and check the controller example that comes with it.

maruka

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 3
    • View Profile
Re: UI Key Navigation starts selected, but color is not on "hover"
« Reply #4 on: September 28, 2015, 02:12:47 PM »
Thank you for your help.

I updated with the last version of NGUI. I check the example scene (I assumed you were talking about NGUI/Examples/Scenes/example 04 Controller Input), where I see it works alright.

But in my scene, the button is called by a "Dialogue Manager" object, related to the plugin Dialogue System for Unity (that I use with a NGUI UI, and it's working great overall). I noticed today that if my dialogue has only one answer possible, the first and only button is selected (with the right hover color). But if there are multiple answers, the first one is selected but without hover color. I looked at every possible tuning of the Dialogue system, but couldn't find anything, so my hope was to force the hover color on the first button when the object is activated, but I don't know... What do you think?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UI Key Navigation starts selected, but color is not on "hover"
« Reply #5 on: September 29, 2015, 04:23:30 PM »
That's what the UIKeyNavigation script should already be doing in its Start() function (or OnEnable if it has already been started). It changes the camera's hovered object, which sets the button to a highlighted state.

My guess is you have some script execution order issue going on. Try changing the script execution order on that dialog manager of yours.