Author Topic: un-hidden button stuck in hover mode issue.  (Read 4677 times)

Foj

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 9
    • View Profile
un-hidden button stuck in hover mode issue.
« on: January 23, 2013, 02:44:20 PM »
Hi,

I am using void OnClick () and NGUITools.SetActive(true/false) to show and hide menu elements.

A button un-hides a game-object holding a series of image-buttons (a popup list of options basically). When one of these buttons is pressed the game-object hides its self again.

After the first use of this popup, the last pressed image-button will show up in its Hover state and not the Normal state.

Other buttons on the pop-up display as expected and the ‘stuck-button’ only deselects Hover after it has been hovered over.

Anyone know how to resolve this? Thankyou.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: un-hidden button stuck in hover mode issue.
« Reply #1 on: January 23, 2013, 05:22:44 PM »
Disabled objects are not capable of receiving events, so once you disable it, it will never be notified of the "unpress" event. You can send an OnPress(false) even yourself, however. Just make sure that UICamera.currentTouch.pressed is cleared properly.

Foj

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 9
    • View Profile
Re: un-hidden button stuck in hover mode issue.
« Reply #2 on: January 24, 2013, 05:16:04 AM »
Hi

Thank you for all this help, but can I ask you to really break this down further for me,

In the script that makes the popup un-hide under “void OnClick(){“ I have placed a line “UICamera.currentTouch.pressed = null;” ...this is not doing anything: do I need to add variable of some sort; am I just not finding the path to the UICamera?

Hope I am not being too lazy  ::)

I am a freelance artist and usually work with Flash plus a little ActionScript. I have just started a job with Unity and nGUI this week (thinking Unity had free ScaleForm). Once this job is done I aim to get my head around nGUI/Unity a little better.

Thank you again for your help.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: un-hidden button stuck in hover mode issue.
« Reply #3 on: January 24, 2013, 09:49:12 AM »
You're forgetting the notification:
  1. UICamera.currentTouch.pressed.SendMessage("OnPress", false);
  2. UICamera.currentTouch.pressed.SendMessage("OnHover", false);
  3. UICamera.currentTouch.pressed = null;
  4. UICamera.currentTouch.hover = null;
...and only after this should you disable the object.

Foj

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 9
    • View Profile
Re: un-hidden button stuck in hover mode issue.
« Reply #4 on: January 26, 2013, 04:10:28 PM »
Hello just to say thanks for your help.
I ended up with,

GetComponent<UIImageButton>().ResetButton();

and,

   public void ResetButton()
   {
      if (target != null)
      {
         target.spriteName = normalSprite;
      }
   }

Thank you a lot for your help again.