Unity's countdown

1. There are two times, one is the time that has been called, the other is the current time minus a number and rounded to the whole time
2. Set the time you want to count down
3. Create the text, the text content should change the number type Into character type

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class daojishi : MonoBehaviour
{
    
    
    public double a, b;
     public Text shijian;
 void Update()
    {
    
    
        a = Time.fixedTime;
        double b = 20 - (a - 0.49);//值为19.多
        b = (int)b;/只取整数部分
        shijian.text ="倒计时:"+ b.ToString();/将数字转化为字符类型
    }

Guess you like

Origin blog.csdn.net/qq_46289420/article/details/109278863