Author Topic: UIButtonKeys - Not Responding after Closing/Reopening Menu  (Read 3275 times)

mmuller

  • Guest
UIButtonKeys - Not Responding after Closing/Reopening Menu
« on: February 19, 2013, 06:12:44 AM »
Hi,

I have this script to switch between menu panels:

  1. void Update ()
  2. {
  3.         if (Input.GetButton ("Fire2") && allowCancel) {
  4.                 Debug.Log ("Cancel");
  5.                 NGUITools.SetActiveSelf (_Menu, true);
  6.                 startSelected.startsSelected = true;
  7.                 UICamera.selectedObject = startSelected.gameObject;
  8.                 NGUITools.SetActiveSelf (_thisMenu, false);
  9.         }
  10.         if (Input.GetButton ("Fire1") && UICamera.selectedObject == this.gameObject && !allowCancel) {
  11.                 Debug.Log ("Select");
  12.                 NGUITools.SetActiveSelf (_Menu, true);
  13.                 startSelected.startsSelected = true;
  14.                 UICamera.selectedObject = startSelected.gameObject;
  15.                 NGUITools.SetActiveSelf (_thisMenu, false);
  16.         }
  17. }

Running on my menu Panels, when I enter a panel when first running the game the menu works perfectly and UIButtonKeys move around the items, when I exit the menu and re-enter though the UIButtonKeys are unresponsive, I get no errors logged and the Cancel Button to exit the menu works as expected.

Any ideas?

Regards,

Mark

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIButtonKeys - Not Responding after Closing/Reopening Menu
« Reply #1 on: February 19, 2013, 09:17:33 AM »
Generally caused by UICamera.selectedObject being either null, or not what you expect it to be.

mmuller

  • Guest
Re: UIButtonKeys - Not Responding after Closing/Reopening Menu
« Reply #2 on: February 19, 2013, 09:51:31 AM »
Arenmook,

I have taken out the selectObject code and settled on using the checkbox in the UIButtonKeys script. Still has the same effect. Opening/Closing the menu outside of NGUI's OnClick/OnKey/OnPress appears to break UIButtonKey navigation...

Regards,

Mark