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(); }
private void OnSliderClicked(SteamVR_Action_In actionIn) { if (clickedSliderAction.GetStateUp(inputSource)) { Hide(true); } }
void OnGrabGripChange(SteamVR_Action_In actionIn) { if (grabGripAction.GetStateDown(hand.handType)) { DropObj(); } }
// when the trigger is pressed, play a note void onPlay(SteamVR_Action_In actionIn) { if (showLine && PlayAction.GetStateDown(hand.handType)) { Play(); } }
void OnGrabActionChange(SteamVR_Action_In actionIn) { if (forwardAction.GetState(skeleton.inputSource)) { FindObjectOfType <DialogueTrigger>().TriggerDialogue(); } }
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(); } }
// when the touchpad is clicked, Pull/release the object void onPull(SteamVR_Action_In actionIn) { if (showLine && PullAction.GetStateDown(hand.handType)) { Pull(); } }
/// <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; } }
private void OnShootActionChange(SteamVR_Action_In actionIn) { if (shootAction.GetStateDown(hand.handType)) { this.GetComponent <SimpleGun>().SpawnShot(); } }
private void OnRotateActionChange(SteamVR_Action_In actionIn) { if (rotateAction.GetStateDown(hand.handType)) { Rotate(); } }
private void OnPlantActionChange(SteamVR_Action_In actionIn) { if (jumpAction.GetStateDown(hand.handType)) { Jump(); } }
protected virtual void OnSkeletonActiveChange(SteamVR_Action_In action, bool newState) { if (newState) { InitializeHand(); } }
//------------------------------------------------- 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); } }
void OnGrabPinchChange(SteamVR_Action_In actionIn) { if (grabPinchAction.GetStateDown(hand.handType)) { PickupObj(); } }
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; } } }
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); } }
//------------------------------------------------- public static void HideTextHint(Hand hand, SteamVR_Action_In action) { var hints = GetControllerButtonHints(hand); if (hints != null) { hints.HideText(action); } }
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); } }
//------------------------------------------------- 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); } }
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); } }
private void OnChange(SteamVR_Action_In source) { foreach (var hand in Hands) { if (source.GetChanged(hand.handType)) { ToggleMenu(hand.transform); } } }
//------------------------------------------------- public static string GetActiveHintText(Hand hand, SteamVR_Action_In action) { var hints = GetControllerButtonHints(hand); if (hints != null) { return(hints.GetActiveHintText(action)); } return(string.Empty); }
//------------------------------------------------- public static bool IsButtonHintActive(Hand hand, SteamVR_Action_In action) { var hints = GetControllerButtonHints(hand); if (hints != null) { return(hints.IsButtonHintActive(action)); } return(false); }
//------------------------------------------------- private void HideText(SteamVR_Action_In action) { if (actionHintInfos.ContainsKey(action)) { var hintInfo = actionHintInfos[action]; hintInfo.textHintObject.SetActive(false); hintInfo.textHintActive = false; HideButtonHint(action); } }
private void OnShowActionChange(SteamVR_Action_In actionIn) { if (showUIAction.GetStateDown(inputSource)) { Show(); } else { Hide(); } }
private void OnSliderTouched(SteamVR_Action_In actionIn) { if (Environment.TickCount - sliderStarted <= Constants.SLIDER_NO_MANUAL_CANCEL_TIME) { return; } if (touchSliderAction.GetStateUp(inputSource)) { Cancel(); } }
//------------------------------------------------- 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); }
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); }
private void OnTriggerActionChange(SteamVR_Action_In actionIn) { if (recordAction.GetStateDown(hand.handType)) { Grip(); } if (recordAction.GetStateUp(hand.handType)) { LoseGrip(); } }