Cross-platform wrapper for Unity Input. See OVRGamepadController for a list of the base axis and button names. Depending on joystick number and platform the base names will be pre-pended with "Platform:Joy #:" to look them up in the Unity Input table. For instance: using an axis name of "Left_X_Axis" with GetJoystickAxis() will result in looking up the axis named "Win: Joy 1: Left_X_Axis" when running on Windows and "Android: Joy 1: Left_X_Axis" when running on Android. In addition to wrapping joystick input, this class allows the assignment of up, held and down events for any key, mouse button, or joystick button via the AddInputHandler() method. Currently this class relies on enumerations defined in OVRGamepadController so that it remains compatible with existing Unity OVR projects. When this class is included it overloads the default GPC_GetAxis() and GPC_GetButton() calls to to ReadAxis() and ReadButton() in this class. Ideally this class would completely replace the OVRGamepadController class. This would involve changing the GPC_GetAxis() and GPC_GetButton() calls in a project and removing references to OVRGamepadController in this file (and moving some of the tables to InputControl).
예제 #1
0
    private void Update()
    {
        OVRInputControl.Update();

        if (Time.time < _startTime)
        {
            return;
        }
        if (!_started)
        {
            ReallyStart();
        }
        Score.StarsLeft = Block.GetCount(Block.Type.Special);
        if (Score.StarsLeft == 0 && NextLevelStartTime < 0.0f)
        {
            NextLevelStartTime = Time.time + _DelayBeforeNextLevel;
        }

        if (NextLevelStartTime >= 0.0f)
        {
            if (Time.time >= NextLevelStartTime)
            {
                NextLevel();
            }
        }
    }
예제 #2
0
    private void Start()
    {
        OVRInputControl.AddInputMapping(1, this);

        OVRInputControl.AddInputHandler(OVRInputControl.DeviceType.Keyboard, "l",
                                        OnKeyDown_Nil, OnKeyHeld_Nil, OnKeyUp_l);
        OVRInputControl.AddInputHandler(OVRInputControl.DeviceType.Keyboard, "space",
                                        OnKeyDown_Space, OnKeyHeld_Nil, OnKeyUp_Nil);
        OVRInputControl.AddInputHandler(OVRInputControl.DeviceType.Keyboard, "n",
                                        OnKeyDown_Nil, OnKeyHeld_Nil, OnKeyUp_N);
        OVRInputControl.AddInputHandler(OVRInputControl.DeviceType.Mouse,
                                        OVRInputControl.MouseButton.Left,
                                        OnKeyDown_Space, OnKeyHeld_Nil, OnKeyUp_Nil);
        OVRInputControl.AddInputHandler(OVRInputControl.DeviceType.Mouse,
                                        OVRInputControl.MouseButton.Right,
                                        OnKeyDown_Nil, OnKeyHeld_Nil, OnKeyUp_N);
        OVRInputControl.AddInputHandler(OVRInputControl.DeviceType.Gamepad,
                                        OVRGamepadController.Button.A,
                                        OnButtonDown_A, OnKeyHeld_Nil, OnKeyUp_Nil);
        OVRInputControl.AddInputHandler(OVRInputControl.DeviceType.Gamepad,
                                        OVRGamepadController.Button.B,
                                        OnButtonDown_B, OnKeyHeld_Nil, OnKeyUp_Nil);
        OVRInputControl.AddInputHandler(OVRInputControl.DeviceType.Gamepad,
                                        OVRGamepadController.Button.X,
                                        OnButtonDown_X, OnKeyHeld_Nil, OnKeyUp_Nil);
        OVRInputControl.AddInputHandler(OVRInputControl.DeviceType.Gamepad,
                                        OVRGamepadController.Button.Y,
                                        OnButtonDown_Y, OnKeyHeld_Nil, OnKeyUp_Nil);
        OVRInputControl.AddInputHandler(OVRInputControl.DeviceType.Gamepad,
                                        OVRGamepadController.Button.LeftShoulder,
                                        OnButtonDown_LeftShoulder, OnKeyHeld_Nil, OnKeyUp_Nil);
        OVRInputControl.AddInputHandler(OVRInputControl.DeviceType.Axis,
                                        OVRGamepadController.Axis.LeftTrigger,
                                        OnButtonDown_LeftTrigger, OnKeyHeld_Nil, OnKeyUp_Nil);

        Score.TitleScreen = true;
        _started          = false;
        _startTime        = Time.time + _startDelay;
    }