首页 > 其他 > 详细

实现倒计时功能

时间:2019-09-29 09:52:03      阅读:98      评论:0      收藏:0      [点我收藏+]

新建文本,实现倒计时功能

 

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class Test : MonoBehaviour {

    public Text timeText;
    private float gameTime = 60;
    private bool gameOver;
    
    // Update is called once per frame
    void Update () {
        if (gameOver)
        {
            return;
        }
        gameTime -= Time.deltaTime;
        if (gameTime<=0)
        {
            gameTime = 0;
            //
            gameOver = true;
            return;
        }
      
        timeText.text = gameTime.ToString("0");
    }
}

 

实现倒计时功能

原文:https://www.cnblogs.com/dream-seeker-201907/p/11605998.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!