# \[ZED Mini\]\[Unity\] How to toggle depth occlusion at runtime?

**URL:** <https://community.stereolabs.com/t/zed-mini-unity-how-to-toggle-depth-occlusion-at-runtime/1670>\
**Category:** C#\
**Tags:** depth, unity\
**Created:** [October 18, 2022, 9:39am UTC](https://community.stereolabs.com/t/zed-mini-unity-how-to-toggle-depth-occlusion-at-runtime/1670 "2022-10-18T09:39:36Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![FeldNico](https://community.stereolabs.com/user_avatar/community.stereolabs.com/feldnico/32/782_2.png) [@FeldNico](https://community.stereolabs.com/u/FeldNico)\
**Post date:** [October 18, 2022, 9:39am UTC](https://community.stereolabs.com/t/zed-mini-unity-how-to-toggle-depth-occlusion-at-runtime/1670/1 "2022-10-18T09:39:36Z")

</div>

Hi,

I’m currently working on a project where the user can switch between AR and VR. Therefore, I would like to toggle the depth occlusion at runtime. If I click on the “Depth Occlusion” in the inspector while the application is running it works fine. However when I call `_zedManager.depthOcclusion = true/false`, nothing happens. The “Depth Occlusion” in the inspector does get ticked/unticked correctly. So somehow there is a difference between clicking the inspector and changing the value via code. Digging into the SDK Code did not reveal anything for me.

Can somebody help me?  
Thanks!

---

<div class="post-metadata">

**Author:** ![FeldNico](https://community.stereolabs.com/user_avatar/community.stereolabs.com/feldnico/32/782_2.png) [@FeldNico](https://community.stereolabs.com/u/FeldNico)\
**Post date:** [October 18, 2022, 9:48am UTC](https://community.stereolabs.com/t/zed-mini-unity-how-to-toggle-depth-occlusion-at-runtime/1670/2 "2022-10-18T09:48:19Z")

</div>

Okay nevermind…  
Just found the “OnValidate” method of the ZedManager Inspector. This led me to call `zedRenderingPlane.ManageKeywordPipe(!_zedManager.depthOcclusion, "NO_DEPTH");` on both RenderingPlanes immediately after changing the depthOcclusion at runtime.
