void NoloRecenter() { //leftcontroller double click system button if (GvrControllerInput.GetControllerState(SvrControllerState.NoloLeftContoller).homeButtonUp || GvrControllerInput.GetControllerState(SvrControllerState.NoloRightContoller).homeButtonUp) //if (NoloVR_Controller.GetDevice(NoloDeviceType.LeftController).GetNoloButtonUp(NoloButtonID.System)) { if (Time.frameCount - leftcontrollerRecenter_PreFrame <= recenterSpacingFrame) { //UnityEngine.XR.InputTracking.Recenter(); Recenter(); leftcontrollerRecenter_PreFrame = -1; } else { leftcontrollerRecenter_PreFrame = Time.frameCount; } } //rightcontroller double click system button //if (NoloVR_Controller.GetDevice(NoloDeviceType.RightController).GetNoloButtonUp(NoloButtonID.System)) //if (GvrControllerInput.HomeButtonUp) //{ // if (Time.frameCount - rightcontrollerRecenter_PreFrame <= recenterSpacingFrame) // { // //UnityEngine.XR.InputTracking.Recenter(); // Recenter(); // rightcontrollerRecenter_PreFrame = -1; // } // else // { // rightcontrollerRecenter_PreFrame = Time.frameCount; // } //} }
private void SetupControllerInputDevice() { GvrControllerInputDevice newDevice = GvrControllerInput.GetDevice(controllerHand); if (controllerInputDevice == newDevice) { return; } if (controllerInputDevice != null) { controllerInputDevice.OnStateChanged -= OnControllerStateChanged; controllerInputDevice = null; } controllerInputDevice = newDevice; if (controllerInputDevice != null) { controllerInputDevice.OnStateChanged += OnControllerStateChanged; OnControllerStateChanged(controllerInputDevice.State, controllerInputDevice.State); } else { OnControllerStateChanged(GvrConnectionState.Disconnected, GvrConnectionState.Disconnected); } PropagateControllerInputDevice(); }
/// Provides a concrete implementation of IControllerProvider appropriate for the current /// platform. This method never returns null. In the worst case, it might return a dummy /// provider if the platform is not supported. For demo purposes the emulator controller /// is returned in the editor and in Standalone buids, for use inside the desktop player. static internal IControllerProvider CreateControllerProvider(GvrControllerInput owner) { //*********DIY*CONTROLLER********** try { return(new DIYControllerProvider()); } catch (System.Exception e) { Debug.LogError(e.Message); } //*********DIY*CONTROLLER********** // Use emualtor in editor, and in Standalone builds (for demo purposes). #if UNITY_EDITOR // Use the Editor controller provider that supports the controller emulator and the mouse. return(new EditorControllerProvider(owner.emulatorConnectionMode)); #elif UNITY_ANDROID if (AndroidNativeShimControllerProvider.ShimAvailable()) { // Use the GVR Unity Shim API. return(new AndroidNativeShimControllerProvider()); } else { Debug.LogWarning( "GVR Unity Shim not found. Creating dummy controller provider."); return(new DummyControllerProvider()); } #else // Platform not supported. Debug.LogWarning("No controller support on this platform."); return(new DummyControllerProvider()); #endif // UNITY_EDITOR || UNITY_ANDROID }
// Runtime switching enabled only in-editor. private void Update() { UpdateStatusMessage(); // Scan all devices' buttons for button down, and switch the singleton pointer // to the controller the user last clicked. int newPointer = activeControllerPointer; if (controllerPointers.Length > 1 && controllerPointers[1] != null) { GvrTrackedController trackedController1 = controllerPointers[1].GetComponent <GvrTrackedController>(); foreach (var hand in ALL_HANDS) { GvrControllerInputDevice device = GvrControllerInput.GetDevice(hand); if (device.GetButtonDown(POINTER_BUTTON_MASK)) { // Match the button to our own controllerPointers list. if (device == trackedController1.ControllerInputDevice) { newPointer = 1; } else { newPointer = 0; } break; } } } if (newPointer != activeControllerPointer) { activeControllerPointer = newPointer; SetVRInputMechanism(); } #if !RUNNING_ON_ANDROID_DEVICE UpdateEmulatedPlatformIfPlayerSettingsChanged(); if ((isDaydream && gvrEmulatedPlatformType == EmulatedPlatformType.Daydream) || (!isDaydream && gvrEmulatedPlatformType == EmulatedPlatformType.Cardboard)) { return; } isDaydream = (gvrEmulatedPlatformType == EmulatedPlatformType.Daydream); SetVRInputMechanism(); #else // Running on an Android device. // Viewer type switched at runtime. if (!IsDeviceDaydreamReady() || viewerPlatform == GvrSettings.ViewerPlatform) { return; } isDaydream = GvrSettings.ViewerPlatform == GvrSettings.ViewerPlatformType.Daydream; viewerPlatform = GvrSettings.ViewerPlatform; SetVRInputMechanism(); #endif // !RUNNING_ON_ANDROID_DEVICE }
// Start is called before the first frame update void Start() { controller = GvrControllerInput.GetDevice(GvrControllerHand.Dominant); hudVideo.SetActive(true); followVideo.SetActive(false); podium.SetActive(false); }
private void ApplyArmModel() { Quaternion controllerOrientation = GvrControllerInput.GetOrientation(SvrControllerState.GvrController); Vector3 resetarmposition = Vector3.zero; if (isLockedToHead) { resetarmposition = CalculatArmRoot(Camera.main.transform.localPosition); } else { resetarmposition = mArmRootPosition; } //Debug.Log(controllerOrientation); // Get the relative positions of the joints. Matrix4x4 tt = Matrix4x4.identity; try { tt = Matrix4x4.TRS(resetarmposition, controllerOrientation, Vector3.one); } catch (System.Exception e) { Debug.Log(e.Message); } Vector3 elbowPosition = resetarmposition + new Vector3(0.0f, addedElbowHeight, addedElbowDepth); elbowPosition = tt.MultiplyPoint(new Vector3(0, 0, ElbowToHandLength)); wristPosition = elbowPosition; wristRotation = controllerOrientation; }
protected override void OnUpdatePoses() { switch (_node) { case XRNode.LeftHand: _controller = GvrControllerInput.GetDevice(GvrControllerHand.Left); break; case XRNode.RightHand: _controller = GvrControllerInput.GetDevice(GvrControllerHand.Right); break; } if (_controller != null) { nodePosition = _controller.Position; nodeRotation = _controller.Orientation; } if (!_overridePosition) { transform.localPosition = nodePosition; } else { transform.position = _positionTarget.position; } transform.localRotation = nodeRotation; }
void Update() { if (VRDevice.OculusGo) //OculusGo { OVRInput.Update(); foreach (VRAction action in actions) { if (OVRInput.Get(action.oculusGoInput)) { action.onInput.Invoke(); } } } else if (VRDevice.MirageSolo) //MirageSolo { foreach (VRAction action in actions) { if (GvrControllerInput.GetDevice(GvrControllerHand.Dominant).GetButton(action.mirageInput)) { action.onInput.Invoke(); } } } else if (VRDevice.GearVR) //GearVR (no support for actions) { } }
public int siteLayer = 10; // This should match the layer number sites are in // Use this for initialization void Start() { _dominantController = GvrControllerInput.GetDevice(GvrControllerHand.Dominant); //_previousOrientation = _dominantController.Orientation * Vector3.forward; _previousTouch = _dominantController.TouchPos; _translate = new Vector3(); _initTransform = this.transform.position; }
private void Start() { controller = GvrControllerInput.GetDevice(GvrControllerHand.Dominant); if (!anchored) { AttachToCamera(); } }
// Start is called before the first frame update void Start() { controller = GvrControllerInput.GetDevice(GvrControllerHand.Dominant); menu.SetActive(false); countdownBox.SetActive(true); timer = 0.0f; actionComplete = false; menuActive = false; }
// Update is called once per frame void Update() { GvrPointerInputModule.Pointer = GvrLaserPointer; var device = GvrControllerInput.GetDevice(GvrControllerHand.Dominant); Teleport(device); Rotate(device); }
void Update() { if (VRDevice.OculusGo) //On OculusGo, use the controller's trigger to recalibrate { OVRInput.Update(); if (OVRInput.Get(oculusGoRecenterButton)) { Recenter(); } if (OVRInput.Get(oculusGoQuitButton)) { Application.Quit(); } } else if (VRDevice.MirageSolo) //On Mirage Solo, use the controller's click button { bool overrideTouch = false; bool overrideQuit = false; GvrControllerInputDevice device = GvrControllerInput.GetDevice(GvrControllerHand.Dominant); if (device == null) { device = GvrControllerInput.GetDevice(GvrControllerHand.NonDominant); if (device == null) { Haze.Logger.LogError("Daydream Input API Status: " + GvrControllerInput.ApiStatus); Haze.Logger.LogError("ErrorDetails: " + GvrControllerInput.ErrorDetails); } } if ((device != null && device.GetButton(mirageRecenterButton)) || overrideTouch) { Recenter(); } if ((device != null && device.GetButton(mirageQuitButton)) || overrideQuit) { Application.Quit(); } } else if (VRDevice.GearVR) //On GearVR, double-tap to recalibrate { if (firstTap > 0) //we've tapped a first time! { if (Input.GetMouseButtonDown(0)) { //that's it, double-tapped. Recenter(); firstTap = 0; } firstTap -= Time.deltaTime; } else if (Input.GetMouseButtonUp(0)) { firstTap = 0.3f; //you have .3 seconds to tap once more for double tap! } } }
private void Update() { foreach (var hand in Gvr.Internal.ControllerUtils.AllHands) { GvrControllerInputDevice device = GvrControllerInput.GetDevice(hand); if (device.GetButtonUp(GvrControllerButton.App)) { CycleSeeThroughModes(); } } }
/// Returns true the frame after the user stops pressing down any of buttons specified /// in `buttons` on any controller. public static bool AnyButtonUp(GvrControllerButton buttons) { bool ret = false; foreach (var hand in AllHands) { GvrControllerInputDevice device = GvrControllerInput.GetDevice(hand); ret |= device.GetButtonUp(buttons); } return(ret); }
// Start is called before the first frame update void Start() { videoPlay = true; audioPlay = false; currAudio = Resources.Load <AudioClip>("Audio/Section1/" + audioFiles[0]); controller = GvrControllerInput.GetDevice(GvrControllerHand.Dominant); Reset(); overlay.SetActive(false); visionBlocker.SetActive(false); playVideo.videoPlayer.enabled = false; playVideo.videoCanvas.SetActive(false); }
/// Provides a concrete implementation of IControllerProvider appropriate for the current /// platform. This method never returns null. In the worst case, it might return a dummy /// provider if the platform is not supported. For demo purposes the emulator controller /// is returned in the editor and in Standalone buids, for use inside the desktop player. static internal IControllerProvider CreateControllerProvider(GvrControllerInput owner) { // Use emualtor in editor, and in Standalone builds (for demo purposes). #if UNITY_EDITOR // Use the Editor controller provider that supports the controller emulator and the mouse. return(new EditorControllerProvider(owner.emulatorConnectionMode)); #else // Platform not supported. Debug.LogWarning("No controller support on this platform."); return(new DummyControllerProvider()); #endif // UNITY_EDITOR || UNITY_ANDROID }
// Update is called once per frame async void Update() { GvrPointerInputModule.Pointer = GvrLaserPointer; transform.GetChild(0).localScale = Vector3.zero; var device = GvrControllerInput.GetDevice(GvrControllerHand.Dominant); var otherCardSelected = BoardManager.AnyCardsSelected(); if (Selected || (GvrLaserPointer.CurrentRaycastResult.gameObject != null && GvrLaserPointer.CurrentRaycastResult.gameObject == gameObject && !otherCardSelected)) { transform.GetChild(0).localScale = Vector3.one; if (device.GetButtonUp(GvrControllerButton.TouchPadButton)) { Selected = true; } } if (Selected) { var deviceWorldPosition = Player.transform.TransformPoint(device.Position); if (!wasSelected) { distance = Vector3.Distance(deviceWorldPosition, transform.position); wasSelected = true; GetComponent <Rigidbody>().detectCollisions = false; } transform.position = GvrLaserPointer.GetPointAlongPointer(distance) + new Vector3(0, -0.5f, 0); distance = Mathf.Lerp(distance, 3.0f, Time.deltaTime * 2); if (GvrLaserPointer.CurrentRaycastResult.gameObject != null && GvrLaserPointer.CurrentRaycastResult.gameObject.tag == SWIM_LANE_TAG && device.GetButtonUp(GvrControllerButton.TouchPadButton)) { await CardClient.MoveCardAsync(cardModel, GvrLaserPointer.CurrentRaycastResult.gameObject.GetComponent <SwimLane>().SwimLaneModel); } } else if (!otherCardSelected) { wasSelected = false; } }
// Compute new head pose. private void UpdateHead() { if (updated) { // Only one update per frame, please. return; } updated = true; GvrViewer.Instance.UpdateState(); if (trackRotation) { orientation = GvrViewer.Instance.HeadPose.Orientation; if (target == null) { transform.localRotation = orientation; } else { transform.rotation = target.rotation * orientation; } } if (trackPosition) { //Vector3 pos = GvrViewer.Instance.HeadPose.Position; Vector3 pos = GvrControllerInput.GetPosition(SvrControllerState.NoloHead); //#if NOLOSDK // pos = NoloVR_Controller.GetDevice(NoloDeviceType.Hmd).GetPose().pos; //#endif if (target == null) { transform.localPosition = pos; } else { transform.position = target.position + target.rotation * pos; } } else { transform.localPosition = Vector3.zero; } if (OnHeadUpdated != null) { OnHeadUpdated(gameObject); } }
/// Get the controller's orientation. protected void GetControllerRotation(out Quaternion rotation, out Quaternion xyRotation, out float xAngle) { // Find the controller's orientation relative to the player. rotation = GvrControllerInput.GetOrientation(SvrControllerState.GvrController); rotation = Quaternion.Inverse(torsoRotation) * rotation; // Extract just the x rotation angle. Vector3 controllerForward = rotation * Vector3.forward; xAngle = 90.0f - Vector3.Angle(controllerForward, Vector3.up); // Remove the z rotation from the controller. xyRotation = Quaternion.FromToRotation(Vector3.forward, controllerForward); }
void Update() { bool connected = false; foreach (var hand in Gvr.Internal.ControllerUtils.AllHands) { GvrControllerInputDevice device = GvrControllerInput.GetDevice(hand); if (device.State == GvrConnectionState.Connected) { connected = true; break; } } if (!connected) { return; } // Daydream is loaded only on deivce, not in editor. #if UNITY_ANDROID && !UNITY_EDITOR if (XRSettings.loadedDeviceName != GvrSettings.VR_SDK_DAYDREAM) { return; } #endif if (GvrControllerInput.Recentered) { ApplyYawCorrection(); return; } #if UNITY_EDITOR // Compatibility for Instant Preview. if (Gvr.Internal.InstantPreview.Instance != null && Gvr.Internal.InstantPreview.Instance.enabled && Gvr.Internal.ControllerUtils.AnyButton(GvrControllerButton.System)) { return; } #else // !UNITY_EDITOR if (Gvr.Internal.ControllerUtils.AnyButton(GvrControllerButton.System)) { return; } #endif // UNITY_EDITOR yawCorrection = GetYawCorrection(); }
public override void OnActivated() { EnsureDeviceStateLength(3); if (Object.FindObjectOfType <GvrHeadset>() == null) { VRModule.Instance.gameObject.AddComponent <GvrHeadset>(); } if (Object.FindObjectOfType <GvrControllerInput>() == null) { VRModule.Instance.gameObject.AddComponent <GvrControllerInput>(); } m_rightDevice = GvrControllerInput.GetDevice(GvrControllerHand.Dominant); m_leftDevice = GvrControllerInput.GetDevice(GvrControllerHand.Dominant); var armModels = VRModule.Instance.GetComponents <GvrArmModel>(); if (armModels != null && armModels.Length >= 1) { m_rightArm = armModels[0]; } else { m_rightArm = VRModule.Instance.GetComponent <GvrArmModel>(); if (m_rightArm == null) { m_rightArm = VRModule.Instance.gameObject.AddComponent <GvrArmModel>(); } } m_rightArm.ControllerInputDevice = m_rightDevice; if (armModels != null && armModels.Length >= 2) { m_leftArm = armModels[1]; } else { m_leftArm = VRModule.Instance.GetComponent <GvrArmModel>(); if (m_leftArm == null) { m_leftArm = VRModule.Instance.gameObject.AddComponent <GvrArmModel>(); } } m_leftArm.ControllerInputDevice = m_leftDevice; }
void Update() { //Update_LED(NoloVR_Plugins.GetElectricity(trackedDevice.devicetype)); if (GvrControllerInput.GetControllerState(trackedDevice.deviceType).clickButtonState) { TouchPad_Down(); } else { TouchPad_Up(); } //if (NoloVR_Controller.GetDevice(trackedDevice).GetNoloButtonPressed(NoloButtonID.Menu)) if (GvrControllerInput.GetControllerState(trackedDevice.deviceType).appButtonState) { Menu_Down(); } else { Menu_Up(); } if (GvrControllerInput.GetControllerState(trackedDevice.deviceType).homeButtonState) //if (NoloVR_Controller.GetDevice(trackedDevice).GetNoloButtonPressed(NoloButtonID.System)) { System_Down(); } else { System_Up(); } //if (GvrControllerInput.GetControllerState(trackedDevice.deviceType).homeButtonState) // //if (NoloVR_Controller.GetDevice(trackedDevice).GetNoloButtonPressed(NoloButtonID.Grip)) //{ // Grip_Down(); //} //else //{ // Grip_Up(); //} if (GvrControllerInput.GetControllerState(trackedDevice.deviceType).triggerButtonState) //if (NoloVR_Controller.GetDevice(trackedDevice).GetNoloButtonPressed(NoloButtonID.Trigger)) { Trigger_Down(); } else { Trigger_Up(); } }
// Start is called before the first frame update void Start() { narratorAudio = GetComponent <AudioSource>(); currAudio = Resources.Load <AudioClip>("Audio/Section1/Intro"); controller = GvrControllerInput.GetDevice(GvrControllerHand.Dominant); if (hideObjects) { Reset(); } else { placed = true; ChangeActive(true); } }
void UpdatePose() { var pose = GvrControllerInput.GetPosition(deviceType); var roation = GvrControllerInput.GetOrientation(deviceType); if (!GvrHead.TrackPosition) { Vector3 headPos = GvrControllerInput.GetPosition(SvrControllerState.NoloHead); transform.localPosition = pose + new Vector3(-headPos.x, -headPos.y, -headPos.z); } else { transform.localPosition = pose; } transform.localRotation = roation; }
void Start() { player = GameObject.FindGameObjectWithTag("Player"); controller = GvrControllerInput.GetDevice(GvrControllerHand.Dominant); boundsHandler.OutOfBoundsListener += OutOfBounds; InitStates(); SetScoreboardPars(); SetupHoleSigns(); SetRaycastingEnabled(false); MovePlayerToCurrentHoleStart(); SetState(statePreThrow); disc.gameObject.SetActive(false); scoreboardController.gameObject.SetActive(false); pauseMenu.SetActive(false); popup.gameObject.SetActive(false); }
public override TBInput.Controller GetActiveController() { if (TBInput.GetActiveControlType() == TBInput.ControlType.HandControllers) { if (GvrControllerInput.GetDevice(GvrControllerHand.Dominant).SupportsPositionalTracking) { return(TBInput.Controller.RHandController); } else { return(TBInput.Controller.Mobile3DOFController); } } else { return(TBInput.Controller.Mobile3DOFController); } }
void Start() { /* Character Controller Boilerplate */ cc = GetComponent <CharacterController>(); /* Latch the GVRControllerInputDevice */ //TODO: If this fails, is there feedback to the user, and // is there a retry? Is there a onConnected callback somewhere? device = GvrControllerInput.GetDevice(GvrControllerHand.Dominant); if (device == null) { Debug.LogError($"{logtag} GvrControllerInputDevice is null"); } else { Debug.LogError($"{logtag} Latched GvrControllerInputDevice."); } }
void Awake() { if (instance != null) { Debug.LogError("More than one GvrController instance was found in your scene. " + "Ensure that there is only one GvrControllerInput."); this.enabled = false; return; } instance = this; if (controllerProvider == null) { controllerProvider = ControllerProviderFactory.CreateControllerProvider(this); } // Keep screen on here, since GvrController must be in any GVR scene in order to enable // controller capabilities. Screen.sleepTimeout = SleepTimeout.NeverSleep; }
void Update() { TT.text = (h.ToString() + "///" + Camera.main.transform.rotation.eulerAngles.ToString() + GGHHS.ToString()); X = Input.GetAxis("Vertical"); if (GvrControllerInput.GetDevice(GvrControllerHand.Dominant).GetButton(GvrControllerButton.TouchPadTouch)) { GGHHS++; h = GvrControllerInput.GetDevice(GvrControllerHand.Dominant).TouchPos; } if (GvrControllerInput.GetDevice(GvrControllerHand.Dominant).GetButtonUp(GvrControllerButton.TouchPadTouch)) { GGHHS = 0; h = Vector2.zero; RR.velocity = Vector3.zero; RR.angularVelocity = Vector3.zero; } RR.AddForce(Camera.main.transform.forward * h.y * Speed); }