I have been looking for a way to detect if window night light mode is on in unity3d using c# but have been unable to find that would work in unity. I have found a post with a similar question here, however this doesn't work with unity and have given me this error when I tried using it in unity.See Here. I have tried switching registry out for System.Environment.UserName. This produced another new error.See Error 2 here. If someone knows how to solve this issue I would be glad if you helped. Heres an example of the code that unity is refusing:
private static bool IsNightLightEnabled()
{
const string BlueLightReductionStateKey = @"SOFTWARE\Microsoft\Windows\CurrentVersion\CloudStore\Store\DefaultAccount\Current\default$windows.data.bluelightreduction.bluelightreductionstate\windows.data.bluelightreduction.bluelightreductionstate";
using (var key = Environment.UserName.OpenSubKey(BlueLightReductionStateKey))
{
//this doesn't matter
}
}
and
private static bool IsNightLightEnabled()
{
const string BlueLightReductionStateKey = @"SOFTWARE\Microsoft\Windows\CurrentVersion\CloudStore\Store\DefaultAccount\Current\default$windows.data.bluelightreduction.bluelightreductionstate\windows.data.bluelightreduction.bluelightreductionstate";
using (var key = Registry.OpenSubKey(BlueLightReductionStateKey))
{
//this doesn't matter
}
}
To get the errors I'm encountering paste these into a c# script and put into a unity project assets.