protected override void Start () { base.Start (); ControllerCamera = new GameObject ("Controller UI Camera").AddComponent<Camera> (); ControllerCamera.clearFlags = CameraClearFlags.Nothing; //CameraClearFlags.Depth; ControllerCamera.cullingMask = 0; // 1 << LayerMask.NameToLayer("UI"); ControllerManager = GameObject.FindObjectOfType<SteamVR_ControllerManager> (); Controllers = new SteamVR_TrackedObject[] { ControllerManager.left.GetComponent<SteamVR_TrackedObject> (), ControllerManager.right.GetComponent<SteamVR_TrackedObject> () }; ControllerDevices = new SteamVR_Controller.Device[Controllers.Length]; Cursors = new RectTransform[Controllers.Length]; for (int index = 0; index < Cursors.Length; index++) { GameObject cursor = new GameObject ("Cursor " + index); Canvas canvas = cursor.AddComponent<Canvas> (); cursor.AddComponent<CanvasRenderer> (); cursor.AddComponent<CanvasScaler> (); cursor.AddComponent<UIIgnoreRaycast> (); cursor.AddComponent<GraphicRaycaster> (); canvas.renderMode = RenderMode.WorldSpace; canvas.sortingOrder = 1000; //set to be on top of everything Image image = cursor.AddComponent<Image> (); if (CursorSprite == null) { image.sprite = CursorSprite; image.material = CursorMaterial; } // if (CursorSprite == null) // Debug.LogError("Set CursorSprite on " + this.gameObject.name + " to the sprite you want to use as your cursor.", this.gameObject); Cursors [index] = cursor.GetComponent<RectTransform> (); } CurrentPoint = new GameObject[Cursors.Length]; CurrentPressed = new GameObject[Cursors.Length]; CurrentDragging = new GameObject[Cursors.Length]; PointEvents = new PointerEventData[Cursors.Length]; Canvas[] canvases = GameObject.FindObjectsOfType<Canvas> (); foreach (Canvas canvas in canvases) { canvas.worldCamera = ControllerCamera; } }
private void Awake() { if (this.GetComponent<VRTK_PlayerPresence>()) { playerPresence = this.GetComponent<VRTK_PlayerPresence>(); } else { Debug.LogError("The VRTK_TouchpadWalking script requires the VRTK_PlayerPresence script to be attached to the [CameraRig]"); } touchpadAxisChanged = new ControllerInteractionEventHandler(DoTouchpadAxisChanged); touchpadUntouched = new ControllerInteractionEventHandler(DoTouchpadTouchEnd); controllerManager = this.GetComponent<SteamVR_ControllerManager>(); }
private void Awake() { // Required Component: VRTK_PlayerPresence playerPresence = GetComponent<VRTK_PlayerPresence>(); if (useGravity) { if (!playerPresence) { playerPresence = gameObject.AddComponent<VRTK_PlayerPresence>(); } playerPresence.SetFallingPhysicsOnlyParams(true); } controllerManager = FindObjectOfType<SteamVR_ControllerManager>(); headCamera = VRTK_DeviceFinder.HeadsetTransform(); collisionFade = headCamera.GetComponent<VRTK_HeadsetCollisionFade>(); if (collisionFade == null) { collisionFade = headCamera.gameObject.AddComponent<VRTK_HeadsetCollisionFade>(); } }
/// <summary> /// Creates both controllers by using <see cref="CreateRightController"/> and <see cref="CreateLeftController"/>. /// Override those methods to change the controller implementation to be used. /// </summary> protected virtual void CreateControllers() { var steamCam = VR.Camera.SteamCam; steamCam.origin.gameObject.SetActive(false); { ControllerManager = steamCam.origin.gameObject.AddComponent <SteamVR_ControllerManager>(); if (VR.Settings.Leap) { LeapMotion = CreateLeapHandController(); LeapMotion.transform.name = "Leap Motion Controller (" + (++cnter) + ")"; LeapMotion.transform.SetParent(steamCam.head.transform, false); LeapMotion.transform.localRotation = Quaternion.Euler(-90f, 180f, 0); LeapMotion.transform.localPosition += Vector3.forward * 0.08f; } Left = CreateLeftController(); Left.transform.SetParent(steamCam.origin, false); Right = CreateRightController(); Right.transform.SetParent(steamCam.origin, false); Left.Other = Right; Right.Other = Left; ControllerManager.left = Left.gameObject; ControllerManager.right = Right.gameObject; } steamCam.origin.gameObject.SetActive(true); VRLog.Info("---- Initialize left tools"); InitializeTools(Left, true); VRLog.Info("---- Initialize right tools"); InitializeTools(Right, false); ControllersCreated(this, new EventArgs()); }
public override void Initialize(NVRPlayer player) { Player = player; #if UNITY_5_6_OR_NEWER Player.Head.gameObject.AddComponent <SteamVR_UpdatePoses>(); #endif Player.gameObject.SetActive(false); SteamVR_ControllerManager controllerManager = Player.gameObject.AddComponent <SteamVR_ControllerManager>(); controllerManager.left = Player.LeftHand.gameObject; controllerManager.right = Player.RightHand.gameObject; //Player.gameObject.AddComponent<SteamVR_PlayArea>(); for (int index = 0; index < Player.Hands.Length; index++) { Player.Hands[index].gameObject.AddComponent <SteamVR_TrackedObject>(); } SteamVR_Camera steamVrCamera = Player.Head.gameObject.AddComponent <SteamVR_Camera>(); Player.Head.gameObject.AddComponent <SteamVR_Ears>(); NVRHelpers.SetField(steamVrCamera, "_head", Player.Head.transform, false); NVRHelpers.SetField(steamVrCamera, "_ears", Player.Head.transform, false); Player.Head.gameObject.AddComponent <SteamVR_TrackedObject>(); Player.gameObject.SetActive(true); SteamVR_Render[] steamvr_objects = GameObject.FindObjectsOfType <SteamVR_Render>(); for (int objectIndex = 0; objectIndex < steamvr_objects.Length; objectIndex++) { steamvr_objects[objectIndex].lockPhysicsUpdateRateToRenderFrequency = false; //this generally seems to break things :) Just make sure your Time -> Physics Timestep is set to 0.011 } }
//Register the existing pads, the pads registered will be checked if their IDs are correct void RegisterExistingPads() { if (cameraRig != null) { controllerManager = cameraRig.transform.GetComponent <SteamVR_ControllerManager>(); } if (controllerManager == null) { return; } controllerManager.Refresh(); controllersGameObject.Clear(); devices.Clear(); controllersGameObject.Add(controllerManager.left); controllersGameObject.Add(controllerManager.right); foreach (GameObject o in controllerManager.objects) { if (!controllersGameObject.Contains(o)) { controllersGameObject.Add(o); } } }
//------------------------ // Setup //------------------------ void Start() { #if USES_STEAM_VR controllerManager = Object.FindObjectOfType <SteamVR_ControllerManager> (); Assert.IsNotNull(controllerManager, "SVControllerInput (with SteamVR) Needs a SteamVR_ControllerManager in the scene to function correctly."); #elif USES_OPEN_VR controllerManager = Object.FindObjectOfType <OVRManager> (); Assert.IsNotNull(controllerManager, "SVControllerInput (with Open VR) Needs a OVRManager in the scene to function correctly."); buttonStateLeft = new Dictionary <int, bool>(); buttonStateRight = new Dictionary <int, bool>(); int cnt = 10; clipHard = new OVRHapticsClip(cnt); for (int i = 0; i < cnt; i++) { clipHard.Samples[i] = i % 2 == 0 ? (byte)0 : (byte)180; } clipHard = new OVRHapticsClip(clipHard.Samples, clipHard.Samples.Length); #else Debug.LogError("Easy Grab VR requires you to choose either Steam VR or Oculus SDK as your VR platform. Please open \"Window -> Easy Grip VR SDK\" and select your framework."); #endif }
// Use this for initialization void Start() { //if the molecule cannot be retrieved by setting it in the Unity Editor, look for it. if (molecule == null) { molecule = GameObject.FindGameObjectWithTag("Mol"); } trackedobj = GetComponent <SteamVR_TrackedObject>(); controllerManager = GetComponent <SteamVR_ControllerManager>(); leftIndex = (int)controllerManager.left.GetComponent <SteamVR_TrackedObject>().index; if (leftIndex != -1) { leftController = SteamVR_Controller.Input(leftIndex); } rightIndex = (int)controllerManager.right.GetComponent <SteamVR_TrackedObject>().index; if (rightIndex != -1) { rightController = SteamVR_Controller.Input(rightIndex); } // Debug.Log(trackedobj.index); }
protected virtual void CreateControllers() { // コントローラマネージャの生成 VRLog.Info("SteamVR Controller Manager Create"); _ControllerManager = gameObject.AddComponent <SteamVR_ControllerManager>(); _ControllerManager.enabled = false; // コントローラの生成. VRLog.Info("Left Controller Create"); Left = LeftController.Create(); VRLog.Info("Right Controller Create"); Right = RightController.Create(); _ControllerManager.left = Left.gameObject; _ControllerManager.right = Right.gameObject; _ControllerManager.UpdateTargets(); _ControllerManager.enabled = true; Left.transform.SetParent(VR.Camera.Origin, true); Right.transform.SetParent(VR.Camera.Origin, true); return; }
//Register the existing pads, the pads registered will be checked if their IDs are correct void RegisterExistingPads() { if (cameraRig != null) { controllerManager = cameraRig.transform.GetComponent <SteamVR_ControllerManager>(); controllerManager.Refresh(); controllersGameObject.Clear(); devices.Clear(); controllersGameObject.Add(controllerManager.left); controllersGameObject.Add(controllerManager.right); foreach (GameObject o in controllerManager.objects) { if (!controllersGameObject.Contains(o)) { controllersGameObject.Add(o); } } } else { Debug.LogWarning("Missing [Camera_Rig] !"); } }
// Use this for initialization void Awake() { SerialSelectionMode serial = GetComponent <SerialSelectionMode>(); if (serial.controllerRight != null || serial.controllerLeft != null) { // Only needs to set up once so will return otherwise return; } GameObject leftController = null, rightController = null; #if SteamVR_Legacy SteamVR_ControllerManager CameraRigObject = FindObjectOfType <SteamVR_ControllerManager>(); if ((CameraRigObject = FindObjectOfType <SteamVR_ControllerManager>()) != null) { leftController = CameraRigObject.left; rightController = CameraRigObject.right; serial.controllerRight = rightController; serial.controllerLeft = leftController; } #elif SteamVR_2 SteamVR_Behaviour_Pose[] controllers = FindObjectsOfType <SteamVR_Behaviour_Pose>(); if (controllers.Length > 1) { leftController = controllers[0].inputSource.ToString() == "LeftHand" ? controllers[0].gameObject : controllers[1].inputSource.ToString() == "LeftHand" ? controllers[1].gameObject : null; rightController = controllers[0].inputSource.ToString() == "RightHand" ? controllers[0].gameObject : controllers[1].inputSource.ToString() == "RightHand" ? controllers[1].gameObject : null; } else { leftController = controllers[0].inputSource.ToString() == "LeftHand" ? controllers[0].gameObject : null; rightController = controllers[0].inputSource.ToString() == "RightHand" ? controllers[0].gameObject : null; } serial.controllerRight = rightController; serial.controllerLeft = leftController; #endif }
void Awake() { // Controller only ever needs to be setup once Raycasting ray = GetComponent <Raycasting>(); if (ray.controllerLeft != null && ray.controllerRight != null) { return; } GameObject leftController = null, rightController = null; #if SteamVR_Legacy SteamVR_ControllerManager CameraRigObject = FindObjectOfType <SteamVR_ControllerManager>(); if ((CameraRigObject = FindObjectOfType <SteamVR_ControllerManager>()) != null) { leftController = CameraRigObject.left; rightController = CameraRigObject.right; ray.controllerRight = rightController; ray.controllerLeft = leftController; } #elif SteamVR_2 SteamVR_Behaviour_Pose[] controllers = FindObjectsOfType <SteamVR_Behaviour_Pose>(); if (controllers.Length > 1) { leftController = controllers[0].inputSource.ToString() == "LeftHand" ? controllers[0].gameObject : controllers[1].inputSource.ToString() == "LeftHand" ? controllers[1].gameObject : null; rightController = controllers[0].inputSource.ToString() == "RightHand" ? controllers[0].gameObject : controllers[1].inputSource.ToString() == "RightHand" ? controllers[1].gameObject : null; } else { leftController = controllers[0].inputSource.ToString() == "LeftHand" ? controllers[0].gameObject : null; rightController = controllers[0].inputSource.ToString() == "RightHand" ? controllers[0].gameObject : null; } ray.controllerRight = rightController; ray.controllerLeft = leftController; #endif }
void Start() { centerTracker = GameObject.CreatePrimitive(PrimitiveType.Sphere); centerTracker.transform.localScale *= .05f; centerTracker.GetComponent <Renderer>().material.color = Color.blue; centerTracker2 = GameObject.CreatePrimitive(PrimitiveType.Sphere); centerTracker2.transform.localScale *= .05f; centerTracker2.GetComponent <Renderer>().material.color = Color.red; ControllerManager = GameObject.FindObjectOfType <SteamVR_ControllerManager>(); Controllers = new SteamVR_TrackedObject[] { ControllerManager.left.GetComponent <SteamVR_TrackedObject>(), ControllerManager.right.GetComponent <SteamVR_TrackedObject>() }; Devices = new SteamVR_Controller.Device[Controllers.Length]; Globals.steeringColumn = GameObject.Find("SteeringColumn"); Globals.steerOrigin = Globals.steeringColumn.transform.position; Globals.seat = GameObject.Find("Seat"); seatTracker = Globals.seat.transform.FindChild("SeatTracker").gameObject; Globals.handles[0] = GameObject.Find("Cylinder.003"); Globals.handles[1] = GameObject.Find("Cylinder.000"); Globals.handles[0].tag = "handle"; Globals.handles[1].tag = "handle"; Globals.handles[0].AddComponent <BoxCollider>().isTrigger = true; Globals.handles[1].AddComponent <BoxCollider>().isTrigger = true; Globals.handles[0].transform.parent = null; Globals.handles[1].transform.parent = null; Globals.origDist = Mathf.Abs(Globals.handles[0].transform.position.y - Globals.steerOrigin.y); Globals.halfHandleDist = Mathf.Abs(Vector3.Distance(Globals.handles[0].transform.position, Globals.handles[1].transform.position)) / 2f; Globals.rootCam = GameObject.Find("[CameraRig]"); Globals.mainCam = GameObject.Find("Camera (eye)").GetComponent <Camera>(); Globals.turret = GameObject.Find("Turret"); handleText = GameObject.Find("HandlePos").GetComponent <TextMesh>(); handText = GameObject.Find("HandPos").GetComponent <TextMesh>(); }
private void FindControllerManager() { VRCInputProcessor l_input = VRCInputManager.field_Private_Static_Dictionary_2_EnumNPublicSealedvaKeMoCoGaViOcViDaWaUnique_VRCInputProcessor_0[VRCInputManager.EnumNPublicSealedvaKeMoCoGaViOcViDaWaUnique.Vive]; if (l_input) { VRCInputProcessorVive l_castInput = l_input.TryCast <VRCInputProcessorVive>(); if (l_castInput) { m_controllerManager = l_castInput.field_Private_SteamVR_ControllerManager_0; return; } } l_input = VRCInputManager.field_Private_Static_Dictionary_2_EnumNPublicSealedvaKeMoCoGaViOcViDaWaUnique_VRCInputProcessor_0[VRCInputManager.EnumNPublicSealedvaKeMoCoGaViOcViDaWaUnique.ViveAdvanced]; if (l_input) { VRCInputProcessorViveAdvanced l_castInput = l_input.TryCast <VRCInputProcessorViveAdvanced>(); if (l_castInput) { m_controllerManager = l_castInput.field_Private_SteamVR_ControllerManager_0; return; } } l_input = VRCInputManager.field_Private_Static_Dictionary_2_EnumNPublicSealedvaKeMoCoGaViOcViDaWaUnique_VRCInputProcessor_0[VRCInputManager.EnumNPublicSealedvaKeMoCoGaViOcViDaWaUnique.Index]; if (l_input) { VRCInputProcessorIndex l_castInput = l_input.TryCast <VRCInputProcessorIndex>(); if (l_castInput) { m_controllerManager = l_castInput.field_Private_SteamVR_ControllerManager_0; return; } } }
void Awake() { // If the controllers are null will try to set everything up. Otherwise will run. if (leftController == null && rightController == null) { #if SteamVR_Legacy // Locates the camera rig and its child controllers SteamVR_ControllerManager CameraRigObject = FindObjectOfType <SteamVR_ControllerManager>(); leftController = CameraRigObject.left; rightController = CameraRigObject.right; #elif SteamVR_2 SteamVR_Behaviour_Pose[] controllers = FindObjectsOfType <SteamVR_Behaviour_Pose>(); if (controllers.Length > 1) { leftController = controllers[0].inputSource.ToString() == "LeftHand" ? controllers[0].gameObject : controllers[1].inputSource.ToString() == "LeftHand" ? controllers[1].gameObject : null; rightController = controllers[0].inputSource.ToString() == "RightHand" ? controllers[0].gameObject : controllers[1].inputSource.ToString() == "RightHand" ? controllers[1].gameObject : null; } else if (controllers.Length == 1) { leftController = controllers[0].inputSource.ToString() == "LeftHand" ? controllers[0].gameObject : null; rightController = controllers[0].inputSource.ToString() == "RightHand" ? controllers[0].gameObject : null; } else { return; } #endif // Adding variables to shadow scripts GoGoShadow shadowLeft; if ((shadowLeft = leftHannd.GetComponent <GoGoShadow>()) != null) { #if SteamVR_Legacy shadowLeft.trackedObj = leftController.GetComponent <SteamVR_TrackedObject>(); #elif SteamVR_2 shadowLeft.trackedObj = leftController.GetComponent <SteamVR_Behaviour_Pose>(); #endif shadowLeft.theController = leftController; shadowLeft.theModel = leftController.transform.GetChild(0).gameObject; shadowLeft.cameraRig = leftController.transform.parent.gameObject; } GoGoShadow shadowRight; if ((shadowRight = rightHand.GetComponent <GoGoShadow>()) != null) { #if SteamVR_Legacy shadowRight.trackedObj = rightController.GetComponent <SteamVR_TrackedObject>(); #elif SteamVR_2 shadowRight.trackedObj = rightController.GetComponent <SteamVR_Behaviour_Pose>(); #endif shadowRight.theController = rightController; shadowRight.theModel = rightController.transform.GetChild(0).gameObject; shadowRight.cameraRig = rightController.transform.parent.gameObject; } // Adding variables to interaction scripts GrabObject grabLeft; if ((grabLeft = leftHannd.GetComponent <GrabObject>()) != null) { #if SteamVR_Legacy grabLeft.trackedObj = leftController.GetComponent <SteamVR_TrackedObject>(); #elif SteamVR_2 grabLeft.trackedObj = leftController.GetComponent <SteamVR_Behaviour_Pose>(); #endif } GrabObject grabRight; if ((grabRight = rightHand.GetComponent <GrabObject>()) != null) { #if SteamVR_Legacy grabRight.trackedObj = rightController.GetComponent <SteamVR_TrackedObject>(); #elif SteamVR_2 grabRight.trackedObj = rightController.GetComponent <SteamVR_Behaviour_Pose>(); #endif } } }
void Awake() { _instance = this; UpdateTargets(); }
private SteamVR_ControllerManager GetControllerManager() { if (cachedControllerManager == null || !cachedControllerManager.isActiveAndEnabled) { foreach (var manager in FindObjectsOfType<SteamVR_ControllerManager>()) { if (manager.left && manager.right) { cachedControllerManager = manager; } } } return cachedControllerManager; }
/// <summary> /// initialize SteamVR_ControllerManager and MediaPlayer /// </summary> private void Initialize() { m_ControllerManager = GameObject.FindObjectOfType <SteamVR_ControllerManager>(); mp = GetComponent <MediaPlayer> (); }
private void OnTrackedDeviceRoleChanged(params object[] args) { cachedControllerManager = null; VRTK_ObjectCache.trackedControllers.Clear(); }
SteamVR_ControllerManager controllerManager; //The steam controller manager that holds the controller indices // Use this for initialization void Awake() { controllerManager = SteamVR_ControllerManager.instance; }
private void Awake() { steamVR_ControllerManager = GetComponent <SteamVR_ControllerManager>(); svrBaroqueInterface = this; }
static void InitializeControllers() { if (controllers != null && controllers[0].transform != null && controllers[1].transform != null && controllers[0].id > 0 && controllers[1].id > 0) { return; } if (controllers == null) { controllers = new ControllerInfo[2]; controllers[0] = new ControllerInfo(); controllers[1] = new ControllerInfo(); } //try to initialize with controllermanager //otherwise try to initialize with player.hands if (cm == null) { cm = GameObject.FindObjectOfType <SteamVR_ControllerManager>(); } if (cm != null) { var left = cm.left.GetComponent <SteamVR_TrackedObject>(); controllers[0].transform = left.transform; controllers[0].id = (int)left.index; controllers[0].isRight = false; if (left.index != SteamVR_TrackedObject.EIndex.None) { controllers[0].connected = SteamVR_Controller.Input((int)left.index).connected; controllers[0].visible = SteamVR_Controller.Input((int)left.index).valid; } else { controllers[0].connected = false; controllers[0].visible = false; } var right = cm.right.GetComponent <SteamVR_TrackedObject>(); controllers[1].transform = right.transform; controllers[1].id = (int)right.index; controllers[1].isRight = true; if (right.index != SteamVR_TrackedObject.EIndex.None) { controllers[1].connected = SteamVR_Controller.Input((int)right.index).connected; controllers[1].visible = SteamVR_Controller.Input((int)right.index).valid; } else { controllers[1].connected = false; controllers[1].visible = false; } } else { if (player == null) { player = GameObject.FindObjectOfType <Valve.VR.InteractionSystem.Player>(); } if (player != null) { var left = player.leftHand; if (left != null && left.controller != null) { controllers[0].transform = player.leftHand.transform; controllers[0].id = (int)player.leftHand.controller.index; controllers[0].isRight = false; controllers[0].connected = left.controller.connected; controllers[0].visible = left.controller.valid; } var right = player.rightHand; if (right != null && right.controller != null) { controllers[1].transform = player.rightHand.transform; controllers[1].id = (int)player.rightHand.controller.index; controllers[1].isRight = true; controllers[1].connected = right.controller.connected; controllers[1].visible = right.controller.valid; } } } }
/// <summary> /// Automatically configure the SteamVR camera rig object in the scene. /// </summary> /// <returns>True if successful, false if there was an error.</returns> public bool Configure() { if (!cameraRig) { Debug.LogWarning("Holojam.Vive.ViveModule: Camera rig not assigned!"); return(false); } SteamVR_ControllerManager controllers = cameraRig.GetComponent <SteamVR_ControllerManager>() as SteamVR_ControllerManager; // Add/update controller relays Action <Type> ConfigureController = type => { GameObject controller = type == Type.LEFT ? controllers.left : controllers.right; if (controller) { ViveControllerRelay relay = controller.GetComponent <ViveControllerRelay>() as ViveControllerRelay; if (!relay) { relay = controller.AddComponent <ViveControllerRelay>() as ViveControllerRelay; } relay.type = type; } else { Debug.Log("Holojam.Vive.ViveModule: Controller not found: " + TypeToString(type)); } }; if (controllers) { ConfigureController(Type.LEFT); ConfigureController(Type.RIGHT); } // Add/update Vive relay SteamVR_Camera camera = cameraRig.GetComponentInChildren <SteamVR_Camera>() as SteamVR_Camera; if (camera) { if (!camera.GetComponent <Tools.ActorTransformRelay>()) { camera.gameObject.AddComponent <Tools.ActorTransformRelay>(); } } else { Debug.LogWarning( "Holojam.Vive.ViveModule: SteamVR camera not found. " + "Did you assign the correct game object to the camera rig field?" ); return(false); } Debug.Log("Holojam.Vive.ViveModule: Configure successful!"); return(true); }
private void Start() { controllers = FindObjectOfType<SteamVR_ControllerManager>(); spawnDelayTimer = 0f; }
protected override void Initialize() { m_InitScale = transform.localScale; m_ControllerManager = GameObject.FindObjectOfType <SteamVR_ControllerManager>(); }
// Use this for initialization void Start() { //Application.LoadLevel("Hackathon"); man = GameObject.Find("[CameraRig]").GetComponent <SteamVR_ControllerManager>(); pointer = GameObject.Find("Pointer"); }
// Use this for initialization void Start() { controllerManager = GetComponentInParent <SteamVR_ControllerManager>(); //SteamVR_Controller.Device controllerDevice = SteamVR_Controller.Input((int)Controller.controllerIndex); //hand.transform.parent = controllerDevice.transform; }
public override void StartController(InstantVR ivr) { if (extension == null) { extension = ivr.GetComponent <IVR_UnityVR>(); } if (VRSettings.enabled) { extension.present = VRDevice.isPresent; Camera camera = CheckCamera(); if (camera != null) { cameraTransform = camera.transform; neck2eyes = HeadUtils.GetNeckEyeDelta(ivr); head2eyes = HeadUtils.GetHeadEyeDelta(ivr); DeterminePlatform(); cameraRoot = new GameObject("UnityVR Root"); cameraRoot.transform.parent = ivr.transform; #if UNITY_STANDALONE_WIN if (needsOVR || needsSteamVR) { cameraRoot.transform.position = ivr.transform.position; } else #endif cameraRoot.transform.position = transform.position; cameraRoot.transform.rotation = ivr.transform.rotation; cameraTransform.SetParent(cameraRoot.transform, false); base.StartController(ivr); if (needsOVR) { ovrManager = transform.gameObject.AddComponent <OVRManager>(); if (ovrManager != null) { ovrManager.resetTrackerOnLoad = true; #if UNITY_STANDALONE_WIN ovrManager.trackingOriginType = OVRManager.TrackingOrigin.FloorLevel; cameraTransform.localPosition = Vector3.zero; #else ovrManager.trackingOriginType = OVRManager.TrackingOrigin.EyeLevel; #endif } } if (needsSteamVR) { cameraTransform.gameObject.AddComponent <SteamVR_Camera>(); steamManager = cameraRoot.gameObject.AddComponent <SteamVR_ControllerManager>(); } #if INSTANTVR_ADVANCED kinect2Head = GetComponent <IVR_Kinect2Head>(); vicoVRHead = GetComponent <IVR_VicoVRHead>(); #endif } } }
private void Start() { controllers = FindObjectOfType <SteamVR_ControllerManager>(); spawnDelayTimer = 0f; }
// Runs in the editor void Awake() { // If the controllers are null will try to set everything up. Otherwise will run. if (leftController == null && rightController == null) { // Locates the camera rig and its child controllers #if SteamVR_Legacy SteamVR_ControllerManager CameraRigObject = FindObjectOfType <SteamVR_ControllerManager>(); leftController = CameraRigObject.left; rightController = CameraRigObject.right; #elif SteamVR_2 SteamVR_Behaviour_Pose[] controllers = FindObjectsOfType <SteamVR_Behaviour_Pose>(); if (controllers.Length > 1) { leftController = controllers[0].inputSource.ToString() == "LeftHand" ? controllers[0].gameObject : controllers[1].inputSource.ToString() == "LeftHand" ? controllers[1].gameObject : null; rightController = controllers[0].inputSource.ToString() == "RightHand" ? controllers[0].gameObject : controllers[1].inputSource.ToString() == "RightHand" ? controllers[1].gameObject : null; } else if (controllers.Length == 1) { leftController = controllers[0].inputSource.ToString() == "LeftHand" ? controllers[0].gameObject : null; rightController = controllers[0].inputSource.ToString() == "RightHand" ? controllers[0].gameObject : null; } else { return; } #endif if ((leftFlashlight.GetComponent <Flashlight>()) != null) { #if SteamVR_Legacy leftFlashlight.GetComponent <Flashlight>().trackedObj = leftController.GetComponent <SteamVR_TrackedObject>(); #elif SteamVR_2 leftFlashlight.GetComponent <Flashlight>().trackedObj = leftController.GetComponent <SteamVR_Behaviour_Pose>(); #endif leftFlashlight.GetComponent <Flashlight>().objectAttachedTo = leftController; FlashlightSelection leftSelection; if ((leftSelection = leftFlashlight.GetComponent <FlashlightSelection>()) != null) { #if SteamVR_Legacy leftSelection.theController = leftController.GetComponent <SteamVR_TrackedObject>(); #elif SteamVR_2 leftSelection.theController = leftController.GetComponent <SteamVR_Behaviour_Pose>(); #endif } } if ((rightFlashlight.GetComponent <Flashlight>()) != null) { #if SteamVR_Legacy rightFlashlight.GetComponent <Flashlight>().trackedObj = rightController.GetComponent <SteamVR_TrackedObject>(); #elif SteamVR_2 rightFlashlight.GetComponent <Flashlight>().trackedObj = rightController.GetComponent <SteamVR_Behaviour_Pose>(); #endif rightFlashlight.GetComponent <Flashlight>().objectAttachedTo = rightController; FlashlightSelection rightSelection; if ((rightSelection = rightFlashlight.GetComponent <FlashlightSelection>()) != null) { #if SteamVR_Legacy rightSelection.theController = rightController.GetComponent <SteamVR_TrackedObject>(); #elif SteamVR_2 rightSelection.theController = rightController.GetComponent <SteamVR_Behaviour_Pose>(); #endif } } } }
private void Start() { bowAnimation = GetComponent<BowAnimation>(); handle = GetComponentInChildren<BowHandle>(); controllers = FindObjectOfType<SteamVR_ControllerManager>(); interact = GetComponent<VRTK_InteractableObject>(); interact.InteractableObjectGrabbed += new InteractableObjectEventHandler(DoObjectGrab); }
private void Start() { _controllerManager = FindObjectOfType <SteamVR_ControllerManager>(); }
protected virtual void Awake() { Utilities.SetPlayerObject(gameObject, VRTK_PlayerObject.ObjectTypes.CameraRig); eyeCamera = Utilities.AddCameraFade(); controllerManager = FindObjectOfType <SteamVR_ControllerManager>(); }
public override void Initialize(NVRPlayer player) { Player = player; #if UNITY_5_6_OR_NEWER Player.Head.gameObject.AddComponent <SteamVR_UpdatePoses>(); #endif Player.gameObject.SetActive(false); SteamVR_ControllerManager controllerManager = Player.gameObject.AddComponent <SteamVR_ControllerManager>(); controllerManager.left = Player.LeftHand.gameObject; controllerManager.right = Player.RightHand.gameObject; //Player.gameObject.AddComponent<SteamVR_PlayArea>(); for (int index = 0; index < Player.Hands.Length; index++) { Player.Hands[index].gameObject.AddComponent <SteamVR_TrackedObject>(); } SteamVR_Camera steamVrCamera = Player.Head.gameObject.AddComponent <SteamVR_Camera>(); Player.Head.gameObject.AddComponent <SteamVR_Ears>(); NVRHelpers.SetField(steamVrCamera, "_head", Player.Head.transform, false); NVRHelpers.SetField(steamVrCamera, "_ears", Player.Head.transform, false); //// Start Integration for Holo with NVR ////// // Integration for two camera setup needed for Microsoft Holo video with NewtonVr Player.Head.gameObject.name = "Head_Left"; // rename original NVR head to avoid confusion in editor // Create game object and position it to match NVR existing camera GameObject headRight = new GameObject("Head_Right"); headRight.transform.position = Player.Head.gameObject.transform.position; headRight.transform.rotation = Player.Head.transform.rotation; headRight.transform.parent = Player.Head.transform.parent; // Add camera to new game object and set for right VR eye Camera camRight = headRight.AddComponent <Camera> (); camRight.stereoTargetEye = StereoTargetEyeMask.Right; // Add steam camera component //SteamVR_Camera steamVrCameraRight = headRight.gameObject.AddComponent<SteamVR_Camera>(); headRight.gameObject.AddComponent <SteamVR_Camera>(); // If original NVR head has a camera component, set the camera for left VR eye Camera camLeft = Player.Head.GetComponent <Camera> (); if (camLeft) { camLeft.stereoTargetEye = StereoTargetEyeMask.Left; } //// End Integration for Holo with NVR ////// Player.Head.gameObject.AddComponent <SteamVR_TrackedObject>(); Player.gameObject.SetActive(true); SteamVR_Render[] steamvr_objects = GameObject.FindObjectsOfType <SteamVR_Render>(); for (int objectIndex = 0; objectIndex < steamvr_objects.Length; objectIndex++) { steamvr_objects[objectIndex].lockPhysicsUpdateRateToRenderFrequency = false; //this generally seems to break things :) Just make sure your Time -> Physics Timestep is set to 0.011 } }