void OnChange(SteamVR_Action_In action) //Creates and deploys an Event on any Input action
        {
            STKEventSender sender = GetComponent <STKEventSender>();

            sender.SetEventValue("Name", action.GetShortName());
            if (action.GetType() == typeof(SteamVR_Action_Boolean))
            {
                SteamVR_Action_Boolean v = (SteamVR_Action_Boolean)action;
                sender.SetEventValue("boolValue", v.GetState(SteamVR_Input_Sources.Any));
            }
            else if (action.GetType() == typeof(SteamVR_Action_Single))
            {
                SteamVR_Action_Single v = (SteamVR_Action_Single)action;
                sender.SetEventValue("singleValue", v.GetAxis(SteamVR_Input_Sources.Any));
            }
            else if (action.GetType() == typeof(SteamVR_Action_Vector2))
            {
                SteamVR_Action_Vector2 v = (SteamVR_Action_Vector2)action;
                sender.SetEventValue("vector2Value", v.GetAxis(SteamVR_Input_Sources.Any));
            }
            else if (action.GetType() == typeof(SteamVR_Action_Vector3))
            {
                SteamVR_Action_Vector3 v = (SteamVR_Action_Vector3)action;
                sender.SetEventValue("vector3Value", v.GetAxis(SteamVR_Input_Sources.Any));
            }
            sender.Deploy();
        }
Пример #2
0
 private void OnSliderClicked(SteamVR_Action_In actionIn)
 {
     if (clickedSliderAction.GetStateUp(inputSource))
     {
         Hide(true);
     }
 }
Пример #3
0
 void OnGrabGripChange(SteamVR_Action_In actionIn)
 {
     if (grabGripAction.GetStateDown(hand.handType))
     {
         DropObj();
     }
 }
Пример #4
0
 // when the trigger is pressed, play a note
 void onPlay(SteamVR_Action_In actionIn)
 {
     if (showLine && PlayAction.GetStateDown(hand.handType))
     {
         Play();
     }
 }
Пример #5
0
 void OnGrabActionChange(SteamVR_Action_In actionIn)
 {
     if (forwardAction.GetState(skeleton.inputSource))
     {
         FindObjectOfType <DialogueTrigger>().TriggerDialogue();
     }
 }
Пример #6
0
        private void OnClickAction(SteamVR_Action_In actionIn)
        {
            if (clickAction.GetStateDown(inputSource))
            {
                return;
            }
            var selectedGo = EventSystem.current.currentSelectedGameObject;

            if (selectedGo == null)
            {
                return;
            }

            var selectable = selectedGo.GetComponent <Selectable>();

            if (selectable != null)
            {
                // Execute click on selectable
                ExecuteEvents.Execute(selectable.gameObject, new BaseEventData(EventSystem.current),
                                      ExecuteEvents.submitHandler);
                OnClick?.Invoke();
            }

            var controllerUi = GetComponentInParent <ControllerUI>();

            if (controllerUi != null && hideOnClick.Contains(selectable))
            {
                controllerUi.Hide();
            }
        }
Пример #7
0
 // when the touchpad is clicked, Pull/release the object
 void onPull(SteamVR_Action_In actionIn)
 {
     if (showLine && PullAction.GetStateDown(hand.handType))
     {
         Pull();
     }
 }
Пример #8
0
        /// <summary>
        ///     Will search for the next key by strokes. If a key is closer than 0.025 cm it will be selected.
        /// </summary>
        /// <param name="actionIn"></param>
        private void OnStrokeSelectedClicked(SteamVR_Action_In actionIn)
        {
            var start = Environment.TickCount;

            if (!selectStrokeAction.GetStateDown(SteamVR_Input_Sources.LeftHand))
            {
                return;
            }
            var probe = new Ray(leftControllerGO.transform.position,
                                leftControllerGO.transform.rotation * Vector3.forward);

            if (!Physics.Raycast(probe, out var hit, 50f, LayerMask.GetMask("Interface/Model")))
            {
                return;
            }
            foreach (var stroke in from stroke in lineRenderers.Keys
                     from key in stroke.keys
                     let dist = Vector3.Distance(key.position, hit.point)
                                where dist < 0.025
                                select stroke)
            {
                currentStroke?.myMarker.Select(false);
                selectStroke(stroke);
                currentStroke?.myMarker.Select(true);
                return;
            }
        }
Пример #9
0
 private void OnShootActionChange(SteamVR_Action_In actionIn)
 {
     if (shootAction.GetStateDown(hand.handType))
     {
         this.GetComponent <SimpleGun>().SpawnShot();
     }
 }
Пример #10
0
 private void OnRotateActionChange(SteamVR_Action_In actionIn)
 {
     if (rotateAction.GetStateDown(hand.handType))
     {
         Rotate();
     }
 }
Пример #11
0
 private void OnPlantActionChange(SteamVR_Action_In actionIn)
 {
     if (jumpAction.GetStateDown(hand.handType))
     {
         Jump();
     }
 }
Пример #12
0
 protected virtual void OnSkeletonActiveChange(SteamVR_Action_In action, bool newState)
 {
     if (newState)
     {
         InitializeHand();
     }
 }
Пример #13
0
        //-------------------------------------------------
        private void ShowText(SteamVR_Action_In action, string text, bool highlightButton = true)
        {
            if (actionHintInfos.ContainsKey(action))
            {
                var hintInfo = actionHintInfos[action];
                hintInfo.textHintObject.SetActive(true);
                hintInfo.textHintActive = true;

                if (hintInfo.text != null)
                {
                    hintInfo.text.text = text;
                }

                if (hintInfo.textMesh != null)
                {
                    hintInfo.textMesh.text = text;
                }

                UpdateTextHint(hintInfo);

                if (highlightButton)
                {
                    ShowButtonHint(action);
                }

                renderModel.gameObject.SetActive(true);
            }
        }
Пример #14
0
 void OnGrabPinchChange(SteamVR_Action_In actionIn)
 {
     if (grabPinchAction.GetStateDown(hand.handType))
     {
         PickupObj();
     }
 }
Пример #15
0
 void OnShootActionChange(SteamVR_Action_In actionIn)
 {
     if (inputSource == SteamVR_Input_Sources.RightHand)
     {
         if (shootAction.GetStateDown(SteamVR_Input_Sources.RightHand))
         {
             altFire = true;
         }
         else if (shootAction.GetStateUp(SteamVR_Input_Sources.RightHand))
         {
             altFire = false;
         }
     }
     else if (inputSource == SteamVR_Input_Sources.LeftHand)
     {
         if (shootAction.GetStateDown(SteamVR_Input_Sources.LeftHand))
         {
             altFire = true;
         }
         else if (shootAction.GetStateUp(SteamVR_Input_Sources.LeftHand))
         {
             altFire = false;
         }
     }
 }
Пример #16
0
 private void OnTouchpadTouched(SteamVR_Action_In actionIn)
 {
     if (touchedTouchpadAction.GetStateUp(inputSource))
     {
         EventSystem.current
         .SetSelectedGameObject(null);     //clear the old selection for directly selecting another one.
     }
 }
 private void OnManualActionChange(SteamVR_Action_In actionIn)
 {
     if (manualAction.GetStateDown(hand.handType))
     {
         Debug.Log("Opening Virtual Manual");
         manualCanvasObject.gameObject.SetActive(!manualCanvasObject.isActiveAndEnabled);
     }
 }
Пример #18
0
        //-------------------------------------------------
        public static void HideTextHint(Hand hand, SteamVR_Action_In action)
        {
            var hints = GetControllerButtonHints(hand);

            if (hints != null)
            {
                hints.HideText(action);
            }
        }
Пример #19
0
 private void OnActionChange(SteamVR_Action_In actionIn)
 {
     if (lightAction.GetStateDown(hand.handType))
     {
         lightAudio.Play();
         light.SetActive(!light.activeSelf);
         vibrator.Execute(0.0f, 0.03f, 200f, 0.1f, SteamVR_Input_Sources.LeftHand);
     }
 }
Пример #20
0
        //-------------------------------------------------
        public static void ShowTextHint(Hand hand, SteamVR_Action_In action, string text, bool highlightButton = true)
        {
            var hints = GetControllerButtonHints(hand);

            if (hints != null)
            {
                hints.ShowText(action, text, highlightButton);
            }
        }
Пример #21
0
 private void OnActionChange(SteamVR_Action_In actionIn)
 {
     if (shootAction.GetStateDown(hand.handType))
     {
         Debug.Log("calling shoot()...");
         GunTip.GetComponent <PlayerShooting>().Shoot();
         vibrator.Execute(0.0f, 0.1f, 100f, 0.99f, SteamVR_Input_Sources.RightHand);
     }
 }
Пример #22
0
 private void OnChange(SteamVR_Action_In source)
 {
     foreach (var hand in Hands)
     {
         if (source.GetChanged(hand.handType))
         {
             ToggleMenu(hand.transform);
         }
     }
 }
Пример #23
0
        //-------------------------------------------------
        public static string GetActiveHintText(Hand hand, SteamVR_Action_In action)
        {
            var hints = GetControllerButtonHints(hand);

            if (hints != null)
            {
                return(hints.GetActiveHintText(action));
            }

            return(string.Empty);
        }
Пример #24
0
        //-------------------------------------------------
        public static bool IsButtonHintActive(Hand hand, SteamVR_Action_In action)
        {
            var hints = GetControllerButtonHints(hand);

            if (hints != null)
            {
                return(hints.IsButtonHintActive(action));
            }

            return(false);
        }
Пример #25
0
        //-------------------------------------------------
        private void HideText(SteamVR_Action_In action)
        {
            if (actionHintInfos.ContainsKey(action))
            {
                var hintInfo = actionHintInfos[action];
                hintInfo.textHintObject.SetActive(false);
                hintInfo.textHintActive = false;

                HideButtonHint(action);
            }
        }
Пример #26
0
 private void OnShowActionChange(SteamVR_Action_In actionIn)
 {
     if (showUIAction.GetStateDown(inputSource))
     {
         Show();
     }
     else
     {
         Hide();
     }
 }
Пример #27
0
 private void OnSliderTouched(SteamVR_Action_In actionIn)
 {
     if (Environment.TickCount - sliderStarted <= Constants.SLIDER_NO_MANUAL_CANCEL_TIME)
     {
         return;
     }
     if (touchSliderAction.GetStateUp(inputSource))
     {
         Cancel();
     }
 }
Пример #28
0
 //-------------------------------------------------
 private string GetActiveHintText(SteamVR_Action_In action)
 {
     if (actionHintInfos.ContainsKey(action))
     {
         var hintInfo = actionHintInfos[action];
         if (hintInfo.textHintActive)
         {
             return(hintInfo.text.text);
         }
     }
     return(string.Empty);
 }
Пример #29
0
        private IEnumerator DoInitialize(SteamVR_RenderModel renderModel)
        {
            while (renderModel.initializedAttachPoints == false)
            {
                yield return(null);
            }

            textHintParent = new GameObject("Text Hints").transform;
            textHintParent.SetParent(this.transform);
            textHintParent.localPosition = Vector3.zero;
            textHintParent.localRotation = Quaternion.identity;
            textHintParent.localScale    = Vector3.one;

            //Get the button mask for each component of the render model

            var renderModels = OpenVR.RenderModels;

            if (renderModels != null)
            {
                string renderModelDebug = "Components for render model " + renderModel.index;
                for (int childIndex = 0; childIndex < renderModel.transform.childCount; childIndex++)
                {
                    Transform child = renderModel.transform.GetChild(childIndex);

                    componentTransformMap.Add(child.name, child);

                    renderModelDebug += "\n\t" + child.name + ".";
                }

                //Uncomment to show the button mask for each component of the render model
                HintDebugLog(renderModelDebug);
            }

            actionHintInfos = new Dictionary <SteamVR_Action_In, ActionHintInfo>();

            for (int actionIndex = 0; actionIndex < SteamVR_Input.actionsNonPoseNonSkeletonIn.Length; actionIndex++)
            {
                SteamVR_Action_In action = (SteamVR_Action_In)SteamVR_Input.actionsNonPoseNonSkeletonIn[actionIndex];

                if (action.GetActive(inputSource))
                {
                    CreateAndAddButtonInfo(action, inputSource);
                }
            }

            ComputeTextEndTransforms();

            initialized = true;

            //Set the controller hints render model to not active
            renderModel.SetMeshRendererState(true);
            renderModel.gameObject.SetActive(false);
        }
Пример #30
0
    private void OnTriggerActionChange(SteamVR_Action_In actionIn)
    {
        if (recordAction.GetStateDown(hand.handType))
        {
            Grip();
        }

        if (recordAction.GetStateUp(hand.handType))
        {
            LoseGrip();
        }
    }