GPC_GetButtonDown() public static method

Returns true if the given Button was pressed this frame.
public static GPC_GetButtonDown ( Button, button ) : bool
button Button,
return bool
コード例 #1
0
 void Update()
 {
     if (Input.GetKeyDown(KeyCode.Space) || OVRGamepadController.GPC_GetButtonDown(OVRGamepadController.Button.Back))
     {
         VR.InputTracking.Recenter();
     }
 }
コード例 #2
0
ファイル: OVRDebugGraph.cs プロジェクト: farmerp/Perspective
    /// <summary>
    /// Check input and toggle the debug graph.
    /// See the input mapping setup in the Unity Integration guide.
    /// </summary>
    void Update()
    {
        // NOTE: some of the buttons defined in OVRGamepadController.Button are not available on the Android game pad controller
        if (OVRGamepadController.GPC_GetButtonDown(toggleButton))
        {
            Debug.Log(" TOGGLE GRAPH ");

            //*************************
            // toggle the debug graph .. off -> running -> paused
            //*************************
            switch (debugMode)
            {
            case DebugPerfMode.DEBUG_PERF_OFF:
                debugMode = DebugPerfMode.DEBUG_PERF_RUNNING;
                break;

            case DebugPerfMode.DEBUG_PERF_RUNNING:
                debugMode = DebugPerfMode.DEBUG_PERF_FROZEN;
                break;

            case DebugPerfMode.DEBUG_PERF_FROZEN:
                debugMode = DebugPerfMode.DEBUG_PERF_OFF;
                break;
            }

            // Turn on/off debug graph
            OVRPlugin.debugDisplay = (debugMode != DebugPerfMode.DEBUG_PERF_OFF);
            OVRPlugin.collectPerf  = (debugMode == DebugPerfMode.DEBUG_PERF_FROZEN);
        }
    }
コード例 #3
0
    void Update()
    {
        if (fuel < maxFuel)
        {
            fuel = Mathf.Clamp(fuel + Time.deltaTime * fuelReplenishedPerSecond, 0, maxFuel);
        }

        if (flying)
        {
            if ((Input.GetKey(KeyCode.Space) || OVRGamepadController.GPC_GetButton(OVRGamepadController.Button.A)) && fuel > 0)
            {
                fuel -= fuelConsumePerSecond * Time.deltaTime;
                Vector3 moveDir = flightDirection;


                if (playerTransform.position.y < maxHeight)
                {
                    moveDir.y = 1;
                }
                playerTransform.position = playerTransform.position + moveDir * Time.deltaTime * moveSpeed;
            }
            else
            {
                audioSource.Stop();
                flying = false;
            }
        }
        else
        {
            if ((Input.GetKeyDown(KeyCode.Space) || OVRGamepadController.GPC_GetButtonDown(OVRGamepadController.Button.A)) && fuel > 0)
            {
                Audio.PlaySound(jetTakeoff, transform.position);
                audioSource.PlayDelayed(jetTakeoff.length);
                flying            = true;
                flightDirection   = cameraTransform.forward;
                flightDirection.y = 0;
            }
            else
            {
                if (playerTransform.position.y > minHeight)
                {
                    Vector3 moveDir = flightDirection;
                    moveDir.y = -1;

                    playerTransform.position = playerTransform.position + moveDir * Time.deltaTime * moveSpeed;
                    if (playerTransform.position.y <= minHeight)
                    {
                        Audio.PlaySound(jetLand, transform.position);
                    }
                }
            }
        }

        Vector3 finalPos = transform.position;

        finalPos.x = Mathf.Clamp(finalPos.x, -limit.x, limit.x);
        finalPos.z = Mathf.Clamp(finalPos.z, -limit.y, limit.y);

        playerTransform.position = finalPos;
    }
コード例 #4
0
 /// <summary>
 /// Check input and reset orientation if necessary
 /// See the input mapping setup in the Unity Integration guide
 /// </summary>
 void Update()
 {
     // NOTE: some of the buttons defined in OVRGamepadController.Button are not available on the Android game pad controller
     if (OVRGamepadController.GPC_GetButtonDown(resetButton))
     {
         //*************************
         // reset orientation
         //*************************
         OVRManager.display.RecenterPose();
     }
 }
コード例 #5
0
 void Update()
 {
     // NOTE: some of the buttons defined in OVRGamepadController.Button are not available on the Android game pad controller
     if (OVRGamepadController.GPC_GetButtonDown(toggleButton))
     {
         //*************************
         // toggle chromatic aberration correction
         //*************************
         chromatic = !chromatic;
         OVRManager.instance.chromatic = chromatic;
     }
 }
コード例 #6
0
ファイル: OVRMonoscopic.cs プロジェクト: farmerp/Perspective
 /// <summary>
 /// Check input and toggle monoscopic rendering mode if necessary
 /// See the input mapping setup in the Unity Integration guide
 /// </summary>
 void Update()
 {
     // NOTE: some of the buttons defined in OVRGamepadController.Button are not available on the Android game pad controller
     if (OVRGamepadController.GPC_GetButtonDown(toggleButton))
     {
         //*************************
         // toggle monoscopic rendering mode
         //*************************
         monoscopic = !monoscopic;
         OVRManager.instance.monoscopic = monoscopic;
     }
 }
コード例 #7
0
ファイル: OVRModeParms.cs プロジェクト: Bdiaz20/Slug
 /// <summary>
 /// Change default vr mode parms dynamically.
 /// </summary>
 void Update()
 {
     // NOTE: some of the buttons defined in OVRGamepadController.Button are not available on the Android game pad controller
     if (OVRGamepadController.GPC_GetButtonDown(resetButton))
     {
         //*************************
         // Dynamically change VrModeParms cpu and gpu level.
         // NOTE: Reset will cause 1 frame of flicker as it leaves
         // and re-enters Vr mode.
         //*************************
         OVRPlugin.cpuLevel = 0;
         OVRPlugin.gpuLevel = 1;
     }
 }
コード例 #8
0
 void ListenForMenuButtons()
 {
     if (guiObject.TutorialText)
     {
         if (Input.GetKeyDown(KeyCode.T) || OVRGamepadController.GPC_GetButtonDown(OVRGamepadController.Button.A) && guiObject.TutorialText)
         {
             // start game
             guiObject.TutorialText = false;
         }
     }
     else if (guiObject.RestartText)
     {
     }
 }
コード例 #9
0
    void ListenToWeaponCycle()
    {
        WeaponMgr.WeaponType type = WeaponMgr.ACTIVE_WEAPON.GetWeaponType();

        if (OVRGamepadController.GPC_GetButtonDown(OVRGamepadController.Button.LeftShoulder))
        {
            Debug.Log("CYCLE LEFT WPN");
            // cycle weapon left
            if (type > 0)
            {
                WeaponMgr.ChangeWeapon(type - 1);
            }
        }
        else if (OVRGamepadController.GPC_GetButtonDown(OVRGamepadController.Button.RightShoulder))
        {
            Debug.Log("CYCLE RIGHT WPN");
            // cycle weapon right
            if (type < (WeaponMgr.WeaponType.WEAPON_COUNT - 1))
            {
                WeaponMgr.ChangeWeapon(type + 1);
            }
        }
    }
コード例 #10
0
    void Update()
    {
        shotLimit = WeaponMgr.ACTIVE_WEAPON.FireRate;

        if (!m_oculusConnected)
        {
            SetupMouseLookat();
        }

        // skip tutorial, restart etc.
        ListenForMenuButtons();
        // previous, next weapon
        ListenToWeaponCycle();

        CycleWeapons();

        // TODO: also check if 0, then reset timer
        if (Input.GetMouseButtonDown(0) || Mathf.Abs(OVRGamepadController.GPC_GetAxis(OVRGamepadController.Axis.RightTrigger)) > 0 || Input.GetMouseButton(0))
        {
            // shoot and other stuff
            if (m_timeSinceShot <= shotLimit)
            {
                m_timeSinceShot += Time.deltaTime * 1000.0f; // add time in ms
                return;
            }
            else
            {
                m_timeSinceShot = 0;
                Shoot();
            }
        }

        if (Input.GetKeyDown(KeyCode.R) || OVRGamepadController.GPC_GetButtonDown(OVRGamepadController.Button.B))
        {
            Application.LoadLevel(Application.loadedLevelName);
        }
    }
コード例 #11
0
        /// <summary>
        /// Get state of button corresponding to gaze pointer
        /// </summary>
        /// <returns></returns>
        protected PointerEventData.FramePressState GetGazeButtonState()
        {
            var pressed  = Input.GetKeyDown(gazeClickKey) || OVRGamepadController.GPC_GetButtonDown(joyPadClickButton);
            var released = Input.GetKeyUp(gazeClickKey) || OVRGamepadController.GPC_GetButtonUp(joyPadClickButton);

#if UNITY_ANDROID && !UNITY_EDITOR
            pressed  |= Input.GetMouseButtonDown(0);
            released |= Input.GetMouseButtonUp(0);
#endif

            if (pressed && released)
            {
                return(PointerEventData.FramePressState.PressedAndReleased);
            }
            if (pressed)
            {
                return(PointerEventData.FramePressState.Pressed);
            }
            if (released)
            {
                return(PointerEventData.FramePressState.Released);
            }
            return(PointerEventData.FramePressState.NotChanged);
        }
コード例 #12
0
    protected virtual void Update()
    {
        if (OVRGamepadController.GPC_GetButtonDown(1) || Input.GetKeyDown(KeyCode.P))
        {
            Debug.Log("entered print screen");
            File.Delete("screen.png");
            Application.CaptureScreenshot("screen.png");
            StartCoroutine("Pics");
        }

        UpdateMovement();

        Vector3 moveDirection = Vector3.zero;

        float motorDamp = (1.0f + (Damping * OVRDevice.SimulationRate * Time.deltaTime));

        MoveThrottle.x /= motorDamp;
        MoveThrottle.y  = (MoveThrottle.y > 0.0f) ? (MoveThrottle.y / motorDamp) : MoveThrottle.y;
        MoveThrottle.z /= motorDamp;

        moveDirection += MoveThrottle * OVRDevice.SimulationRate * Time.deltaTime;

        // Gravity
        if (Controller.isGrounded && FallSpeed <= 0)
        {
            FallSpeed = ((Physics.gravity.y * (GravityModifier * 0.002f)));
        }
        else
        {
            FallSpeed += ((Physics.gravity.y * (GravityModifier * 0.002f)) * OVRDevice.SimulationRate * Time.deltaTime);
        }

        moveDirection.y += FallSpeed * OVRDevice.SimulationRate * Time.deltaTime;

        // Offset correction for uneven ground
        float bumpUpOffset = 0.0f;

        if (Controller.isGrounded && MoveThrottle.y <= 0.001f)
        {
            bumpUpOffset = Mathf.Max(Controller.stepOffset,
                                     new Vector3(moveDirection.x, 0, moveDirection.z).magnitude);
            moveDirection -= bumpUpOffset * Vector3.up;
        }

        Vector3 predictedXZ = Vector3.Scale((Controller.transform.localPosition + moveDirection),
                                            new Vector3(1, 0, 1));

        // Move contoller
        Controller.Move(moveDirection);

        Vector3 actualXZ = Vector3.Scale(Controller.transform.localPosition, new Vector3(1, 0, 1));

        if (predictedXZ != actualXZ)
        {
            MoveThrottle += (actualXZ - predictedXZ) / (OVRDevice.SimulationRate * Time.deltaTime);
        }

        // Update rotation using CameraController transform, possibly proving some rules for
        // sliding the rotation for a more natural movement and body visual
        UpdatePlayerForwardDirTransform();
    }