# Read and write global dimming OS values from within the app

**URL:** <https://forum.magicleap.cloud/t/read-and-write-global-dimming-os-values-from-within-the-app/4227>\
**Category:** Unity Development\
**Tags:** global-dimmer\
**Created:** [September 14, 2024, 8:50am UTC](https://forum.magicleap.cloud/t/read-and-write-global-dimming-os-values-from-within-the-app/4227 "2024-09-14T08:50:30Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![rafal.legiedz](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.magicleap.cloud/rafal.legiedz/32/654_2.png) [@rafal.legiedz](https://forum.magicleap.cloud/u/rafal.legiedz)\
**Post date:** [September 14, 2024, 8:50am UTC](https://forum.magicleap.cloud/t/read-and-write-global-dimming-os-values-from-within-the-app/4227/1 "2024-09-14T08:50:30Z")

</div>

We're trying to modify and persist Global Dimmer values from within our app, such as:

1. We'd like to be able to read the value of Global Dimmer (that was set in OS) on the application startup
2. We'd like to manipulate that value from within the app and persist so that even when user leaves the app, the Global Dimmer value would be reflected within OS

We're using `MLGlobalDimmer.SetValue()` at the moment but it only gives us possibility to set Global Dimming while within the app, without possibilities to persist the value within OS.

We tried using

`var renderFeature = OpenXRSettings.Instance.GetFeature<MagicLeapRenderingExtensionsFeature>();`

and reading the value of `renderFeature.GlobalDimmerValue` during the application startup, but it always gives `0`, no matter what value we'd set in the OS for the Global Dimmer.

Is there a way to achieve what I stated in the above points 1 and 2 with the API available?

---

<div class="post-metadata">

**Author:** ![etucker](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.magicleap.cloud/etucker/32/842_2.png) [@etucker](https://forum.magicleap.cloud/u/etucker)\
**Post date:** [September 16, 2024, 4:57pm UTC](https://forum.magicleap.cloud/t/read-and-write-global-dimming-os-values-from-within-the-app/4227/2 "2024-09-16T16:57:16Z")

</div>

Hi @rafal.legiedz,

I have reached out to our team regarding this issue and I will report back as soon as I learn more.

---

<div class="post-metadata">

**Author:** ![etucker](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.magicleap.cloud/etucker/32/842_2.png) [@etucker](https://forum.magicleap.cloud/u/etucker)\
**Post date:** [September 16, 2024, 5:04pm UTC](https://forum.magicleap.cloud/t/read-and-write-global-dimming-os-values-from-within-the-app/4227/4 "2024-09-16T17:04:57Z")

</div>

Also, just to make sure please confirm you have Magic Leap 2 Rendering Extensions checked in the OpenXR settings.

---

<div class="post-metadata">

**Author:** ![rafal.legiedz](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.magicleap.cloud/rafal.legiedz/32/654_2.png) [@rafal.legiedz](https://forum.magicleap.cloud/u/rafal.legiedz)\
**Post date:** [September 17, 2024, 4:50am UTC](https://forum.magicleap.cloud/t/read-and-write-global-dimming-os-values-from-within-the-app/4227/5 "2024-09-17T04:50:12Z")

</div>

Thank @etucker for chiming in. I have the following checked:

 ![image](https://us1.discourse-cdn.com/flex019/uploads/magicleap1/original/2X/c/c799e0b59ed37b0f04de8a9a632b33a9c5011f0c.png)

And still:

`renderFeature = OpenXRSettings.Instance.GetFeature<MagicLeapRenderingExtensionsFeature>();` gives me 0 for `renderFeature.GlobalDimmerValue`

---

<div class="post-metadata">

**Author:** ![kbabilinski](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.magicleap.cloud/kbabilinski/32/19_2.png) [@kbabilinski](https://forum.magicleap.cloud/u/kbabilinski)\
**Post date:** [September 17, 2024, 3:34pm UTC](https://forum.magicleap.cloud/t/read-and-write-global-dimming-os-values-from-within-the-app/4227/6 "2024-09-17T15:34:56Z")

</div>

Question regarding your application, are you using the OpenXR loader from the XR Plugin Management settings?

Are you setting the Global dimmer value using the OpenXR APIs as well?

> **[Global Dimming | MagicLeap Developer Documentation](https://developer-docs.magicleap.cloud/docs/guides/unity-openxr/rendering-extensions/global-dimmer/global-dimmer-example/)**
>
> Learn how to use the Magic Leap 2's unique global dimming technology.

---

<div class="post-metadata">

**Author:** ![rafal.legiedz](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.magicleap.cloud/rafal.legiedz/32/654_2.png) [@rafal.legiedz](https://forum.magicleap.cloud/u/rafal.legiedz)\
**Post date:** [September 17, 2024, 4:26pm UTC](https://forum.magicleap.cloud/t/read-and-write-global-dimming-os-values-from-within-the-app/4227/7 "2024-09-17T16:26:06Z")

</div>

I guess you mean this:

 ![image](https://us1.discourse-cdn.com/flex019/uploads/magicleap1/original/2X/a/af43f439709b37981cf262fd643ae5efd34f04e6.png)

Then I think not. Shall I try with it on?

---

<div class="post-metadata">

**Author:** ![kbabilinski](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.magicleap.cloud/kbabilinski/32/19_2.png) [@kbabilinski](https://forum.magicleap.cloud/u/kbabilinski)\
**Post date:** [September 17, 2024, 4:43pm UTC](https://forum.magicleap.cloud/t/read-and-write-global-dimming-os-values-from-within-the-app/4227/8 "2024-09-17T16:43:58Z")

</div>

Correct, you will need to use the OpenXR loader to use the OpenXR APIs. Currently the MLSDK does not provide a way to read the global dimming value.

Note, you will need to migrate your project to OpenXR from MLSDK XR.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex019/uploads/magicleap1/original/1X/bd9b737a4d45ea243aa7eb177d60a773b806899a.svg) [@system](https://forum.magicleap.cloud/u/system)\
**Post date:** [October 1, 2024, 4:44pm UTC](https://forum.magicleap.cloud/t/read-and-write-global-dimming-os-values-from-within-the-app/4227/9 "2024-10-01T16:44:05Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
