Exemplo n.º 1
0
    public bool GetButton(string action)
    {
        if (XRDevice.isPresent)
        {
            foreach (WebVRControllerInput input in inputMap.inputs)
            {
                if (action == input.actionName)// && input.unityInputIsButton)
                {
                    return(XRInputMaster.ButtonCheck(inputMap.deviceRole, input.usageFeature));
                }
            }
        }

        if (!buttonStates.ContainsKey(action))
        {
            return(false);
        }
        return(buttonStates[action].pressed);
    }
Exemplo n.º 2
0
    public bool GetButtonDown(string action)
    {
        // Use Unity Input Manager when XR is enabled and WebVR is not being used (eg: standalone or from within editor).
        if (UnityEngine.XR.XRDevice.isPresent)
        {
            foreach (WebVRControllerInput input in inputMap.inputs)
            {
                if (action == input.actionName) // && input.unityInputIsButton)
                {
                    return(XRInputMaster.ButtonCheck(inputMap.deviceRole, input.usageFeature));
                    //return Input.GetButtonDown(input.unityInputName);
                }
            }
        }

        if (GetButton(action) && !GetPastButtonState(action))
        {
            SetPastButtonState(action, true);
            return(true);
        }
        return(false);
    }
Exemplo n.º 3
0
 void Update()
 {
     if (XRDevice.isPresent)
     {
         foreach (WebVRControllerInput input in controller.inputMap.inputs)
         {
             bool state = XRInputMaster.ButtonCheck(controller.inputMap.deviceRole, input.usageFeature);
             if (input.PreviousState != state)
             {
                 if (state)
                 {
                     input.PreviousState = state;
                     input.OnDown.Invoke();
                 }
                 else
                 {
                     input.PreviousState = state;
                     input.OnUp.Invoke();
                 }
             }
         }
     }
 }