Author Topic: (3.0.8 f6) UIKeyBinding.Update nullref  (Read 1717 times)

Gwl

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 8
    • View Profile
(3.0.8 f6) UIKeyBinding.Update nullref
« on: January 07, 2014, 09:17:14 AM »
There's no check if UICamera.currentTouch is null. If I read UICamera correctly, it's always being nullified in its Update so unless I'm missing something this can't work.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: (3.0.8 f6) UIKeyBinding.Update nullref
« Reply #1 on: January 07, 2014, 09:24:44 AM »
Yup, it's already fixed in the Pro version so you will see it in the next update. The fixed UIKeyBinding.Update function:
  1.         void Update ()
  2.         {
  3.                 if (keyCode == KeyCode.None || !IsModifierActive()) return;
  4.  
  5.                 if (action == Action.PressAndClick)
  6.                 {
  7.                         if (UICamera.inputHasFocus) return;
  8.  
  9.                         UICamera.currentTouch = UICamera.controller;
  10.                         UICamera.currentScheme = UICamera.ControlScheme.Controller;
  11.                         UICamera.currentTouch.current = gameObject;
  12.  
  13.                         if (Input.GetKeyDown(keyCode))
  14.                         {
  15.                                 UICamera.Notify(gameObject, "OnPress", true);
  16.                         }
  17.  
  18.                         if (Input.GetKeyUp(keyCode))
  19.                         {
  20.                                 UICamera.Notify(gameObject, "OnPress", false);
  21.                                 UICamera.Notify(gameObject, "OnClick", null);
  22.                         }
  23.                         UICamera.currentTouch.current = null;
  24.                 }
  25.                 else if (action == Action.Select)
  26.                 {
  27.                         if (Input.GetKeyUp(keyCode))
  28.                         {
  29.                                 if (mIsInput)
  30.                                 {
  31.                                         if (!mIgnoreUp && !UICamera.inputHasFocus)
  32.                                         {
  33.                                                 UICamera.selectedObject = gameObject;
  34.                                         }
  35.                                         mIgnoreUp = false;
  36.                                 }
  37.                                 else
  38.                                 {
  39.                                         UICamera.selectedObject = gameObject;
  40.                                 }
  41.                         }
  42.                 }
  43.         }
P.S. You likely won't have UICamera.controller, so you can replace that with UICamera.GetMouse(0).