unity 设置Android 亮度

        public void SetApplicationBrightnessTo()
        {
#if UNITY_ANDROID && (!UNITY_EDITOR)
        AndroidJavaObject Activity = null;
        Activity = new AndroidJavaClass("com.unity3d.player.UnityPlayer").GetStatic("currentActivity");
        Activity.Call("runOnUiThread", new AndroidJavaRunnable(() => {
                AndroidJavaObject Window = null, Attributes = null;
                Window = Activity.Call("getWindow");
                Attributes = Window.Call("getAttributes"); 
                Attributes.Set("screenBrightness", Brightness); 
                Window.Call("setAttributes", Attributes); 
                })); 
#endif

        }

        public void GetApplicationBrightnessTo()
        {
        float num = -1;
#if UNITY_ANDROID && (!UNITY_EDITOR)
        AndroidJavaObject Activity = null;
        Activity = new AndroidJavaClass("com.unity3d.player.UnityPlayer").GetStatic("currentActivity");
        Activity.Call("runOnUiThread", new AndroidJavaRunnable(() => {
                AndroidJavaObject Window = null, Attributes = null;
                Window = Activity.Call("getWindow");
                Attributes = Window.Call("getAttributes"); 
                num = Attributes.Get("screenBrightness"); 
                })); 
#endif
        }

你可能感兴趣的:(unity 设置Android 亮度)