Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: mmuller on February 19, 2013, 06:12:44 AM

Title: UIButtonKeys - Not Responding after Closing/Reopening Menu
Post by: mmuller 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
Title: Re: UIButtonKeys - Not Responding after Closing/Reopening Menu
Post by: ArenMook on February 19, 2013, 09:17:33 AM
Generally caused by UICamera.selectedObject being either null, or not what you expect it to be.
Title: Re: UIButtonKeys - Not Responding after Closing/Reopening Menu
Post by: mmuller 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