void Update() { for (int i = 0; i < lines.Count; i++) { if (Time.time > lines[i].stopTime) { Destroy(lines[i].material); lines.RemoveAt(i); continue; } Graphics.DrawMesh(mesh, lines[i].matrix, lines[i].material, 0); } //if(VRInput.GetDevice("ViveLeft").GetButtonDown("Grip")) VRDebug.ToggleConsole(); if (VRInput.HasDevice("ViveLeft")) { if (VRInput.GetDevice("ViveLeft").GetButtonDown("Grip") && VRInput.GetDevice("ViveLeft").GetButton("Menu")) { VRDebug.ToggleConsole(false); } else if (VRInput.GetDevice("ViveLeft").GetButtonDown("Menu") && VRInput.GetDevice("ViveLeft").GetButton("Grip")) { VRDebug.ToggleConsole(true); } } }
// Update is called once per frame void Update() { VRInputDevice tempDevice = VRInput.GetDevice("Xbox"); // Find a PlayerIndex, for a single player game // Will find the first controller that is connected ans use it if (!playerIndexSet || !prevState.IsConnected) { for (int i = 0; i < 4; ++i) { PlayerIndex testPlayerIndex = (PlayerIndex)i; GamePadState testState = GamePad.GetState(testPlayerIndex); if (testState.IsConnected) { Debug.Log(string.Format("GamePad found {0}", testPlayerIndex)); playerIndex = testPlayerIndex; playerIndexSet = true; } } } prevState = state; state = GamePad.GetState(playerIndex); tempDevice.SetAxis("LeftStickX", state.ThumbSticks.Left.X); tempDevice.SetAxis("LeftStickY", state.ThumbSticks.Left.Y); tempDevice.SetAxis("RightStickX", state.ThumbSticks.Right.X); tempDevice.SetAxis("RightStickY", state.ThumbSticks.Right.Y); tempDevice.SetAxis("LeftTrigger", state.Triggers.Left); tempDevice.SetAxis("RightTrigger", state.Triggers.Right); tempDevice.SetAxis("DPadX", state.DPad.Left.Equals(XInputDotNetPure.ButtonState.Pressed) ? -1f : state.DPad.Right.Equals(XInputDotNetPure.ButtonState.Pressed) ? 1f : 0f); tempDevice.SetAxis("DPadY", state.DPad.Down.Equals(XInputDotNetPure.ButtonState.Pressed) ? -1f : state.DPad.Up.Equals(XInputDotNetPure.ButtonState.Pressed) ? 1f : 0f); tempDevice.SetAxis("Triggers", state.Triggers.Right - state.Triggers.Left); tempDevice.SetButton("A", getButtonInt(prevState.Buttons.A, state.Buttons.A)); tempDevice.SetButton("B", getButtonInt(prevState.Buttons.B, state.Buttons.B)); tempDevice.SetButton("X", getButtonInt(prevState.Buttons.X, state.Buttons.X)); tempDevice.SetButton("Y", getButtonInt(prevState.Buttons.Y, state.Buttons.Y)); tempDevice.SetButton("DPadUp", getButtonInt(prevState.DPad.Up, state.DPad.Up)); tempDevice.SetButton("DPadDown", getButtonInt(prevState.DPad.Down, state.DPad.Down)); tempDevice.SetButton("DPadLeft", getButtonInt(prevState.DPad.Left, state.DPad.Left)); tempDevice.SetButton("DPadRight", getButtonInt(prevState.DPad.Right, state.DPad.Right)); tempDevice.SetButton("LeftShoulder", getButtonInt(prevState.Buttons.LeftShoulder, state.Buttons.LeftShoulder)); tempDevice.SetButton("RightShoulder", getButtonInt(prevState.Buttons.RightShoulder, state.Buttons.RightShoulder)); tempDevice.SetButton("LeftTrigger", getTriggerButtonInt(prevState.Triggers.Left, state.Triggers.Left)); tempDevice.SetButton("RightTrigger", getTriggerButtonInt(prevState.Triggers.Right, state.Triggers.Right)); tempDevice.SetButton("LeftStick", getButtonInt(prevState.Buttons.LeftStick, state.Buttons.LeftStick)); tempDevice.SetButton("RightStick", getButtonInt(prevState.Buttons.RightStick, state.Buttons.RightStick)); tempDevice.SetButton("Back", getButtonInt(prevState.Buttons.Back, state.Buttons.Back)); tempDevice.SetButton("Start", getButtonInt(prevState.Buttons.Start, state.Buttons.Start)); tempDevice.Vibrate(); }
void Update() { if (!VRInput.GetDevice("ViveRight").isTracked) { return; } RaycastHit tempHit; if (background.Raycast(new Ray(VRInput.GetDevice("ViveRight").position, VRInput.GetDevice("ViveRight").forward), out tempHit, Mathf.Infinity)) { VRDebug.DrawLine(VRInput.GetDevice("ViveRight").position, tempHit.point, Color.black, true, 0.0015f); } }
void Update() { if (VRInput.GetButtonDown(GrabButton, Hand) && currentObject == null) { Grab(); } if (VRInput.GetButtonUp(GrabButton, Hand) && currentObject != null) { Release(); } if (VRInput.GetButtonDown(UseButton, Hand) && currentObject != null) { Use(); } }
private void updateDevice() { if (trackingMode != TrackingMode.Rotation) { Vector3 position = VRInput.GetPosition(device); if (local && transform.parent != null) { position = transform.parent.TransformPoint(position); } if (rb) { rb.position = position; } else { transform.position = position; } } if (trackingMode != TrackingMode.Position) { Quaternion rotation = VRInput.GetRotation(device); if (local && transform.parent != null) { rotation = transform.parent.rotation * rotation; } if (rb) { rb.rotation = rotation; } else { transform.rotation = rotation; } } }
public ConsoleCollider GetCollider(out RaycastHit hit) { hit = new RaycastHit(); if (!VRInput.GetDevice("ViveRight").isTracked) { return(ConsoleCollider.None); } bool found = false; int foundIndex = -1; for (int i = 0; i < colliders.Length; i++) { if (colliders[i].Raycast(new Ray(VRInput.GetDevice("ViveRight").position, VRInput.GetDevice("ViveRight").forward), out hit, Mathf.Infinity)) { found = true; foundIndex = i; break; } } if (found) { return(colliderValues[foundIndex]); } else { if (background.Raycast(new Ray(VRInput.GetDevice("ViveRight").position, VRInput.GetDevice("ViveRight").forward), out hit, Mathf.Infinity)) { return(ConsoleCollider.Background); } else { return(ConsoleCollider.None); } } }
void Awake() { #if UNITY_5_3 || UNITY_5_2 || UNITY_5_1 || UNITY_5_0 || UNITY_4 if (hmd == null) { if (transform.FindChild("Camera (head)") != null) { hmd = transform.FindChild("Camera (head)").GetComponent <SteamVR_TrackedObject>(); } if (hmd == null) { hmd = GameObject.Find("Camera (head)").GetComponent <SteamVR_TrackedObject>(); if (hmd == null) { Debug.LogError("Error - couldn't find gameobject with name 'Camera (head)' for the HMD on ViveInput!"); } } } #else //we don't need to reference the vive tracked object here because we have it from the native unity implementation if (hmd == null) { if (transform.Find("Camera (eye)") != null) { hmd = transform.Find("Camera (eye)"); } if (hmd == null) { hmd = GameObject.Find("Camera (eye)").transform; if (hmd == null) { Debug.LogError("Error - couldn't find gameobject with name 'Camera (eye)' for the HMD on ViveInput!"); } } } #endif if (Left == null) { if (transform.Find("Controller (left)") != null) { Left = transform.Find("Controller (left)").GetComponent <SteamVR_TrackedObject>(); } if (Left == null) { Left = GameObject.Find("Controller (left)").GetComponent <SteamVR_TrackedObject>(); if (Left == null) { Debug.LogError("Error - couldn't find gameobject with name 'Controller (left)' for the Left Controller on ViveInput!"); } } } if (Right == null) { if (transform.Find("Controller (right)") != null) { Right = transform.Find("Controller (right)").GetComponent <SteamVR_TrackedObject>(); } if (Right == null) { Right = GameObject.Find("Controller (right)").GetComponent <SteamVR_TrackedObject>(); if (Right == null) { Debug.LogError("Error - couldn't find gameobject with name 'Controller (right)' for the Right Controller on ViveInput!"); } } } if (hmd == null || Left == null || Right == null) { Debug.LogError("One or more Vive devices couldn't be found - ViveInput will not function. :("); } //ViveInput.Left = new ControllerState(); //ViveInput.Right = new ControllerState(); //ViveInput.HMD = new ControllerState(); VRInput.AddVive(); //StartCoroutine(GetChaperoneData()); //StartCoroutine(GetChaperoneData()); }
void Update() { //if we don't have one of these, something is wrong, and we shouldn't do anything if (hmd == null || Left == null || Right == null) { return; } //If we have the left controller if (Left.isValid) { deviceLeft = SteamVR_Controller.Input((int)Left.index); VRInputDevice tempDevice = VRInput.GetDevice("ViveLeft"); tempDevice.isTracked = true; tempDevice.SetInt("Index", (int)Left.index); tempDevice.transform = Left.transform; tempDevice.position = Left.transform.position; tempDevice.forward = Left.transform.forward; tempDevice.up = Left.transform.up; tempDevice.right = Left.transform.right; tempDevice.velocity = deviceLeft.velocity; tempDevice.rotation = Left.transform.rotation; tempDevice.angularVelocity = deviceLeft.angularVelocity; tempDevice.SetButton("Trigger", GetButtonInt(deviceLeft, EVRButtonId.k_EButton_SteamVR_Trigger)); tempDevice.SetButton("Menu", GetButtonInt(deviceLeft, EVRButtonId.k_EButton_ApplicationMenu)); tempDevice.SetButton("Touchpad", GetButtonInt(deviceLeft, EVRButtonId.k_EButton_SteamVR_Touchpad)); tempDevice.SetButton("Grip", GetButtonInt(deviceLeft, EVRButtonId.k_EButton_Grip)); tempDevice.SetTouchButton("Touchpad", GetTouchButtonInt(deviceLeft, EVRButtonId.k_EButton_SteamVR_Touchpad)); Vector2 touchpadVector = deviceLeft.GetAxis(EVRButtonId.k_EButton_SteamVR_Touchpad); tempDevice.SetAxis("TouchpadX", touchpadVector.x); tempDevice.SetAxis("TouchpadY", touchpadVector.y); tempDevice.SetAxis("TouchpadR", Mathf.Sqrt(touchpadVector.x * touchpadVector.x + touchpadVector.y * touchpadVector.y)); tempDevice.SetAxis("TouchpadT", Mathf.Atan2(touchpadVector.y, touchpadVector.x) * Mathf.Rad2Deg); tempDevice.SetAxis("Trigger", deviceLeft.GetAxis(EVRButtonId.k_EButton_SteamVR_Trigger).x); tempDevice.Vibrate(); /* * ViveInput.Left.IsTracked = true; * ViveInput.Left.Index = (int)Left.index; * ViveInput.Left.Transform = Left.transform; * * ViveInput.Left.Position = Left.transform.position;//deviceLeft.transform.pos; * ViveInput.Left.Forward = Left.transform.forward; * ViveInput.Left.Up = Left.transform.up; * ViveInput.Left.Right = Left.transform.right; * ViveInput.Left.Velocity = deviceLeft.velocity; * ViveInput.Left.Rotation = Left.transform.rotation;//deviceLeft.transform.rot; * ViveInput.Left.AngularVelocity = deviceLeft.angularVelocity; * * * ViveInput.Left.Buttons.Trigger = getButtonState(deviceLeft, EVRButtonId.k_EButton_SteamVR_Trigger); * ViveInput.Left.TriggerAxis = deviceLeft.GetAxis(EVRButtonId.k_EButton_SteamVR_Trigger); * ViveInput.Left.Buttons.Grip = getButtonState(deviceLeft, EVRButtonId.k_EButton_Grip); * ViveInput.Left.Buttons.TouchpadButton = getButtonState (deviceLeft, EVRButtonId.k_EButton_SteamVR_Touchpad); * ViveInput.Left.Buttons.Menu = getButtonState (deviceLeft, EVRButtonId.k_EButton_ApplicationMenu); * * ViveInput.Left.TouchpadAxis = deviceLeft.GetAxis (EVRButtonId.k_EButton_SteamVR_Touchpad); * if(ViveInput.Left.Buttons.TouchpadButton.Equals(ButtonState.Touched) || ViveInput.Left.Buttons.TouchpadButton.Equals(ButtonState.Pressed)) { * ViveInput.Left.TouchpadDeltaX = (ViveInput.Left.TouchpadAxis.x - lastLeftTouchpad.x) * Time.deltaTime; * ViveInput.Left.TouchpadDeltaY = (ViveInput.Left.TouchpadAxis.y - lastLeftTouchpad.y) * Time.deltaTime; * ViveInput.Left.TouchpadDeltaR = ((ViveInput.Left.TouchpadAxis).magnitude - (lastLeftTouchpad).magnitude) * Time.deltaTime; * ViveInput.Left.TouchpadDeltaT = getDeltaAngle(ViveInput.Left.TouchpadAxis, lastLeftTouchpad) * Time.deltaTime; * } else { * ViveInput.Left.TouchpadDeltaX = ViveInput.Left.TouchpadDeltaY = ViveInput.Left.TouchpadDeltaR = ViveInput.Left.TouchpadDeltaT = 0f; * } * ViveInput.Left.TouchpadDir = getTouchpadDir(ViveInput.Left.TouchpadAxis, ViveInput.Left.Buttons.TouchpadButton); * * lastLeftTouchpad = ViveInput.Left.TouchpadAxis; */ } else { VRInput.GetDevice("ViveLeft").isTracked = false; deviceLeft = null; //deviceLeft = null; //ViveInput.Left.IsTracked = false; } //If we have the right controller if (Right.isValid) { deviceRight = SteamVR_Controller.Input((int)Right.index); VRInputDevice tempDevice = VRInput.GetDevice("ViveRight"); tempDevice.isTracked = true; tempDevice.SetInt("Index", (int)Right.index); tempDevice.transform = Right.transform; tempDevice.position = Right.transform.position; tempDevice.forward = Right.transform.forward; tempDevice.up = Right.transform.up; tempDevice.right = Right.transform.right; tempDevice.velocity = deviceRight.velocity; tempDevice.rotation = Right.transform.rotation; tempDevice.angularVelocity = deviceRight.angularVelocity; tempDevice.SetButton("Trigger", GetButtonInt(deviceRight, EVRButtonId.k_EButton_SteamVR_Trigger)); tempDevice.SetButton("Menu", GetButtonInt(deviceRight, EVRButtonId.k_EButton_ApplicationMenu)); tempDevice.SetButton("Touchpad", GetButtonInt(deviceRight, EVRButtonId.k_EButton_SteamVR_Touchpad)); tempDevice.SetButton("Grip", GetButtonInt(deviceRight, EVRButtonId.k_EButton_Grip)); tempDevice.SetTouchButton("Touchpad", GetTouchButtonInt(deviceRight, EVRButtonId.k_EButton_SteamVR_Touchpad)); Vector2 touchpadVector = deviceRight.GetAxis(EVRButtonId.k_EButton_SteamVR_Touchpad); tempDevice.SetAxis("TouchpadX", touchpadVector.x); tempDevice.SetAxis("TouchpadY", touchpadVector.y); tempDevice.SetAxis("TouchpadR", Mathf.Sqrt(touchpadVector.x * touchpadVector.x + touchpadVector.y * touchpadVector.y)); tempDevice.SetAxis("TouchpadT", Mathf.Atan2(touchpadVector.y, touchpadVector.x) * Mathf.Rad2Deg); tempDevice.SetAxis("Trigger", deviceRight.GetAxis(EVRButtonId.k_EButton_SteamVR_Trigger).x); tempDevice.Vibrate(); /* * ViveInput.Right.IsTracked = true; * ViveInput.Right.Index = (int)Right.index; * ViveInput.Right.Transform = Right.transform; * * ViveInput.Right.Position = Right.transform.position;//deviceRight.transform.pos; * ViveInput.Right.Forward = Right.transform.forward; * ViveInput.Right.Up = Right.transform.up; * ViveInput.Right.Right = Right.transform.right; * ViveInput.Right.Velocity = deviceRight.velocity; * ViveInput.Right.Rotation = Right.transform.rotation;//deviceRight.transform.rot; * ViveInput.Right.AngularVelocity = deviceRight.angularVelocity; * * ViveInput.Right.Buttons.Trigger = getButtonState(deviceRight, EVRButtonId.k_EButton_SteamVR_Trigger); * ViveInput.Right.TriggerAxis = deviceRight.GetAxis(EVRButtonId.k_EButton_SteamVR_Trigger); * ViveInput.Right.Buttons.Grip = getButtonState(deviceRight, EVRButtonId.k_EButton_Grip); * ViveInput.Right.Buttons.TouchpadButton = getButtonState (deviceRight, EVRButtonId.k_EButton_SteamVR_Touchpad); * ViveInput.Right.Buttons.Menu = getButtonState (deviceRight, EVRButtonId.k_EButton_ApplicationMenu); * * ViveInput.Right.TouchpadAxis = deviceRight.GetAxis (EVRButtonId.k_EButton_SteamVR_Touchpad); * if(ViveInput.Right.Buttons.TouchpadButton.Equals(ButtonState.Touched) || ViveInput.Right.Buttons.TouchpadButton.Equals(ButtonState.Pressed)) { * ViveInput.Right.TouchpadDeltaX = (ViveInput.Right.TouchpadAxis.x - lastRightTouchpad.x) * Time.deltaTime; * ViveInput.Right.TouchpadDeltaY = (ViveInput.Right.TouchpadAxis.y - lastRightTouchpad.y) * Time.deltaTime; * ViveInput.Right.TouchpadDeltaR = ((ViveInput.Right.TouchpadAxis).magnitude - (lastRightTouchpad).magnitude) * Time.deltaTime; * ViveInput.Right.TouchpadDeltaT = getDeltaAngle(ViveInput.Right.TouchpadAxis, lastRightTouchpad) * Time.deltaTime; * } else { * ViveInput.Right.TouchpadDeltaX = ViveInput.Right.TouchpadDeltaY = ViveInput.Right.TouchpadDeltaR = ViveInput.Right.TouchpadDeltaT = 0f; * } * ViveInput.Right.TouchpadDir = getTouchpadDir(ViveInput.Right.TouchpadAxis, ViveInput.Right.Buttons.TouchpadButton); * * lastRightTouchpad = ViveInput.Right.TouchpadAxis; */ } else { VRInput.GetDevice("ViveRight").isTracked = false; deviceRight = null; //ViveInput.Right.IsTracked = false; } #if UNITY_5_3 || UNITY_5_2 || UNITY_5_1 || UNITY_5_0 || UNITY_4 //If we have the HMD if (hmd.isValid) { deviceHMD = SteamVR_Controller.Input((int)hmd.index); VRInputDevice tempDevice = VRInput.GetDevice("ViveHMD"); tempDevice.isTracked = true; tempDevice.SetInt("Index", (int)hmd.index); tempDevice.transform = hmd.transform; tempDevice.position = hmd.transform.position; tempDevice.forward = hmd.transform.forward; tempDevice.up = hmd.transform.up; tempDevice.right = hmd.transform.right; tempDevice.velocity = deviceHMD.velocity; tempDevice.rotation = hmd.transform.rotation; tempDevice.angularVelocity = deviceHMD.angularVelocity; /* * ViveInput.HMD.IsTracked = true; * ViveInput.HMD.Index = (int)hmd.index; * ViveInput.HMD.Transform = hmd.transform; * * ViveInput.HMD.Position = hmd.transform.position; * ViveInput.HMD.Forward = hmd.transform.forward; * ViveInput.HMD.Up = hmd.transform.up; * ViveInput.HMD.Right = hmd.transform.right; * ViveInput.HMD.Velocity = deviceHMD.velocity; * ViveInput.HMD.Rotation = deviceHMD.transform.rot; * ViveInput.HMD.AngularVelocity = deviceHMD.angularVelocity; * * ViveInput.HMD.Buttons.Trigger = ButtonState.Inactive; * ViveInput.HMD.Buttons.Grip = ButtonState.Inactive; * ViveInput.HMD.Buttons.TouchpadButton = ButtonState.Inactive; * ViveInput.HMD.Buttons.Menu = ButtonState.Inactive; * * ViveInput.HMD.TouchpadAxis = Vector3.zero; */ } else { VRInput.GetDevice("ViveHMD").isTracked = false; deviceHMD = null; //ViveInput.HMD.IsTracked = false; } #else if (VRDevice.isPresent) { VRInputDevice tempDevice = VRInput.GetDevice("ViveHMD"); tempDevice.isTracked = true; tempDevice.transform = hmd; tempDevice.position = hmd.position; tempDevice.forward = hmd.forward; tempDevice.up = hmd.up; tempDevice.right = hmd.right; tempDevice.rotation = hmd.transform.rotation; tempDevice.velocity = (hmd.position - lastPosition) / Time.deltaTime; tempDevice.angularVelocity = (hmd.rotation * Quaternion.Inverse(lastRotation)).eulerAngles / Time.deltaTime; lastPosition = hmd.position; lastRotation = hmd.rotation; tempDevice.SetString("Model", VRDevice.model); tempDevice.SetFloat("RefreshRate", VRDevice.refreshRate); tempDevice.SetVector3("Head", InputTracking.GetLocalPosition(VRNode.Head)); tempDevice.SetVector3("LeftEye", InputTracking.GetLocalPosition(VRNode.LeftEye)); tempDevice.SetVector3("RightEye", InputTracking.GetLocalPosition(VRNode.RightEye)); tempDevice.SetVector3("CenterEye", InputTracking.GetLocalPosition(VRNode.CenterEye)); tempDevice.SetQuaternion("Head", InputTracking.GetLocalRotation(VRNode.Head)); tempDevice.SetQuaternion("LeftEye", InputTracking.GetLocalRotation(VRNode.LeftEye)); tempDevice.SetQuaternion("RightEye", InputTracking.GetLocalRotation(VRNode.RightEye)); tempDevice.SetQuaternion("CenterEye", InputTracking.GetLocalRotation(VRNode.CenterEye)); } else { VRInput.GetDevice("ViveHMD").isTracked = false; } #endif }
void DoRaycast() { RaycastHit hit; ConsoleCollider hitCollider = colliders.GetCollider(out hit); switch (hitCollider) { case ConsoleCollider.MainWindow: //if(!ViveInput.Right.Buttons.Trigger.Equals(ButtonState.Pressed)) break; //float yValue = colliders.colliders[0].transform.InverseTransformPoint(hit.point).y; float yParam = VRInput.GetDevice("ViveLeft").GetAxis("TouchpadY"); float sign = Mathf.Sign(yParam); yParam = Mathf.Abs(yParam); yParam *= 1.42857f; yParam -= 0.42857f; yParam = Mathf.Clamp01(yParam); yParam *= yParam; yParam *= sign; if (Mathf.Abs(yParam) < 0.05f) { yParam = 0f; } mainStartIndex -= yParam * mainScrollSpeed * Time.deltaTime; mainStartIndex = Mathf.Clamp(mainStartIndex, 0f, Mathf.Max(0f, getNumToShow() - 13)); atBottom = (mainStartIndex >= Mathf.Max(0f, getNumToShow() - 13) - 1f); if (VRInput.GetDevice("ViveLeft").GetButtonDown("Trigger")) { int indexOfHit = 12 - (int)Mathf.Max(0f, Mathf.RoundToInt((colliders.colliders[0].transform.InverseTransformPoint(hit.point).y + 0.5f) * 13f - 0.7f)); //Debug.Log("index of hit: " + indexOfHit); indexOfHit = Mathf.RoundToInt(indexOfHit + mainStartIndex); if (selectedMessage != null) { selectedMessage.SetColor(colorA); selectedMessage.SetMessageColor(Color.black); selectedMessage = null; } if (collapse) { if (indexOfHit < collapsedLogMessages.Count) { selectedMessage = collapsedLogMessages[indexOfHit]; selectedMessage.SetColor(selectedColor); selectedMessage.SetMessageColor(Color.white); selectedText.text = selectedMessage.log.message + "\n" + selectedMessage.log.stackTrace; selectedOffset = 0f; } } else { if (indexOfHit < logMessages.Count) { selectedMessage = logMessages[indexOfHit]; selectedMessage.SetColor(selectedColor); selectedMessage.SetMessageColor(Color.white); selectedText.text = selectedMessage.log.message + "\n" + selectedMessage.log.stackTrace; selectedOffset = 0f; } } } break; case ConsoleCollider.SubWindow: yParam = VRInput.GetDevice("ViveLeft").GetAxis("TouchpadY"); sign = Mathf.Sign(yParam); yParam = Mathf.Abs(yParam); yParam *= 1.42857f; yParam -= 0.42857f; yParam = Mathf.Clamp01(yParam); yParam *= yParam; yParam *= sign; if (Mathf.Abs(yParam) < 0.05f) { yParam = 0f; } selectedOffset -= yParam * mainScrollSpeed * 20f * Time.deltaTime; selectedOffset = Mathf.Clamp(selectedOffset, 0f, Mathf.Max(0f, selectedText.preferredHeight - 210f)); //if(Time.frameCount % 30 == 0) Debug.Log("selectedText.preferredHeight: " + selectedText.preferredHeight + "\nselectedOffset: " + selectedOffset + "\nyParam: " + yParam); break; case ConsoleCollider.ClearButton: if (VRInput.GetDevice("ViveRight").GetButtonDown("Trigger")) { for (int i = 0; i < logMessages.Count; i++) { Destroy(logMessages[i].gameObject); } for (int i = 0; i < collapsedLogMessages.Count; i++) { Destroy(collapsedLogMessages[i].gameObject); } logMessages.Clear(); collapsedLogMessages.Clear(); mainStartIndex = 0; VRDebug.ClearConsole(); } break; case ConsoleCollider.CollapseButton: if (VRInput.GetDevice("ViveRight").GetButtonDown("Trigger")) { collapse = !collapse; CollapseToggle.SetOn(collapse); if (collapse) { for (int i = 0; i < logMessages.Count; i++) { logMessages[i].gameObject.SetActive(false); } for (int i = 0; i < collapsedLogMessages.Count; i++) { collapsedLogMessages[i].gameObject.SetActive(true); } } else { for (int i = 0; i < collapsedLogMessages.Count; i++) { collapsedLogMessages[i].gameObject.SetActive(false); } for (int i = 0; i < logMessages.Count; i++) { logMessages[i].gameObject.SetActive(true); } } } break; case ConsoleCollider.StickToControllerButton: if (VRInput.GetDevice("ViveRight").GetButtonDown("Trigger")) { GetComponent <FollowTransform>().enabled = !GetComponent <FollowTransform>().enabled; StickToControllerToggle.SetOn(GetComponent <FollowTransform>().enabled); } break; case ConsoleCollider.LogToggleButton: if (VRInput.GetDevice("ViveRight").GetButtonDown("Trigger")) { LogToggle.Toggle(); } break; case ConsoleCollider.WarningToggleButton: if (VRInput.GetDevice("ViveRight").GetButtonDown("Trigger")) { WarningToggle.Toggle(); } break; case ConsoleCollider.ErrorToggleButton: if (VRInput.GetDevice("ViveRight").GetButtonDown("Trigger")) { ErrorToggle.Toggle(); } break; } }
// Use this for initialization void Start() { VRInput.AddXbox(); }