공부/Unity

[Unity] 00:00으로 늘어나는 시간 표현하기

굴러다니다니 2025. 6. 2. 16:59
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PlayTme : MonoBehaviour
{
    [SerializeField] TMPro.TextMeshProUGUI m_timeText;
    void Update()
    {
        m_timeText.text = GetPlayTimeText();
    }
    public string GetPlayTimeText()
    {
        float playTime = Time.time; 
        int minutes = Mathf.FloorToInt(playTime / 60f);
        int seconds = Mathf.FloorToInt(playTime % 60f);
        return string.Format("{0:00}:{1:00}", minutes, seconds);
    }

}
728x90
반응형