Синтаксис:
Используется csharp
using UnityEngine;
using System.Collections;
public class ScorePrint : MonoBehaviour
{
int hour, min, sec;
string h,m,s,leveltype="Normal Level";
void Start ()
{
RunScore ();
}
void RunScore ()
{
StartCoroutine (RepeatingFunction ());
}
IEnumerator RepeatingFunction ()
{
while (true) {
TimeCount ();
yield return new WaitForSeconds(1);
}
}
void TimeCount ()
{
if (sec > 59) {
sec = 0;
min++;
}
if (min > 59) {
min = 0;
hour++;
}
if (hour > 23) {
hour = 0;
}
if (sec<10) s="0"+sec; else s=sec.ToString();
if (min<10) m="0"+min; else m=min.ToString();
if (hour<10) h="0"+hour; else h=hour.ToString();
UILabel c = GameObject.Find("ScoreLabel").GetComponent<UILabel>();
c.text=leveltype+" Time:"+h+":" + m + ":" + s;
sec++;
}
}
using System.Collections;
public class ScorePrint : MonoBehaviour
{
int hour, min, sec;
string h,m,s,leveltype="Normal Level";
void Start ()
{
RunScore ();
}
void RunScore ()
{
StartCoroutine (RepeatingFunction ());
}
IEnumerator RepeatingFunction ()
{
while (true) {
TimeCount ();
yield return new WaitForSeconds(1);
}
}
void TimeCount ()
{
if (sec > 59) {
sec = 0;
min++;
}
if (min > 59) {
min = 0;
hour++;
}
if (hour > 23) {
hour = 0;
}
if (sec<10) s="0"+sec; else s=sec.ToString();
if (min<10) m="0"+min; else m=min.ToString();
if (hour<10) h="0"+hour; else h=hour.ToString();
UILabel c = GameObject.Find("ScoreLabel").GetComponent<UILabel>();
c.text=leveltype+" Time:"+h+":" + m + ":" + s;
sec++;
}
}