Domanda

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?

È stato utile?

Soluzione

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);
    }
}
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top