Hololens 2 Multi-Camera

Bahadır ÇAKAR 21 Reputation points

Hi there,

I would like to know how can I set up a multi-camera on MRTK on Unity 2020.3? When I copy the main camera and set up a switched button to change the cameras it worked. However, the second camera scene is stable like a monitor screen, it's not moving according to my moving.

HoloLens Development
HoloLens Development
HoloLens: A family of Microsoft self-contained, holographic devices that enable engagement with digital content and interaction with holograms in the surrounding environment.Development: The process of researching, productizing, and refining new or existing technologies.
277 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Seth DU - MSFT 536 Reputation points Microsoft Employee

    Hello, welcome to Microsoft Q&A,

    I am not sure of the scenario, but if you simply want to switch different views within the same Unity Scene:

    Your position (headset position) is the main camera. If you didn’t attach any script to the second camera, it will keep still. I am not sure of your scenario, if it is required to display views in other cameras on time, you need to create additional cameras and targeting to a customized Render Texture, which should be attached on an object you want to display.
    Meanwhile, if it only switches between different views, simply store those transforms of that point Clicking the switching button simply change the transform of Main Camera. Please note that the main camera transform only reflects the position from hardware, so that directly changing transform won’t work. You need to use MixedRealityPlayspace.Transform.Translate() to modify the position.

    Meanwhile, if your requirement is switching camera between different Unity Scenes:

    May I ask which mode you choose when you load the scene? To be clear, Unity will use Single load mode by default, while in MRTK, MixedRealityToolkit and MixedRealityPlaySpace should be unique and in a scene that is never unloaded. There are 2 suggestions that may help you solve this issue.

    • If insisting on using Single mode. You need to add DontDestroyOnLoad() calls for MixedRealityToolkit and MixedRealityPlaySpace and make sure they won't be destroyed when loading the new scene. MixedRealityPlaySpace, MixedRealityToolkit in new scene will be automatically set Inactive and you can manually choose the active MRTK at any time.
    • Using Additive load mode. This won't destroy objects in the previous scene, but all objects will be contained in the same scene. Feel free to add codes to set inactive.

    Besides manually setting up scene loading behavior, it is also recommended to use the official Scene System. Please refer to https://learn.microsoft.com/en-us/windows/mixed-reality/mrtk-unity/features/scene-system/scene-system-getting-started?view=mrtkunity-2021-05.


    If the response is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.