把该脚本直接拉给摄像机就OK了
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ShowNumber : MonoBehaviour {
private int tmp=10;
void Start()
{
//开启一个协程
StartCoroutine(“changeTime”);
}
void OnGUI ()
{
GUILayout.BeginArea(new Rect(100, 100, 300, 100));
GUILayout.Label("" + tmp, GUILayout.Width(300));
GUILayout.EndArea();
}
IEnumerator changeTime()
{
while(tmp > 0)
{
//暂停一秒
yield return new WaitForSeconds(1);
tmp–;
}
s();
}
private void s()
{
Debug.Log(“倒计时”);
}
}