question

BahadrAKAR-0421 avatar image
0 Votes"
BahadrAKAR-0421 asked BahadrAKAR-0421 commented

Hololens 2 Multi-Camera

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
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

SethDu-MSFT avatar image
0 Votes"
SethDu-MSFT answered BahadrAKAR-0421 commented

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://docs.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.

· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Thank you for answering. Yes, I need to switch different views within the same Unity Scene

Could you provide more inf about MixedRealityPlayspace.Transform.Translate() ? I googled it. However, cannot find a proper source

Thank you,

0 Votes 0 ·

Basically, this function needs a Vector3 to relocate the headset's position. It simply works like:

 MixedRealityPlayspace.Transform.Translate(new Vector3(1,1,1));

You may add this code to an On-Click event function, to switch views. This function is more common when using a controller to move the player.






0 Votes 0 ·