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

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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