private void Update() { GameObject rightHand = VRTK_DeviceFinder.GetControllerRightHand(true); controllerReference = VRTK_ControllerReference.GetControllerReference(rightHand); int currentSceneIndex = SceneManager.GetActiveScene().buildIndex; int nextSceneIndex = currentSceneIndex; if (IsForwardPressed() || Input.GetKeyUp(KeyCode.Space)) { nextSceneIndex++; if (nextSceneIndex >= SceneManager.sceneCountInBuildSettings) { nextSceneIndex = 0; } } else if (IsBackPressed() || Input.GetKeyUp(KeyCode.Backspace)) { nextSceneIndex--; if (nextSceneIndex < 0) { nextSceneIndex = SceneManager.sceneCountInBuildSettings - 1; } } if (nextSceneIndex == currentSceneIndex) { return; } SceneManager.LoadScene(nextSceneIndex); }
protected void PositionObject() { //1.Get motion controller positions(x, z); we can ignore y for now Transform leftController = VRTK_DeviceFinder.GetControllerLeftHand().transform; Transform rightController = VRTK_DeviceFinder.GetControllerRightHand().transform; if (leftController != null && rightController != null) { //2.Calculate center point(x, z) point Vector3 centerPos = leftController.transform.position + rightController.transform.position; centerPos /= 2; //UnityEngine.Debug.Log("Left" + leftController.transform.position); //UnityEngine.Debug.Log("Right" + rightController.transform.position); //UnityEngine.Debug.Log("Center" + centerPos); //3.Calculate(x, z) point X inches away from center point Vector2 rightPt = new Vector2(rightController.transform.position.x, rightController.transform.position.z); Vector2 centerPt = new Vector2(centerPos.x, centerPos.z); float angle = Vector2.SignedAngle(centerPt - rightPt, Vector2.right); //4.Update Theremin position to this point Vector3 pos = transform.parent.transform.localPosition; pos.x = centerPt.x; pos.z = centerPt.y; transform.parent.transform.localPosition = pos; Vector3 angles = transform.localEulerAngles; angles.y = 180 + angle; transform.parent.transform.localEulerAngles = angles; //Save State SavePositionState(); } }
public void DoObjectGrab(object sender, InteractableObjectEventArgs e) { Debug.Log(e.interactingObject); Debug.Log(VRTK_SDK_Bridge.IsControllerLeftHand(e.interactingObject)); if (VRTK_SDK_Bridge.IsControllerLeftHand(e.interactingObject)) { holdControl = VRTK_DeviceFinder.GetControllerLeftHand().GetComponent <VRTK_ControllerEvents>(); stringControl = VRTK_DeviceFinder.GetControllerRightHand().GetComponent <VRTK_ControllerEvents>(); holdActions = VRTK_DeviceFinder.GetControllerLeftHand().GetComponent <VRTK_ControllerActions>(); stringActions = VRTK_DeviceFinder.GetControllerRightHand().GetComponent <VRTK_ControllerActions>(); } else { Debug.Log("string control will be: "); Debug.Log(VRTK_DeviceFinder.GetControllerLeftHand().GetComponent <VRTK_ControllerEvents> ()); stringControl = VRTK_DeviceFinder.GetControllerLeftHand().GetComponent <VRTK_ControllerEvents>(); holdControl = VRTK_DeviceFinder.GetControllerRightHand().GetComponent <VRTK_ControllerEvents>(); stringActions = VRTK_DeviceFinder.GetControllerLeftHand().GetComponent <VRTK_ControllerActions>(); holdActions = VRTK_DeviceFinder.GetControllerRightHand().GetComponent <VRTK_ControllerActions>(); } StartCoroutine("GetBaseRotation"); }
// Use this for initialization void Start() { this.LeftController = VRTK_DeviceFinder.GetControllerLeftHand(); if (LeftController == null) { Debug.LogWarning("Error fetching left Controller from newBall"); } else { sliderHandler = LeftController.GetComponent <SliderHandler>(); if (sliderHandler == null) { Debug.LogWarning("Error fetching slider Handler from left controller"); } else { // } } this.RightController = VRTK_DeviceFinder.GetControllerRightHand(); if (RightController == null) { Debug.LogWarning("Error fetching right controller from NewBall"); } }
void UpdateData() { if (rightController == null) { // Check if actual rightController = VRTK_DeviceFinder.GetControllerRightHand(true); } if (leftController == null) { // Check if actual leftController = VRTK_DeviceFinder.GetControllerLeftHand(true); } if (rightController != null) { rightHandPosition = rightController.transform.localPosition; } if (leftController != null) { leftHandPosition = leftController.transform.localPosition; } timeStamp = Time.time; }
private IEnumerator FindDevices() { yield return(new WaitForEndOfFrame()); yield return(new WaitForEndOfFrame()); yield return(new WaitForEndOfFrame()); yield return(new WaitForEndOfFrame()); HeadsetFollower = VRTK_DeviceFinder.HeadsetTransform().gameObject; RightHand = VRTK_DeviceFinder.GetControllerRightHand().GetComponent <VRTK_ControllerEvents>(); LeftHand = VRTK_DeviceFinder.GetControllerLeftHand().GetComponent <VRTK_ControllerEvents>(); RightHand.GetComponent <VRTK_ControllerEvents>().TriggerPressed += TriggerPressed; LeftHand.GetComponent <VRTK_ControllerEvents>().TriggerPressed += TriggerPressed; RightHand.GetComponent <VRTK_ControllerEvents>().GripPressed += GripPressed; LeftHand.GetComponent <VRTK_ControllerEvents>().GripPressed += GripPressed; RightHand.GetComponent <VRTK_ControllerEvents>().TouchpadPressed += TouchpadPressed; LeftHand.GetComponent <VRTK_ControllerEvents>().TouchpadPressed += TouchpadPressed; RightHand.GetComponent <VRTK_ControllerEvents>().ButtonTwoPressed += ButtonTwoPressed; LeftHand.GetComponent <VRTK_ControllerEvents>().ButtonTwoPressed += ButtonTwoPressed; RightHand.GetComponent <VRTK_ControllerEvents>().StartMenuPressed += StartMenuPressed; LeftHand.GetComponent <VRTK_ControllerEvents>().StartMenuPressed += StartMenuPressed; }
private void Update() { if (!EnableSceneChanger) { return; } var rightHand = VRTK_DeviceFinder.GetControllerRightHand(true); controllerIndex = VRTK_DeviceFinder.GetControllerIndex(rightHand); if (ForwardPressed() || Input.GetKeyUp(KeyCode.Space)) { var nextSceneIndex = SceneManager.GetActiveScene().buildIndex + 1; if (nextSceneIndex >= SceneManager.sceneCountInBuildSettings) { nextSceneIndex = 0; } SceneManager.LoadScene(nextSceneIndex); } if (BackPressed() || Input.GetKeyUp(KeyCode.Backspace)) { var previousSceneIndex = SceneManager.GetActiveScene().buildIndex - 1; if (previousSceneIndex < 0) { previousSceneIndex = SceneManager.sceneCountInBuildSettings - 1; } SceneManager.LoadScene(previousSceneIndex); } }
public void Awake() { touchpadAxisChanged = new ControllerInteractionEventHandler(DoTouchpadAxisChanged); touchpadUntouched = new ControllerInteractionEventHandler(DoTouchpadTouchEnd); controllerRightHand = VRTK_DeviceFinder.GetControllerRightHand(); }
private void Update() { GameObject rightHand = VRTK_DeviceFinder.GetControllerRightHand(true); controllerReference = VRTK_ControllerReference.GetControllerReference(rightHand); if (ForwardPressed() || Input.GetKeyUp(KeyCode.Space)) { int nextSceneIndex = SceneManager.GetActiveScene().buildIndex + 1; if (nextSceneIndex >= SceneManager.sceneCountInBuildSettings) { nextSceneIndex = 0; } VRTK_SDKManager.instance.UnloadSDKSetup(); SceneManager.LoadScene(nextSceneIndex); } if (BackPressed() || Input.GetKeyUp(KeyCode.Backspace)) { int previousSceneIndex = SceneManager.GetActiveScene().buildIndex - 1; if (previousSceneIndex < 0) { previousSceneIndex = SceneManager.sceneCountInBuildSettings - 1; } VRTK_SDKManager.instance.UnloadSDKSetup(); SceneManager.LoadScene(previousSceneIndex); } }
protected virtual void OnEnable() { controllerThrustHistory = new Queue <Vector3>(); controllerMovementHistory = new Queue <Vector3>(); controllerDirectionHistory = new Queue <Vector3>(); previousEngageButton = engageButton; VRTK_leftController = VRTK_DeviceFinder.GetControllerLeftHand(); VRTK_rightController = VRTK_DeviceFinder.GetControllerRightHand(); actualLeftController = VRTK_DeviceFinder.GetControllerLeftHand(getActual: true); actualRightController = VRTK_DeviceFinder.GetControllerRightHand(getActual: true); if (!actualLeftController) { Debug.LogError("No left controller found. Make sure you attach the Controller GameObject to the Flight Handler."); } if (!actualRightController) { Debug.LogError("No right controller found. Make sure you attach the Controller GameObject to the Flight Handler."); } playAreaTransform = VRTK_DeviceFinder.PlayAreaTransform(); playerRigidbody = playAreaTransform.GetComponent <Rigidbody>(); SetControllerListeners(VRTK_leftController, leftController, ref leftSubscribed); SetControllerListeners(VRTK_rightController, rightController, ref rightSubscribed); }
static void Postfix(ref float ___currentZoomVelocity, float ___zoomInTime, float ___zoomOutTime, float ___normalFOV, float ___zoomedFOV) { try { if (thisModEntry.Active && VRManager.IsVREnabled()) { VRTK_ControllerEvents secondaryEvents = VRTK_DeviceFinder.GetControllerRightHand(false).GetComponent <VRTK_ControllerEvents>(); Vector2 axis = secondaryEvents.GetAxis( VRTK_DeviceFinder.GetHeadsetType() == SDK_BaseHeadset.HeadsetType.WindowsMixedReality ? VRTK_ControllerEvents.Vector2AxisAlias.TouchpadTwo : VRTK_ControllerEvents.Vector2AxisAlias.Touchpad ); float zoomedFactor = ___normalFOV / ___zoomedFOV; if (axis.y < 0.625f && XRDevice.fovZoomFactor > 1f) { XRDevice.fovZoomFactor = Mathf.SmoothDamp(XRDevice.fovZoomFactor, 1.0f, ref ___currentZoomVelocity, ___zoomOutTime); } if (axis.y > 0.625f && XRDevice.fovZoomFactor < zoomedFactor) { XRDevice.fovZoomFactor = Mathf.SmoothDamp(XRDevice.fovZoomFactor, zoomedFactor, ref ___currentZoomVelocity, ___zoomInTime); } } } catch (Exception e) { Debug.LogError(string.Format("Exception thrown during CameraZoom.ZoomMechanic postfix patch:\n{0}", e.Message)); OnCriticalFailure(); } }
protected override void Start() { base.Start(); _leftController = VRTK_DeviceFinder.GetControllerLeftHand(); _rightController = VRTK_DeviceFinder.GetControllerRightHand(); }
//Our coroutine takes the upload url private IEnumerator UploadAFile(string uploadUrl, string filename, Byte[] data) { // Create a Web Form, this will be our POST method's data var form = new WWWForm(); form.AddBinaryData("file", data, filename, "audio/wav"); VRTK_DeviceFinder.GetControllerRightHand().GetComponentInChildren <VRTK_ControllerTooltips>().UpdateText(VRTK_ControllerTooltips.TooltipButtons.ButtonTwoTooltip, "Uploading…"); WWW w = new WWW(uploadUrl, form); while (!w.isDone) { yield return(w); } if (w.error != null) { Debug.Log(w.error); } else { Debug.Log(w.text); } VRTK_DeviceFinder.GetControllerRightHand().GetComponentInChildren <VRTK_ControllerTooltips>().ToggleTips(false, VRTK_ControllerTooltips.TooltipButtons.ButtonTwoTooltip); }
void OnTriggerEnter(Collider other) { if (other.tag == "RController" || other.tag == "LController") { Transform player; if (other.tag == "RController") { player = VRTK_DeviceFinder.GetControllerRightHand().transform; } else { player = VRTK_DeviceFinder.GetControllerLeftHand().transform; } Vector3 portalToPlayer = player.position - transform.position; float dotProduct = Vector3.Dot(transform.up, portalToPlayer); Debug.Log(dotProduct); if (dotProduct > 0.1f) { if (receiver.name == "ColliderPlane_A") { GameController.Instance.ForceTeleportScript.ForceTeleportToTeleportA(); } else { GameController.Instance.ForceTeleportScript.ForceTeleportToTeleportB(); } RenderSettings.skybox = CameraSkybox.material; } } }
private IEnumerator Start() { yield return(null); ; GameObject leftHand = null; while (leftHand == null) { leftHand = VRTK_DeviceFinder.GetControllerLeftHand(true); yield return(null); } GameObject rightHand = null; while (rightHand == null) { rightHand = VRTK_DeviceFinder.GetControllerRightHand(true); yield return(null); } yield return(TurnOffShadows(leftHand)); yield return(TurnOffShadows(rightHand)); }
// Token: 0x06001E97 RID: 7831 RVA: 0x0009B87C File Offset: 0x00099A7C private void Update() { GameObject controllerRightHand = VRTK_DeviceFinder.GetControllerRightHand(true); this.controllerReference = VRTK_ControllerReference.GetControllerReference(controllerRightHand); int buildIndex = SceneManager.GetActiveScene().buildIndex; int num = buildIndex; if (this.IsForwardPressed() || Input.GetKeyUp(KeyCode.Space)) { num++; if (num >= SceneManager.sceneCountInBuildSettings) { num = 0; } } else if (this.IsBackPressed() || Input.GetKeyUp(KeyCode.Backspace)) { num--; if (num < 0) { num = SceneManager.sceneCountInBuildSettings - 1; } } if (num == buildIndex) { return; } SceneManager.LoadScene(num); }
private void Awake() { _labObjectModule = ModuleManager.Instance.Get <LabObjectsModule>(); _leftGrab = VRTK_DeviceFinder.GetControllerLeftHand().GetComponent <VRTK_InteractGrab>(); _rightGrab = VRTK_DeviceFinder.GetControllerRightHand().GetComponent <VRTK_InteractGrab>(); //_jsonLabObj = _labObjectModule.GetJsonLabObj(ID); }
protected virtual void Update() { GameObject rightHand = VRTK_DeviceFinder.GetControllerRightHand(true); controllerReference = VRTK_ControllerReference.GetControllerReference(rightHand); int currentSceneIndex = SceneManager.GetActiveScene().buildIndex; int nextSceneIndex = currentSceneIndex; if (ForwardPressed()) { nextSceneIndex++; if (nextSceneIndex >= lastSceneIndex) { nextSceneIndex = firstSceneIndex; } } else if (BackPressed()) { nextSceneIndex--; if (nextSceneIndex < firstSceneIndex) { nextSceneIndex = lastSceneIndex - 1; } } if (nextSceneIndex != currentSceneIndex) { SceneManager.LoadScene(nextSceneIndex); } }
private IEnumerator RecordingCounter() { float start = Time.time; double timer = 45; string counter = "-00:"; timerUp = false; VRTK_DeviceFinder.GetControllerRightHand().GetComponentInChildren <VRTK_ControllerTooltips>().ToggleTips(true, VRTK_ControllerTooltips.TooltipButtons.ButtonTwoTooltip); while (Microphone.IsRecording(null) && timer > 0) { timer = Math.Round(45 - (Time.time - start)); if (timer < 10) { counter = "-00:0" + timer.ToString(); } else { counter = "-00:" + timer.ToString(); } VRTK_DeviceFinder.GetControllerRightHand().GetComponentInChildren <VRTK_ControllerTooltips>().UpdateText(VRTK_ControllerTooltips.TooltipButtons.ButtonTwoTooltip, counter); yield return(null); } if (timer <= 0) { timerUp = true; } }
protected override void OnEnable() { player = VRTK_DeviceFinder.PlayAreaTransform(); head = VRTK_DeviceFinder.HeadsetTransform(); leftHand = VRTK_DeviceFinder.GetControllerLeftHand().transform; rightHand = VRTK_DeviceFinder.GetControllerRightHand().transform; base.OnEnable(); }
protected virtual void EnableBodyPhysics() { currentBodyCollisionsSetting = enableBodyCollisions; CreateCollider(); InitControllerListeners(VRTK_DeviceFinder.GetControllerLeftHand(), true); InitControllerListeners(VRTK_DeviceFinder.GetControllerRightHand(), true); }
protected virtual void ToggleScriptAlias() { GameObject scriptLeft = VRTK_DeviceFinder.GetControllerLeftHand(false); GameObject scriptRight = VRTK_DeviceFinder.GetControllerRightHand(false); CycleScriptAlias(scriptLeft, leftHandAvatar); CycleScriptAlias(scriptRight, rightHandAvatar); }
void Move() { Vector3 jointPos = gameObject.GetComponent <MoleculesAction>().GetJointPosition(); Vector3 RightControllerPos = VRTK_DeviceFinder.GetControllerRightHand().transform.position; Vector3 moveDir = (jointPos - RightControllerPos).normalized; transform.Translate(moveDir * touchAxis.y * moveSpeed * Time.deltaTime, Space.World); }
void Start() { audioManager = GameObject.FindWithTag("AudioCenter").GetComponent <AudioManager>(); VRTK_leftController = VRTK_DeviceFinder.GetControllerLeftHand(); VRTK_rightController = VRTK_DeviceFinder.GetControllerRightHand(); actualLeftController = VRTK_DeviceFinder.GetControllerLeftHand(getActual: true); actualRightController = VRTK_DeviceFinder.GetControllerRightHand(getActual: true); }
// Update is called once per frame private void Update() { if (playerId != "") { // Start downloading audio when we have an active controller to do recordings, etc. if (gameObject.activeSelf && !requestingAudio && !requestedAllAudio) { RequestAllAudio(); } if (menuReleased && // pressed the button !Microphone.IsRecording(null) && // not recording canRecord // fits criteria to be recording ) { menuReleased = false; StartCoroutine(ChangeVolume(0.2f)); recordButton.GetComponent <AudioSource>().clip = (AudioClip)Resources.Load("startrecord"); recordButton.GetComponent <AudioSource>().Play(); Debug.Log("Started Recording for: " + recordObject.name); recordsource.clip = Microphone.Start(null, true, 45, 44100); StartCoroutine(RecordingCounter()); } else if (timerUp || // was recording and timer ran out (Microphone.IsRecording(null) && menuReleased) // currently recording and press menu to stop ) { menuReleased = false; timerUp = false; StartCoroutine(ChangeVolume(defaultQuoteVolume)); Debug.Log("Stopped Recording " + recordsource.clip.samples); VRTK_DeviceFinder.GetControllerRightHand().GetComponentInChildren <VRTK_ControllerTooltips>().UpdateText(VRTK_ControllerTooltips.TooltipButtons.ButtonTwoTooltip, "Saving…"); if (recordsource.clip.samples > 0) { recordObject.GetComponentInChildren <Quote>().recorded = true; ToggleRecordButton(false); Save("tiaf", recordsource.clip); } Microphone.End(null); } CheckQuoteDistance(); if (!playingAudio && requestedAllAudio) { StartCoroutine(PlayAudio()); } } else if (!initializingGS) { InitGS(); } }
IEnumerator DelayedStart() { yield return(null); playArea = VRTK_DeviceFinder.PlayAreaTransform(); InitControllerListeners(VRTK_DeviceFinder.GetControllerLeftHand(), true); InitControllerListeners(VRTK_DeviceFinder.GetControllerRightHand(), true); }
public void ForceTeleportTo(Transform destination, Quaternion?rotation = null) { float distance = Vector3.Distance(transform.position, destination.position); VRTK_ControllerReference controllerReference = VRTK_ControllerReference.GetControllerReference(VRTK_DeviceFinder.GetControllerRightHand()); OnDestinationMarkerSet(SetDestinationMarkerEvent(distance, destination, new RaycastHit(), destination.position, controllerReference, false, rotation)); }
protected override void Start() { base.Start(); rb = controlObject.GetComponent <Rigidbody>(); rb.maxAngularVelocity = 7f; leftCtrlEvents = VRTK_DeviceFinder.GetControllerLeftHand().GetComponent <VRTK_ControllerEvents>(); rightCtrlEvents = VRTK_DeviceFinder.GetControllerRightHand().GetComponent <VRTK_ControllerEvents>(); }
public void Start() { GameObject leftController = VRTK_DeviceFinder.GetControllerLeftHand(); leftController.GetComponent <VRTK_ControllerEvents>().ControllerEnabled += controllerEnabledHandler; GameObject rightController = VRTK_DeviceFinder.GetControllerRightHand(); rightController.GetComponent <VRTK_ControllerEvents>().ControllerDisabled += controllerDisabledHandler; }
private IEnumerator FindDevices() { yield return(new WaitForEndOfFrame()); yield return(new WaitForEndOfFrame()); UIPointerR = VRTK_DeviceFinder.GetControllerRightHand().GetComponent <VRTK_UIPointer>(); UIPointerL = VRTK_DeviceFinder.GetControllerLeftHand().GetComponent <VRTK_UIPointer>(); HeadsetTranform = VRTK_DeviceFinder.HeadsetTransform(); }