gpt4 book ai didi

c# - 如何使用 C# 和 Unity 知道设备是否已插入

转载 作者:行者123 更新时间:2023-12-02 15:01:29 25 4
gpt4 key购买 nike

我正在制作游戏,想知道:如何在 Unity 中使用 C# 纯代码知道 Android 设备是否已插入(即电池正在充电)?

最佳答案

设备已插入:

SystemInfo.batteryStatus == BatteryStatus.Charging || SystemInfo.batteryStatus == BatteryStatus.Full || SystemInfo.batteryStatus == BatteryStatus.NotCharging

电池正在充电:

SystemInfo.batteryStatus == BatteryStatus.Charging

来源:

https://docs.unity3d.com/ScriptReference/SystemInfo-batteryStatus.html

Returns the current status of the device's battery (Read Only).

See the BatteryStatus enumeration for possible values.

The battery status includes information about whether the device is plugged in to a power source and whether the battery is charging. If battery status is not available on your target platform, this property returns BatteryStatus.Unknown.

https://docs.unity3d.com/ScriptReference/BatteryStatus.html

  • 未知 无法确定设备的电池状态。如果电池状态在您的目标平台上不可用,SystemInfo.batteryStatus 将返回此值。

  • 充电设备已插入并正在充电。

  • Discharge Device 已拔下并正在放电。

  • NotCharging 设备已插入,但未充电。

  • 完整设备已插入且电池已充满。

关于c# - 如何使用 C# 和 Unity 知道设备是否已插入,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49323785/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com