I'm having trouble tracking down a problem with SteamVR. Here is a quick way to set up an MWE:
- Create a new Unity project.
- Import the SteamVR package from the Asset Store.
Create the following script:
using UnityEngine; public class CameraCreator : MonoBehaviour { private GameObject cameraObject; private void Start () { cameraObject = new GameObject("CameraObject"); cameraObject.AddComponent<Camera>(); cameraObject.transform.position = Vector3.one; } }
Create an empty game object and add this script to it.
SteamVR seems to lock this object's position (and that of any other game object with a dynamically created camera component) to the origin. No matter what I try to do to change it (inspector; set it inside update; set it in a coroutine), it always ends up back at the origin at some point during the frame (I believe somewhere between LateUpdate
and OnRenderObject
, but I'm not entirely sure). Without data breakpoints I find this really hard to track down.
This behaviour isn't really a problem for my actual project, but I need to be able to create cameras and modify their positions in my unit tests, where I'm having the same issue.
Does anyone know what's causing this, or have any advice on how to track down the cause?
stereoTargetEye
property of each camera object. See my answer for details. Thanks for looking into it though! \$\endgroup\$