unity编写计时表(不使用UI)
1.关键代码 using System; using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI;
public class Test : MonoBehaviour { //毫秒 private float ms = 0f; //小时 private int h = 0; //分 private int m = 0; //秒 private int s = 0; //字符串 private string timeStr = string.Empty; void Update () { //累加游戏运行时间 timer += Time.deltaTime; //毫秒是0-1的小数,超过1,进位清零,重新计算 if (timer >= 1f) { s++;timer =
共有 0 条评论