我的代码现在是这样,30秒的倒计时,30秒后 就开始-1,-2,-3游戏还在继续 没有结束
想问一下 这种情况怎么处理
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class countdown : MonoBehaviour
{
public float timeStart = 30;
public Text textBox;
bool timerActive = false;
// Start is called before the first frame update
void Start()
{
textBox.text = timeStart.ToString();
}
// Update is called once per frame
void Update()
{
if (timerActive) {
timeStart -= Time.deltaTime;
textBox.text = Mathf.Round(timeStart).ToString();
}
}
public void startBtn()
{
timerActive = !timerActive;
}
}