| 12345678910111213141516171819202122232425262728293031323334353637383940 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.UI;
- using SmartBowSDK;
- public class GrassLandShootView : MonoBehaviour
- {
- [SerializeField] GameObject batteryProgress;
- void Start()
- {
-
- }
- float lastUpdateBatteryTime = 0;
- void Update()
- {
- if (Time.realtimeSinceStartup - lastUpdateBatteryTime > 2) {
- lastUpdateBatteryTime = Time.realtimeSinceStartup;
- if (SmartBowHelper.GetInstance().GetBluetoothStatus() == BluetoothStatusEnum.Connected) {
- int battery = SmartBowHelper.GetInstance().GetBattery();
- if (battery > 0) {
- Text text = batteryProgress.transform.Find("Value").GetComponent<Text>();
- text.text = battery + "%";
- Image bar = batteryProgress.transform.Find("Bar").GetComponent<Image>();
- bar.fillAmount = battery / 100f;
- batteryProgress.SetActive(true);
- }
- } else {
- batteryProgress.SetActive(false);
- }
- }
- }
- public void OnClick_Close() {
- AudioMgr.ins.PlayBtn();
- Application.Quit();
- }
- }
|