To support iOS/Android native features in Unity, this will provide variety functions. This package provide functions to retrive information about thermal.
Details
- Add a event handler for thermal status change.
- Start thermal status monitoring.
Below is an example.
private void StartThermalMonitoring()
{
#if UNITY_ANDROID
// OnBatteryTemperatureChanged is only available on Android
Thermal.OnBatteryTemperatureChanged += value => Debug.Log($"Battery Temperature: {value}");
#endif
#if UNITY_ANDROID || UNITY_IOS
Thermal.OnThermalStatusChanged += status => Debug.Log($"Thermal Status: {status}");
Thermal.StartMonitoring();
#endif
}If you want to stop monitoring, call Thermal.StopStopMonitoring()
On Android, Thermal.GetThermalHeadroom() is available to estimate CPU temperature.
Details: https://developer.android.com/reference/android/os/PowerManager#getThermalHeadroom(int)
private void GetThermalHeadroom()
{
Thermal.GetThermalHeadroom(0, out var headroom, out var resultForecastSeconds, out var isLatestValue);
}This library is compatible with the following environments.
- Unity 2019.4 or higher
To install the software, follow the steps below.
- Open the Package Manager from
Window > Package Manager "+" button > Add package from git URL- Enter the following
Or, open Packages/manifest.json and add the following to the dependencies block.
{
"dependencies": {
"jp.co.cyberagent.unity-mobile-support-thermal": "https://github.com/CyberAgentGameEntertainment/UnityMobileSupport.git?path=/Packages/MobileSupportThermal"
}
}If you want to set the target version, write as follows.
Note that if you get a message like No 'git' executable was found. Please install Git on your system and restart Unity, you will need to set up Git on your machine.
To update the version, rewrite the version as described above. If you don't want to specify a version, you can also update the version by editing the hash of this library in the package-lock.json file.
{
"dependencies": {
"jp.co.cyberagent.unity-mobile-support-thermal": {
"version": "https://github.com/CyberAgentGameEntertainment/UnityMobileSupport.git?path=/Packages/MobileSupportThermal",
"depth": 0,
"source": "git",
"dependencies": {},
"hash": "..."
}
}
}This software is released under the MIT license. You are free to use it within the scope of the license, but the following copyright and license notices are required.
