Unity에서 제한 시간 3분을 추가하여 카운트다운하는 방법
OS 사용
Mac
본 문서에 사용된 Unity 버전
Version 2020.3.18f1
하고 싶은 일
메서드
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class TimeCounter : MonoBehaviour
{
public int countdownMinutes = 3;
private float countdownSeconds;
private Text timeText;
private void Start()
{
timeText = GetComponent<Text>();
countdownSeconds = countdownMinutes * 60;
}
void Update()
{
countdownSeconds -= Time.deltaTime;
var span = new TimeSpan(0, 0, (int)countdownSeconds);
timeText.text = span.ToString(@"mm\:ss");
if (countdownSeconds <= 0)
{
// 0秒になったときの処理
}
}
}
보태다
참고 자료
이것을 참고하게 해 주세요.감사합니다.
Reference
이 문제에 관하여(Unity에서 제한 시간 3분을 추가하여 카운트다운하는 방법), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://zenn.dev/fujimiya/articles/5775dd0824031d텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)