using System.Collections;
using System.Collections.Generic;
using UnityEngine;
在需要倒计时的时刻,记录当时的时间。
然后在update中一直取到现在的时间。现在的时间-当时的时间就是时间差。end-时间差就是倒计时的时间数字
public class Times : MonoBehaviour
{
// Start is called before the first frame update
public float miss;
float time1;
void Start()
{
time1 = Time.time;
}
void djs (float end)
{
float time2 = Time.time;
miss =end-(time2 - time1);
}
// Update is called once per frame
void Update()
{
djs(10);
}
private void OnGUI()
{
GUILayout.Label("秒数" + miss);
}
}