-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Closed
Labels
By DesignThe behavior reported in the issue is actually correctThe behavior reported in the issue is actually correctCameraSystemStale
Description
Describe the bug
In the Microsoft.MixedReality.Toolkit.Utilities.CameraCache there is a loophole to fall through, if cachedCamera and Camera.main are both null.
The code reads (l. 36, ff.):
if (mainCamera == null)
{
Debug.Log("No main camera found. Searching for cameras in the scene.");
// If no main camera was found, try to determine one.
Camera[] cameras = GameObject.FindObjectsOfType<Camera>();
if (cameras.Length == 0)
{
Debug.LogWarning("No cameras found. Creating a \"MainCamera\".");
mainCamera = new GameObject("Main Camera", typeof(Camera), typeof(AudioListener)) { tag = "MainCamera" }.GetComponent<Camera>();
}
else
{
Debug.LogWarning("The Mixed Reality Toolkit requires one camera in the scene to be tagged as \"MainCamera\". Please ensure the application's main camera is tagged.");
}
}
So if Cameras are found, they are never assigned to the cameraCache.
To reproduce
Steps to reproduce the behavior:
- Create an app with no MRTK Profile assigned to the MRTK
- Assign an MRTK profile during runtime
--> Observe that CameraCache.Main returns null
--> Observe that it can never access the cameras found in the scene
Expected behavior
The MRTK can be assigned a profile and initialized AFTER preparing the scene
Your setup (please complete the following information)
- Unity Version [e.g. 2019.4.21f1]
- MRTK Version [e.g. v2.5.4]
Target platform (please complete the following information)
- HoloLens
- HoloLens 2
- Unity Editor
Additional context
Add any other context about the problem here.
I solved this by changing the CameraCache.cs script. But of course, I would rather not change scripts from the MRTK package
Metadata
Metadata
Assignees
Labels
By DesignThe behavior reported in the issue is actually correctThe behavior reported in the issue is actually correctCameraSystemStale