Visual Masking Bug
Visual Masking Bug
This bug involves masking game objects within a unity canvas. Masking a child object of a panel while all being inside a canvas doesn't work on the physical device correctly. To elaborate, the simulator works as expected masking the child object, but when ran on the actual device, the user doesn't see the mask in effect. Now for the confusing part, when you are running on the physical device, take a screenshot I used speak recognition via saying "Cortana, take a picture". You will see that the screenshot shows the mask working correctly.
To reproduce
I have a pre-baked unity project here I highly recommend to use because there is a lot of setup required, check src/
Steps to reproduce the behavior:
- Create a Unity Project, I am using version
2020.3.13f1 - Use the MRTK Tool to install packages
2.7.2.0- com.microsoft.mixedreality.openxr
- com.microsoft.mixedreality.toolkit.foundation (this installs com.microsoft.mixedreality.toolkit.standardassets as a dep)
- Configure to use
OpenXRand Add theMRTKconfiguration to your scene - Add a
GameObjectunder theMixedRealitySceneContentand name it MainWindow- Add this script to the MainWindow. This
ViewFollowerscript makes the game object follow our camera.
Adding a MeshFilterand aMeshRendererare just to make visualizing the location of the MainWindow easier.
- Add a child of type
Canvasto the MainWindow and resize / position it to appear properly sized in front of the camera. Make it's positioning is set toWorld Space.

- Add a child of type
Panelto theCanvasand add theMaskcomponent to the newly addedPanel. Make sure to set theSource Imageof the mask to some shape.

- Add a child of type
Raw Imageto thePanelyou just added. ThisRaw Imagewill be what our mask is masking or cropping.
As you can see I have set Colorto red for example and theSource Imageto theKnobshape which is a circle. So essentially we have a circle of red that will be masked to the shape set in the parentPanel'sMaskcomponent'sSource Imageproperty. As seen below:
Now the masking can be tested on the HoloLens 2.
- Add this script to the MainWindow. This
Expected behavior
Using a Panel with a Mask component inside a Canvas will mask children of that Panel.
Screenshots
Using Camera Screenshot

Recreation of what I (the user) sees

My Setup
- Unity Version
2020.3.13f1 - MRTK Version
2.7.2.0If I missed anything let me know, otherwise, the repo might have what I missed.
Target Platform(s)
- HoloLens 2
I have a similar issue. We use the same setup, but as soon we use Unity UI components either taking "screenshots" or while recording videos. The Unity UI components won't be rendered in video/photo although we can see them on the physical device.
I have a similar issue. We use the same setup, but as soon we use Unity UI components either taking "screenshots" or while recording videos. The Unity UI components won't be rendered in video/photo although we can see them on the physical device.
Sounds like you are having the opposite issue of what I am experiencing no? For I, being the user wearing the physical device I cannot see the mask correctly, whereas the camera does... Interesting this is.
-- Edit I just discovered that a video I was watching on the HoloLens 2 that had black bars on either side because of it's width where invisible when watching through the HoloLens 2. I took a video, of the video on the HoloLens 2 and the black bars show up in the recording. Therefore, I wonder if you could use black rectangles (any shape for that matter) to mask things as a hacky work around?
I have a similar issue. We use the same setup, but as soon we use Unity UI components either taking "screenshots" or while recording videos. The Unity UI components won't be rendered in video/photo although we can see them on the physical device.
Sounds like you are having the opposite issue of what I am experiencing no? For I, being the user wearing the physical device I cannot see the mask correctly, whereas the camera does... Interesting this is.
-- Edit I just discovered that a video I was watching on the HoloLens 2 that had black bars on either side because of it's width where invisible when watching through the HoloLens 2. I took a video, of the video on the HoloLens 2 and the black bars show up in the recording. Therefore, I wonder if you could use black rectangles (any shape for that matter) to mask things as a hacky work around?
Thanks for the answer. I think you're right, our issue is not the masking but actually the components not showing in the video.
Therefore I don't think using the black bar would work.
Hi @Chase-William thank you for submitting this beautifully detailed visual masking bug, and creating the supporting reproduction Unity Project repository! I will investigate this issue, and then it will get sorted out.
@Spoon2311 Thank you for the additional insight that you have provided on this issue. It will save me some time during the investigation!
This issue has been marked as stale by an automated process because it has not had any recent activity. It will be automatically closed in 30 days if no further activity occurs. If this is still an issue please add a new comment with more recent details and repro steps.
We appreciate your feedback and thank you for reporting this issue.
Microsoft Mixed Reality Toolkit version 2 (MRTK2) is currently in limited support. This means that Microsoft is only fixing high priority security issues. Unfortunately, this issue does not meet the necessary priority and will be closed. If you strongly feel that this issue deserves more attention, please open a new issue and explain why it is important.
Microsoft recommends that all new HoloLens 2 Unity applications use MRTK3 instead of MRTK2.
Please note that MRTK3 was released in August 2023. It features an all new architecture for developing rich mixed reality experiences and has a minimum requirement of Unity 2021.3 LTS. For more information about MRTK3, please visithttps://www.mixedrealitytoolkit.org.
Thank you for your continued support of the Mixed Reality Toolkit!