Someone knows how to turn On/Off android display backlight using C# only in Unity? I don’t like plugins, and I don’t want to make one of my own. I know that you can disable the display while using the proximity sensor… but i don’t know how to do it in C# in Unity3d…
Maybe the android.provider.Settings.System.SCREEN_BRIGHTNESS will help but i don’t know how to change the value (1-255) in Unity3d with C# If someone have a solution i would be very happy. thank you
here is my code… but it doesn’t work as expected… also i like to know how to set the SCREEN_BRIGHTNESS using C# and Unity… if someone has a working example script or know how to change this… plz help out… many many thx M.
public void CheckScreenBrightness()
{
using (var actClass = new AndroidJavaClass("com.unity3d.player.UnityPlayer"))
{
var context = actClass.GetStatic<AndroidJavaObject>("SCREEN_BRIGHTNESS");
AndroidJavaClass systemSetting = new AndroidJavaClass("android.provider.Settings$System");
var screenbrightness = systemSetting.CallStatic<int>("getInt", context.Call<AndroidJavaObject>("getContentResolver"), "SCREEN_BRIGHTNESS");
Debug.Log("Screen Brightness = " + screenbrightness);
}
}