unity 控制安卓手機的亮度調節

直接上代碼,我試用了個scb.value; scroolbar 控制亮度的

///
/// 控制手機亮度
///
///
public void SetApplicationBrightnessTo(float Brightness)
{
Brightness = scb.value;
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);
}));
}

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章