유니티의 여러가지 시간 측정 방법중 한가지인 스탑워치 사용하기에 대한 방법이다.

using System.Diagnostics;
using debug = UnityEngine.Debug;
public class TimerScript : MonoBehaviour {

Stopwatch sw = new Stopwatch();
float time;

    void Start(){
        sw.Start();
    }

    void Update(){
        time = sw.ElapsedMilliseconds;
        if(time>5000){
            sw.Stop();
            debug.Log("Time: "+time);
        }
    }




+ Recent posts