본문 바로가기
개발/C#

유니티 C# 베터리 잔량 가져오기 Battery 간단 사용법

by SPNK 2022. 8. 25.
반응형
  • 코드 작성
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class Example : MonoBehaviour
{

    private void Start()
    {
        float number = SystemInfo.batteryLevel; // 베터리 충전량 가져오기 (0 ~ 1);

        Debug.Log(SystemInfo.batteryLevel);
        

        switch(SystemInfo.batteryStatus) //베터리 상태 가져오기
        {
            case BatteryStatus.Unknown:
                Debug.Log("충전 상태를 알 수 없음");
                break;

            case BatteryStatus.Discharging:
                Debug.Log("충전 케이블이 연결되지 않았고 충전도 되지 않는 상태");
                break;

            case BatteryStatus.NotCharging:
                Debug.Log("충전 케이블이 연결되었지만 충전이 되지 않는 상태");
                break;

            case BatteryStatus.Charging:
                Debug.Log("충전 케이블이 연결되어 있고 충전되고 있는 상태");
                break;

            case BatteryStatus.Full:
                Debug.Log("충전 케이블이 연결되어 있고 베터리가 가득찬 상태");
                break;
        }
    }
}

참고할만한 글

 

 

유니티 C# 가변 해상도 대응 Android , IOS 간단 구현

코드 작성 using System.Collections; using System.Collections.Generic; using UnityEngine; public class CameraResolution : MonoBehaviour { private void Start() { SetResolution(); } public void SetResolution() { int setWidth = 1080; int setHeight = 1920;

parksh3641.tistory.com

 

 

유니티 C# NGUI 가변 해상도 대응 IOS 간단 사용법

UIroot.cs 코드 변경 public void UpdateScale(bool updateAnchors = true) { if (mTrans != null) { float calcActiveHeight = activeHeight; if (calcActiveHeight > 0f) { float size = 2f / calcActiveHeight; Vector3 ls = mTrans.localScale; if (!(Mathf.Abs(ls.x

parksh3641.tistory.com

 

반응형

댓글