コード例 #1
0
 public Dictionary <string, SteamVR_Action_Single_Source> GenerateAxis1DInputMap() => new Dictionary <string, SteamVR_Action_Single_Source>()
 {
     { VRAxis.Two, SteamVR_Input.GetAction <SteamVR_Action_Single>("default", "Trigger")[SteamHand] },
     { VRAxis.TwoRaw, SteamVR_Input.GetAction <SteamVR_Action_Single>("default", "Trigger")[SteamHand] },
     { VRAxis.Three, SteamVR_Input.GetAction <SteamVR_Action_Single>("default", "Squeeze")[SteamHand] },
     { VRAxis.ThreeRaw, SteamVR_Input.GetAction <SteamVR_Action_Single>("default", "Squeeze")[SteamHand] },
 };
コード例 #2
0
ファイル: ingameGlobalManager.cs プロジェクト: nanalucky/AP
    public bool GetSteamVRPauseDown()
    {
        SteamVR_Action_Boolean action = SteamVR_Input.GetAction <SteamVR_Action_Boolean>("buggy", "Reset");
        bool state = action.GetStateDown(SteamVR_Input_Sources.RightHand);

        return(state);
    }
コード例 #3
0
 // Start is called before the first frame update
 void Start()
 {
     pCamera    = GameObject.FindGameObjectWithTag("MainCamera").GetComponent <Camera>(); //Get the active scene camera at the begining of the scene
     pRigidbody = GetComponent <Rigidbody>();
     moveVR     = SteamVR_Input.GetAction <SteamVR_Action_Vector2>("default", "move");
     lookVR     = SteamVR_Input.GetAction <SteamVR_Action_Vector2>("default", "look");
 }
コード例 #4
0
ファイル: ingameGlobalManager.cs プロジェクト: nanalucky/AP
    public bool GetSteamVRValidateUp(Hand hand)
    {
        SteamVR_Action_Boolean teleportAction = SteamVR_Input.GetAction <SteamVR_Action_Boolean>("Teleport");
        bool state = teleportAction.GetStateUp(hand.handType);

        return(state);
    }
コード例 #5
0
ファイル: ingameGlobalManager.cs プロジェクト: nanalucky/AP
    public bool GetSteamVRTeleportPlayerDown()
    {
        SteamVR_Action_Boolean action = SteamVR_Input.GetAction <SteamVR_Action_Boolean>("default", "GrabGrip");
        bool state = action.GetStateDown(SteamVR_Input_Sources.LeftHand) || action.GetStateDown(SteamVR_Input_Sources.RightHand);

        return(state);
    }
コード例 #6
0
        public override void OnUpdate()
        {
            //var vector2 = vector2Action.Value as SteamVR_Action_Vector2;

            switch (vector2Type)
            {
            case setTriggerType.getAxis:
                result = SteamVR_Input.GetAction <SteamVR_Action_Vector2>(vector2Action.Value).GetAxis(devices);
                break;

            case setTriggerType.getAxisDelta:
                result = SteamVR_Input.GetAction <SteamVR_Action_Vector2>(vector2Action.Value).GetAxisDelta(devices);
                break;

            case setTriggerType.getLastAxis:
                result = SteamVR_Input.GetAction <SteamVR_Action_Vector2>(vector2Action.Value).GetLastAxis(devices);
                break;

            case setTriggerType.getLastAxisDelta:
                result = SteamVR_Input.GetAction <SteamVR_Action_Vector2>(vector2Action.Value).GetLastAxisDelta(devices);
                break;
            }

            storeVector2Result.Value = result;
        }
コード例 #7
0
ファイル: ingameGlobalManager.cs プロジェクト: nanalucky/AP
    public bool GetSteamVRValidate()
    {
        SteamVR_Action_Boolean teleportAction = SteamVR_Input.GetAction <SteamVR_Action_Boolean>("Teleport");
        bool state = teleportAction.GetState(SteamVR_Input_Sources.LeftHand) || teleportAction.GetState(SteamVR_Input_Sources.RightHand);

        return(state);
    }
コード例 #8
0
        public override void OnUpdate()
        {
            DoGetVelocity();
            DoGetAngularVelocity();

            switch (positionType)
            {
            case setPositionType.getLocalPosition:
                storePosition.Value = SteamVR_Input.GetAction <SteamVR_Action_Pose>(poseAction.Value).GetLocalPosition(devices);
                break;

            case setPositionType.getLastLocalPosition:
                storePosition.Value = SteamVR_Input.GetAction <SteamVR_Action_Pose>(poseAction.Value).GetLastLocalPosition(devices);
                break;
            }
            switch (rotationType)
            {
            case setRotationType.getLocalRotation:
                storeRotation.Value = SteamVR_Input.GetAction <SteamVR_Action_Pose>(poseAction.Value).GetLocalRotation(devices);
                break;

            case setRotationType.getLastLocalRotation:
                storeRotation.Value = SteamVR_Input.GetAction <SteamVR_Action_Pose>(poseAction.Value).GetLastLocalRotation(devices);
                break;
            }
        }
コード例 #9
0
    void Start()
    {
        if (GameObject.FindGameObjectWithTag("leftHand").Equals(this.gameObject))
        {
            currentSource = SteamVR_Input_Sources.LeftHand;
        }
        else
        {
            if (GameObject.FindGameObjectWithTag("rightHand").Equals(this.gameObject))
            {
                currentSource = SteamVR_Input_Sources.RightHand;
            }
            else
            {
                print("This script is not on right or left hand");
            }
        }

        pose  = GetComponent <SteamVR_Behaviour_Pose>();
        hover = GetComponent <Hover>();

        currentActionSet  = SteamVR_Input.GetActionSet("MySet");
        gripClickAction   = SteamVR_Input.GetAction <SteamVR_Action_Boolean>("MySet", "GripClick", false, false);
        triggerPullAction = SteamVR_Input.GetAction <SteamVR_Action_Single>("MySet", "Teleport", false, false);
        joyStickAction    = SteamVR_Input.GetAction <SteamVR_Action_Vector2>("MySet", "Move", false, false);

        //Sword specific actions that need to be defined (They won't do anything until we activate the correct action set)
        detachAction       = SteamVR_Input.GetAction <SteamVR_Action_Boolean>("Sword", "Detach", false, false);
        triggerClickAction = SteamVR_Input.GetAction <SteamVR_Action_Boolean>("Sword", "InitiateSlash", false, false);
    }
コード例 #10
0
 /// <summary>
 /// Handles drop-off behaviour.
 /// </summary>
 private void HandleDropOff()
 {
     // Determine behaviour depending on mode.
     if (managerType == GraspManagerType.Controller)
     {
         // Releases object when the object interaction button is pressed and there is an object in hand.
         if (SteamVR_Input.GetAction <SteamVR_Action_Boolean>("ObjectInteractButton").GetStateDown(SteamVR_Input_Sources.Any) && objectInHand != null && (managerMode == GraspManagerMode.Open || (managerMode == GraspManagerMode.Restriced && inDropOff)))
         {
             ReleaseObjectInHand();
         }
     }
     else if (managerType == GraspManagerType.Assisted)
     {
         // Get hand velocity from physics engine when not tracked object
         if (!isTrackedObject)
         {
             handVelocity = handRB.velocity.magnitude;
         }
         // Get hand velocity and compare to threshold.
         if (HasHandStopped() && objectInHand != null && !releasing)
         {
             ReleaseObjectInHand();
         }
     }
 }
コード例 #11
0
    public override void Initialize(ActionCanvasBase actionCanvasBase)
    {
        base.Initialize(actionCanvasBase);

        actionTouch = SteamVR_Input.GetAction <SteamVR_Action_Boolean>(actionName + "Touch");
        actionPress = SteamVR_Input.GetAction <SteamVR_Action_Boolean>(actionName + "Press");
    }
コード例 #12
0
        public void Init()
        {
            // Get control input settings from script
            ViveControlInputs = new Dictionary <ViveControlType, ViveControlInput>();
            ViveControlInputs.Add(ViveControlType.Grip, new ViveControlInput(SteamVR_Input.GetAction <SteamVR_Action_Boolean>("srinput", "grip")));
            ViveControlInputs.Add(ViveControlType.Trigger, new ViveControlInput(SteamVR_Input.GetAction <SteamVR_Action_Boolean>("srinput", "trigger")));
            ViveControlInputs.Add(ViveControlType.Touchpad, new ViveControlInput(SteamVR_Input.GetAction <SteamVR_Action_Boolean>("srinput", "touchpadclick"), SteamVR_Input.GetAction <SteamVR_Action_Boolean>("srinput", "touchpadtouch"), SteamVR_Input.GetAction <SteamVR_Action_Vector2>("srinput", "touchpadposition")));

            //// Get control input settings from inspector
            //for (int i = 0; i < (int)ViveControlType.Max; ++i)
            //    ViveControlInputs[(ViveControlType)i] = ViveControlInputList[i];

            // Disable 2D
            Player.instance.allowToggleTo2D = false;

            // Get hand and add listener to each button
            hand = ViveSR_Experience.instance.targetHand;
            for (int i = 0; i < (int)ViveControlType.Max; ++i)
            {
                ViveControlType type = (ViveControlType)i;

                if (type == ViveControlType.Touchpad)
                {
                    ViveControlInputs[type].actionTouch.AddOnUpdateListener(ClickListener, hand.handType);
                }
                ViveControlInputs[type].actionClick.AddOnUpdateListener(ClickListener, hand.handType);
            }
        }
コード例 #13
0
 protected virtual void CheckSkeletonAction()
 {
     if (skeletonAction == null)
     {
         skeletonAction = SteamVR_Input.GetAction <SteamVR_Action_Skeleton0>("Skeleton" + inputSource.ToString());
     }
 }
コード例 #14
0
        public override void OnUpdate()
        {
            //var single = singleAction.Value as SteamVR_Action_Single;

            switch (singleType)
            {
            case setTriggerType.getAxis:
                result = SteamVR_Input.GetAction <SteamVR_Action_Single>(singleAction.Value).GetAxis(devices);
                break;

            case setTriggerType.getAxisDelta:
                result = SteamVR_Input.GetAction <SteamVR_Action_Single>(singleAction.Value).GetAxisDelta(devices);
                break;

            case setTriggerType.getLastAxis:
                result = SteamVR_Input.GetAction <SteamVR_Action_Single>(singleAction.Value).GetLastAxis(devices);
                break;

            case setTriggerType.getLastAxisDelta:
                result = SteamVR_Input.GetAction <SteamVR_Action_Single>(singleAction.Value).GetLastAxisDelta(devices);
                break;
            }

            // if variable set to none, assume multiplier is 1
            if (!multiplier.IsNone)
            {
                result *= multiplier.Value;
            }

            store.Value = result;
        }
コード例 #15
0
    public override void Initialize(ActionCanvasBase actionCanvasBase)
    {
        base.Initialize(actionCanvasBase);

        actionAxis = SteamVR_Input.GetAction <SteamVR_Action_Single>(actionName + "Axis");
        fillType   = FillImageOptions.Border;
    }
コード例 #16
0
    public override void Initialize(ActionCanvasBase actionCanvasBase)
    {
        base.Initialize(actionCanvasBase);

        skeleton = SteamVR_Input.GetAction <SteamVR_Action_Skeleton>("Skeleton" + actionCanvas.handType.ToString());

        index = int.Parse(actionName.Replace("finger", ""));
    }
コード例 #17
0
 public Dictionary <string, SteamVR_Action_Boolean_Source> GenerateButtonInputMap() => new Dictionary <string, SteamVR_Action_Boolean_Source>()
 {
     { VRButton.Trigger, SteamVR_Input.GetAction <SteamVR_Action_Boolean>("default", "InteractUI")[SteamHand] },
     { VRButton.One, SteamVR_Input.GetAction <SteamVR_Action_Boolean>("default", "InteractUI")[SteamHand] },
     { VRButton.Two, SteamVR_Input.GetAction <SteamVR_Action_Boolean>("default", "Secondary")[SteamHand] },
     { VRButton.Touch, SteamVR_Input.GetAction <SteamVR_Action_Boolean>("default", "JoystickPress")[SteamHand] },
     { VRButton.Back, SteamVR_Input.GetAction <SteamVR_Action_Boolean>("default", "Back")[SteamHand] },
 };
コード例 #18
0
 // Update walking with physics
 void FixedUpdate()
 {
     if (walkEnable.GetState(inputSource))
     {
         Vector2 trackpad      = SteamVR_Input.GetAction <SteamVR_Action_Vector2>("Trackpad").GetAxis(SteamVR_Input_Sources.Any);
         Vector3 walkingMotion = new Vector3(trackpad.x * Time.fixedDeltaTime, 0.0f, trackpad.y * Time.fixedDeltaTime);
         player.position += new Vector3(headTransform.TransformVector(walkingMotion).x, 0.0f, headTransform.TransformVector(walkingMotion).z);
     }
 }
コード例 #19
0
 private void InitializeSteamVR_Actions()
 {
     grabAction            = SteamVR_Input.GetAction <SteamVR_Action_Boolean>("VRShooterKit", "Grab");
     triggerAction         = SteamVR_Input.GetAction <SteamVR_Action_Boolean>("VRShooterKit", "Shoot");
     primaryButtonAction   = SteamVR_Input.GetAction <SteamVR_Action_Boolean>("VRShooterKit", "PrimaryButton");
     secondaryButtonAction = SteamVR_Input.GetAction <SteamVR_Action_Boolean>("VRShooterKit", "SecondaryButton");
     joystickPressAction   = SteamVR_Input.GetAction <SteamVR_Action_Boolean>("VRShooterKit", "JoystickPress");
     joystickInputAction   = SteamVR_Input.GetAction <SteamVR_Action_Vector2>("VRShooterKit", "Joystick");
 }
コード例 #20
0
    protected override void Awake()
    {
        base.Awake();

        m_TargetSource = SteamVR_Input_Sources.RightHand;
        m_ClickAction  = SteamVR_Input.GetAction <SteamVR_Action_Boolean>("InteractUI");

        m_Data = new PointerEventData(eventSystem);
    }
コード例 #21
0
    private void FixedUpdate()
    {
        _moveAxis = SteamVR_Input.GetAction <SteamVR_Action_Vector2>("move").GetAxis(SteamVR_Input_Sources.RightHand);
        _run      = SteamVR_Input.GetAction <SteamVR_Action_Boolean>("run").GetState(SteamVR_Input_Sources.RightHand);

        if (_rig != null)
        {
            _rig.position += (_camRig.transform.right * _moveAxis.x + _camRig.transform.forward * _moveAxis.y) * Time.deltaTime;
            _rig.position  = new Vector3(_rig.position.x, 0, _rig.position.z);
        }
    }
コード例 #22
0
    /// <summary>
    /// Checks the Tracker-Status and Updates the Position, Rotation and Velocity.
    /// </summary>
    protected override void UpdateTracker()
    {
        // Setting 'trackingOK' to false (In case we have an Error and return before the end of the method).
        trackingOK = false;
        // Check if OpenVR-System is found correctly.
        if (OpenVR.System == null)
        {
            Debug.LogError("<b>DHUI</b> | DroneTracking_Vive | OpenVR-System was not found.");
            return;
        }
        // If we didn't set the Action Pose.
        if (_VRTrackerActionPose == null)
        {
            // Check if there is an Active Action called "VRTracker".
            SteamVR_Action_Pose ap = SteamVR_Input.GetAction <SteamVR_Action_Pose>("VRTracker");
            if (ap.GetActive(SteamVR_Input_Sources.Any))
            {
                _VRTrackerActionPose = ap;
                droneTrackerIndex    = _VRTrackerActionPose.GetDeviceIndex(SteamVR_Input_Sources.Any);
            }
            else
            {
                Debug.LogError("<b>DHUI</b> | DroneTracking_Vive | No Active VR-Tracker was found.");
                return;
            }
        }

        // Copy Position and Rotation to the 'trackedTransform' and save the Velocity.
        // If 'trackTransformAsLocal' is true: Copy the real tracked pose to 'trackedTransform' as localPosition & localRotation
        if (trackTransformAsLocal)
        {
            trackedTransform.localPosition = _VRTrackerActionPose.GetLocalPosition(SteamVR_Input_Sources.Any) - trackerToDroneOffset_Position;
            trackedTransform.localRotation = _VRTrackerActionPose.GetLocalRotation(SteamVR_Input_Sources.Any) * Quaternion.Euler(trackerToDroneOffset_Rotation);
        }
        // If 'trackTransformAsLocal' is false (= default): Copy the real tracked pose to 'trackedTransform' as (global) position & rotation
        else
        {
            trackedTransform.position = _VRTrackerActionPose.GetLocalPosition(SteamVR_Input_Sources.Any) - trackerToDroneOffset_Position;
            trackedTransform.rotation = _VRTrackerActionPose.GetLocalRotation(SteamVR_Input_Sources.Any) * Quaternion.Euler(trackerToDroneOffset_Rotation);
        }

        velocity = _VRTrackerActionPose.GetVelocity(SteamVR_Input_Sources.Any);

        // Calculate the current pose for our device. [See https://github.com/ValveSoftware/openvr/wiki/IVRSystem::GetDeviceToAbsoluteTrackingPose]
        TrackedDevicePose_t[] trackedDevicePoses = new TrackedDevicePose_t[OpenVR.k_unMaxTrackedDeviceCount];
        OpenVR.System.GetDeviceToAbsoluteTrackingPose(ETrackingUniverseOrigin.TrackingUniverseStanding, 0.0f, trackedDevicePoses);
        TrackedDevicePose_t droneTrackedDevicePose = trackedDevicePoses[droneTrackerIndex];

        // If the 'TrackedDevicePose' of the drone is valid, connected and running ok, we can set the 'trackingOK' to true.
        if (droneTrackedDevicePose.bPoseIsValid && droneTrackedDevicePose.bDeviceIsConnected && droneTrackedDevicePose.eTrackingResult == ETrackingResult.Running_OK)
        {
            trackingOK = true;
        }
    }
コード例 #23
0
        public void ResetToInteractbaleDefault()
        {
            input.VRActions = GlobalKeys.VR_ACTIONS_ARRAY;
#if Int_Oculus || (Int_SteamVR && !Int_SteamVR2)
            input.triggerKey       = 1;
            input.triggerKeyOculus = 1;
            input.padTop           = 0;
            input.padTopOculus     = 0;
            input.padLeft          = 0;
            input.padLeftOculus    = 0;
            input.padRight         = 0;
            input.padRightOculus   = 0;
            input.padBottom        = 0;
            input.padBottomOculus  = 0;
            input.padCentre        = 0;
            input.padCentreOculus  = 0;
            input.padTouch         = 0;
            input.padTouchOculus   = 0;
            input.gripKey          = 2;
            input.gripKeyOculus    = 2;
            input.menuKey          = 0;
            input.menuKeyOculus    = 0;
            input.AXKey            = 0;
            input.AXKeyOculus      = 0;
#endif

#if Int_SteamVR2
            if (input.isSteamVR())
            {
                SteamVR_Action_Boolean actionAction     = SteamVR_Input.GetAction <SteamVR_Action_Boolean>(GlobalKeys.KEY_ACTION);
                SteamVR_Action_Boolean pickupDropAction = SteamVR_Input.GetAction <SteamVR_Action_Boolean>(GlobalKeys.KEY_PICKUP_DROP);
                input.booleanActions.Clear();
                input.booleanActions.Add(actionAction);
                input.booleanActions.Add(pickupDropAction);

                input.triggerPressure = SteamVR_Input.GetAction <SteamVR_Action_Single>("TriggerPressure");
                input.touchPosition   = SteamVR_Input.GetAction <SteamVR_Action_Vector2>("TouchPosition");
                input.padTouched      = SteamVR_Input.GetAction <SteamVR_Action_Boolean>("PadTouched");
                input.padPressed      = SteamVR_Input.GetAction <SteamVR_Action_Boolean>("PadPressed");

                input.handType = input.IsLeftHand ? SteamVR_Input_Sources.LeftHand : SteamVR_Input_Sources.RightHand;
                SteamVR_Behaviour_Pose poseComp = input.GetComponent <SteamVR_Behaviour_Pose>();
                if (poseComp == null)
                {
                    poseComp             = input.gameObject.AddComponent <SteamVR_Behaviour_Pose>();
                    poseComp.inputSource = input.handType;
                }
            }
#endif

            EditorUtility.SetDirty(input);
            EditorSceneManager.MarkSceneDirty(SceneManager.GetActiveScene());
        }
コード例 #24
0
        IEnumerator DoStartCoroutine()
        {
            float startTime = FsmTime.RealtimeSinceStartup;

            while (FsmTime.RealtimeSinceStartup - startTime <= duration.Value)
            {
                SteamVR_Input.GetAction <SteamVR_Action_Vibration>(hapticAction.Value).Execute(0, duration.Value, frequency.Value, amplitude.Value, devices);
                yield return(null);
            }

            Fsm.Event(sendEvent);
        }
コード例 #25
0
    // Update is called once per frame
    void Update()
    {
        MenuDown = SteamVR_Input.GetAction <SteamVR_Action_Boolean>("Menu").GetStateDown(InputSource);
        Menu     = SteamVR_Input.GetAction <SteamVR_Action_Boolean>("Menu").GetState(InputSource);
        MenuUp   = SteamVR_Input.GetAction <SteamVR_Action_Boolean>("Menu").GetStateUp(InputSource);

        TriggerDown = SteamVR_Input.GetAction <SteamVR_Action_Boolean>("GrabPinch").GetStateDown(InputSource);
        Trigger     = SteamVR_Input.GetAction <SteamVR_Action_Boolean>("GrabPinch").GetState(InputSource);
        TriggerUp   = SteamVR_Input.GetAction <SteamVR_Action_Boolean>("GrabPinch").GetStateUp(InputSource);

        TouchPadDown = SteamVR_Input.GetAction <SteamVR_Action_Boolean>("TouchPad").GetStateDown(InputSource);
        TouchPad     = SteamVR_Input.GetAction <SteamVR_Action_Boolean>("TouchPad").GetState(InputSource);
        TouchPadUp   = SteamVR_Input.GetAction <SteamVR_Action_Boolean>("TouchPad").GetStateUp(InputSource);

        TouchClicDown = SteamVR_Input.GetAction <SteamVR_Action_Boolean>("Teleport").GetStateDown(InputSource);
        TouchClic     = SteamVR_Input.GetAction <SteamVR_Action_Boolean>("Teleport").GetState(InputSource);
        TouchClicUp   = SteamVR_Input.GetAction <SteamVR_Action_Boolean>("Teleport").GetStateUp(InputSource);

        GripDown = SteamVR_Input.GetAction <SteamVR_Action_Boolean>("GrabGrip").GetStateDown(InputSource);
        Grip     = SteamVR_Input.GetAction <SteamVR_Action_Boolean>("GrabGrip").GetState(InputSource);
        GripUp   = SteamVR_Input.GetAction <SteamVR_Action_Boolean>("GrabGrip").GetStateUp(InputSource);



        Squeeze = SteamVR_Input.GetSingleAction("Squeeze").GetAxis(InputSource);
        //Squeeze = (float)System.Math.Round(Squeeze , 2);
        if (Squeeze <= 0.05f)
        {
            Squeeze = 0;
        }

        TouchPos = SteamVR_Input.GetVector2Action("TouchPos").GetAxis(InputSource);
        //TouchPos = new Vector2 ((float)System.Math.Round(TouchPos.x , 2) , (float)System.Math.Round(TouchPos.y , 2) );

        /*
         * if (Menu) print("Menu");
         * if (MenuUp) print("MenuUp");
         * if (MenuDown) print("MenuDown");
         * if (Trigger) print("Trigger");
         * if (TriggerUp) print("TriggerUp");
         * if (TriggerDown) print("TriggerDown");
         * if (TouchPad) print("TouchPad");
         * if (TouchPadUp) print("TouchPadUp");
         * if (TouchPadDown) print("TouchPadDown");
         * if (TouchClic) print("TouchClic");
         * if (TouchClicUp) print("TouchClicUp");
         * if (TouchClicDown) print("TouchClicDown");
         * if (Grip) print("Grip");
         * if (GripUp) print("GripUp");
         * if (GripDown) print("GripDown");
         */
    }
コード例 #26
0
    void Update()
    {
        if (SteamVR_Input.GetAction <SteamVR_Action_Boolean>("Teleport").GetStateUp(SteamVR_Input_Sources.RightHand))
        {
            _teleport = true;
        }
        _hasPosition = UpdatePointer();
        _pointer.SetActive(_hasPosition);

        if (_teleport)
        {
            TryTeleport();
        }
    }
コード例 #27
0
        void DoGetAngularVelocity()
        {
            switch (angularVelocityType)
            {
            case setaVelocityType.getAngularVelocity:
                velocity = SteamVR_Input.GetAction <SteamVR_Action_Pose>(poseAction.Value).GetVelocity(devices);
                break;

            case setaVelocityType.getLastStateAngularVelocity:
                velocity = SteamVR_Input.GetAction <SteamVR_Action_Pose>(poseAction.Value).GetLastVelocity(devices);
                break;
            }

            storeAngularVelocity = velocity;
        }
コード例 #28
0
    // Start is called before the first frame update
    void Start()
    {
        //create a quad a circle for gazeing in VR or mouse cursor in non VR
        oGazeQuad = GameObject.CreatePrimitive(PrimitiveType.Quad);
        oGazeQuad.transform.parent = transform;
        MonoBehaviour.DestroyImmediate(oGazeQuad.GetComponent <Collider>());
        oCursorMaterial = Resources.Load("Cursor", typeof(Material)) as Material;
        oGazeQuad.GetComponent <MeshRenderer>().material = oCursorMaterial;
        oGazeQuad.transform.localScale = new Vector3(.38f, .38f, 1);
        oGazeQuad.SetActive(false);

        poseActionR = SteamVR_Input.GetAction <SteamVR_Action_Pose>("Pose_right_tip");
        poseActionL = SteamVR_Input.GetAction <SteamVR_Action_Pose>("Pose_left_tip");

        iRightHanded = 0;
    }
コード例 #29
0
        private static void InitializeActionMapping()
        {
            hapticAction              = SteamVR_Input.GetAction <SteamVR_Action_Vibration>("Haptic", false);
            m_weaponSwitchLeftAction  = SteamVR_Input.GetBooleanAction("WeaponSwitchLeft", false);
            m_weaponSwitchRightAction = SteamVR_Input.GetBooleanAction("WeaponSwitchRight", false);
            m_reloadAction            = SteamVR_Input.GetBooleanAction("Reload", false);
            m_flashlightAction        = SteamVR_Input.GetBooleanAction("ToggleFlashlight", false);
            m_shootAction             = SteamVR_Input.GetBooleanAction("Shoot", false);
            m_movementAxisAction      = SteamVR_Input.GetVector2Action("Movement", false);
            m_interactAction          = SteamVR_Input.GetBooleanAction("interact", false);
            m_crouchAction            = SteamVR_Input.GetBooleanAction("Crouch", false);
            m_sprintAction            = SteamVR_Input.GetBooleanAction("Sprint", false);
            m_jumpAction              = SteamVR_Input.GetBooleanAction("Jump", false);
            m_openMapAction           = SteamVR_Input.GetBooleanAction("OpenMap", false);
            m_openMenuAction          = SteamVR_Input.GetBooleanAction("OpenMenu", false);
            m_pingAction              = SteamVR_Input.GetBooleanAction("Ping", false);
            m_openObjectivesAction    = SteamVR_Input.GetBooleanAction("OpenObjectives", false);
            m_aimOrShoveAction        = SteamVR_Input.GetBooleanAction("AimOrShove", false);
            m_pushToTalkAction        = SteamVR_Input.GetBooleanActionFromPath("/actions/default/in/PushToTalk");


            boolActions = new Dictionary <InputAction, SteamVR_Action_Boolean>
            {
                { InputAction.Jump, m_jumpAction },
                { InputAction.Use, m_interactAction },
                { InputAction.Aim, m_aimOrShoveAction },
                { InputAction.ToggleObjectives, m_openObjectivesAction },
                { InputAction.Fire, m_shootAction },
                { InputAction.Run, m_sprintAction },
                { InputAction.Crouch, m_crouchAction },
                { InputAction.Reload, m_reloadAction },
                { InputAction.VoiceChatPushToTalk, m_pushToTalkAction },
                { InputAction.NavMarkerPing, m_pingAction },
                { InputAction.TerminalUp, m_weaponSwitchLeftAction },
                { InputAction.TerminalDown, m_weaponSwitchRightAction },
                { InputAction.TerminalExit, m_reloadAction },
                { InputAction.MenuClick, m_shootAction },
                //{ InputAction.MenuClickAlternate, interactAction },
                { InputAction.MenuExit, m_reloadAction },
                { InputAction.MenuToggle, m_openMenuAction },
                { InputAction.ToggleMap, m_openMapAction },
                { InputAction.Flashlight, m_flashlightAction },
            };
        }
コード例 #30
0
        public void ResetToInteractbaleDefault()
        {
            input.VRActions = new string[] { "NONE", "ACTION", "PICKUP_DROP" };

            input.triggerKey   = 1;
            input.padTop       = 0;
            input.padLeft      = 0;
            input.padRight     = 0;
            input.padBottom    = 0;
            input.padCentre    = 0;
            input.padTouch     = 0;
            input.gripKey      = 2;
            input.menuKey      = 0;
            input.primaryKey   = 0;
            input.secondaryKey = 0;

#if Int_SteamVR2
            if (input.isSteamVR())
            {
                SteamVR_Action_Boolean actionAction     = SteamVR_Input.GetAction <SteamVR_Action_Boolean>("ACTION");
                SteamVR_Action_Boolean pickupDropAction = SteamVR_Input.GetAction <SteamVR_Action_Boolean>("PICKUP_DROP");
                input.booleanActions.Clear();
                input.booleanActions.Add(actionAction);
                input.booleanActions.Add(pickupDropAction);

                input.triggerPressure = SteamVR_Input.GetAction <SteamVR_Action_Single>("TriggerPressure");
                input.touchPosition   = SteamVR_Input.GetAction <SteamVR_Action_Vector2>("TouchPosition");
                input.padTouched      = SteamVR_Input.GetAction <SteamVR_Action_Boolean>("PadTouched");
                input.padPressed      = SteamVR_Input.GetAction <SteamVR_Action_Boolean>("PadPressed");

                input.handType = input.LeftHand ? SteamVR_Input_Sources.LeftHand : SteamVR_Input_Sources.RightHand;
                SteamVR_Behaviour_Pose poseComp = input.GetComponent <SteamVR_Behaviour_Pose>();
                if (poseComp == null)
                {
                    poseComp             = input.gameObject.AddComponent <SteamVR_Behaviour_Pose>();
                    poseComp.inputSource = input.handType;
                }
            }
#endif

            EditorUtility.SetDirty(input);
            EditorSceneManager.MarkSceneDirty(SceneManager.GetActiveScene());
        }