建一个GUI并将代码拖上去即可
//个人原创,转载请声明转载自 http://www.cnblogs.com/suxsho
//计时器 var hour : int = 12; //时 var min : int = 30; //分 var sec : int = 0; //秒 //固定记时 var timeRate : float = 0.01; //修改时间 private var nextTime : float = 1.0; //这个不动 function Update () { guiText.text = hour.ToString()+":"+min.ToString()+":"+sec.ToString(); time(); } function time () { //记时 if (Time.time > nextTime) { nextTime = Time.time + timeRate; sec ++; } //分钟计算 if (sec >= 60) { sec = 0; min ++; } if (min >= 60) { min = 0; hour ++; } if (hour >= 24) { hour = 0; } }