Created
June 26, 2021 01:26
-
-
Save Isshi-777/f790db63a233de09a9f194d2112f82dd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
namespace Isshi777 | |
{ | |
/// <summary> | |
/// バッテリーの関連クラス | |
/// </summary> | |
public static class BatteryUtility | |
{ | |
/// <summary> | |
/// バッテリーの残量と状態を返す | |
/// </summary> | |
/// <returns>(残量, 状態)</returns> | |
public static (float, BatteryStatus) GetBatteryDetail() | |
{ | |
return (GetBatteryLevel(), GetBatteryStatus()); | |
} | |
/// <summary> | |
/// バッテリーの残量を返す | |
/// </summary> | |
/// <returns>バッテリー残量</returns> | |
public static float GetBatteryLevel() | |
{ | |
return SystemInfo.batteryLevel; | |
} | |
/// <summary> | |
/// バッテリーの状態を返す | |
/// | |
/// <para>Charging : 充電中</para> | |
/// <para>Discharging : 放電中</para> | |
/// <para>NotCharging : 充電していない</para> | |
/// <para>Full : 満タン</para> | |
/// </summary> | |
/// <returns>バッテリー状態</returns> | |
public static BatteryStatus GetBatteryStatus() | |
{ | |
return SystemInfo.batteryStatus; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment