I have a java-code for controlling the brightness of the screen, which works fine in Android Studio.

The method cited in the code below. The method accepts the integer value "value", which is then set as brightness.

public static int HardwareBrightnessSet (int value) { Activity activity = currentActivity; Context context = activity.getApplicationContext(); Settings.System.putInt(context.getContentResolver(),Settings.System.SCREEN_BRIGHTNESS,value); return value; } 

In Unity, I call the method like this:

  void SetBrightnessHardware(int value) { var androidPlugin = new AndroidJavaObject("vrcorp.com.brightness.BrightnessControl"); int _value = androidPlugin.Call<int>("HardwareBrightnessSet",200); _get.text = String.Format("Значение яркости экрана {0}", _value); } 

Unity does not react at all. At the same time, if in Android Studio I just get the data via "Settings.System.getInt, then everything is fine, the brightness value is displayed.

Apparently, something is not working when trying to transfer and install data.

However, there is no error. Just the text on which the method is hung does not react at all.

  • Try instead 'AndroidJavaObject' - 'AndroidJavaClass' and instead of 'androidPlugin.Call <int> ("HardwareBrightnessSet", 200)' - 'androidPlugin.CallStatic <int> ("HardwareBrightnessSet", new object [] {200})' - Xumera_hZ

0