Author Topic: [SOLVED] UIButtonKeys - How to program in the B button?  (Read 4194 times)

Disastercake

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 87
  • www.disastercake.com
    • View Profile
    • Disastercake
[SOLVED] UIButtonKeys - How to program in the B button?
« on: January 13, 2014, 02:26:44 AM »
Right now when using UIButtonKeys if I press the B button on my Xbox 360 controller, the current selection is deselected, butten there is no way for me to get it back.  It is just deselected forever apparently.

I would like to customize how NGUI handles the B button by telling it which menu to go back to, or to not do anything at all and maintain the current selection.  How would I do this?  At the moment I can't find the code where the B button triggers this.

Edit: I ended up going into the UICamera class and commenting out lines 922 and 928 so they looked like the following:

  1. // Clear the selection on the cancel key, but only if mouse input is allowed
  2.                 if (useMouse && mCurrentSelection != null)
  3.                 {
  4.                         if (cancelKey0 != KeyCode.None && Input.GetKeyDown(cancelKey0))
  5.                         {
  6.                                 currentScheme = ControlScheme.Controller;
  7.                                 currentKey = cancelKey0;
  8.                                 //selectedObject = null; // Mike: Commented out so it doesn't screw up targeting
  9.                         }
  10.                         else if (cancelKey1 != KeyCode.None && Input.GetKeyDown(cancelKey1))
  11.                         {
  12.                                 currentScheme = ControlScheme.Controller;
  13.                                 currentKey = cancelKey1;
  14.                                 //selectedObject = null; // Mike: Commented out so it doesn't screw up targeting
  15.                         }
  16.                 }

This seems to be the only way to handle it that I saw.  Perhaps the whole section could be commented out, but I didn't want to spend much time testing out what happens when commenting out large code chunks.  If anyone knows a better way to handle this please let me know~
« Last Edit: January 13, 2014, 02:38:34 AM by Disastercake »
Creator of Soul Saga.
http://www.disastercake.com

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: [SOLVED] UIButtonKeys - How to program in the B button?
« Reply #1 on: January 13, 2014, 05:55:42 PM »
That's what the cancel keys do. They clear the selection. It's like hitting Escape. You can always change the cancel keys to "None" on your UICamera.

Note that this only happens if the mouse input is allowed -- that is, you have both controller and mouse input active.

Disastercake

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 87
  • www.disastercake.com
    • View Profile
    • Disastercake
Re: [SOLVED] UIButtonKeys - How to program in the B button?
« Reply #2 on: January 18, 2014, 09:36:51 AM »
That's what the cancel keys do. They clear the selection. It's like hitting Escape. You can always change the cancel keys to "None" on your UICamera.

Note that this only happens if the mouse input is allowed -- that is, you have both controller and mouse input active.

I guess it makes sense if it's intent is for keyboard and mouse.  I guess I will have to have only "keyboard and mouse" or "controller" options.
Creator of Soul Saga.
http://www.disastercake.com