The inability to see power and WiFi signals in mobile games is a problem for gamers. There are different ways for Android and iOS to do this.Power AndroidThere are two ways to get power on Android, one is to read a file on an Android phone, and it's convenient to use Android to send messages to unity, but we don't guarantee that the vendor will change the file to another location and we won't be reading it.
Reference: Http://www.cnblogs.com/BobbyWeaver/p/5118118.html read the files in the Android phone, the code is as follows:
int Getbatterylevel () { try { string capacitystring = System.IO.File.ReadAllText ("/sys/class/power _supply/battery/capacity "); return int. Parse (capacitystring); } catch (Exception e) { Debug.Log ("Failed to read battery power;" + e.message); } return-1; } }
The way you interact with Android, it's not just about getting power, WiFi, controlling phone shake, restarting, calling third-party apps, and so on. Android features reference: http://www.cnblogs.com/wuzhang/p/wuzhang20170318.htmlIOSA workaround on the forum is to use a. mm file to write a method to get iOS power using the same way as iOS, and the pro-Test available reference: https://forum.unity3d.com/threads/ Display-battery-level-in-game.67804/the method for calling the iOS library can be consulted: http://blog.sina.com.cn/s/blog_923fdd9b0102v2a8.htmlWiFiMethod an Android and iOS both use the above platform to interact with Unity method method two clients and the server sends the heartbeat packet the way to simulate.by:wolf96 2017/7/8
Unity3d mobile power and WiFi signal acquisition