문제

I have no idea how to come at this. In Python I could probably do it but I'm not that good with UnityScript. I was thinking something like this in Python:

import time 
for i in range(time):
    if(condition == True):
      #do this
    else:
       #do this
    time.sleep(1)

How would I come about doing this in UnityScript?

도움이 되었습니까?

해결책

With a normal JavaScript implementation I would suggest using setTimeout(), but the Unity documentation suggests using Invoke() (see the docs).

function doStuff() {
    if(condition == true) {
      ...
    }
    else {
        Invoke('doStuff', 1);
    }
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top