Unity 在JS中间隔时间调用方法

 

 

 

var text2d:Texture2D[];//放图片的数组
private static var i:int=0;
public var TheTime:float=0.1;播放图片的间隔
InvokeRepeating("test",0,TheTime);
function Update () {
}
function OnGUI(){
        GUI.Label(Rect(10,10,10,10),text2d[i]);
}
function test(){
        if(i<text2d.length-1){
                 i++;
        }
        else{
                 i=0;
        }
}


接受博友的意件!
方法二:
// Launches a projectile in 2 seconds
var projectile : Rigidbody;
Invoke("LaunchProjectile", 2);
function LaunchProjectile () {
instance = Instantiate(prefab);
instance.velocity = Random.insideUnitSphere * 5;
}
每隔2秒时间调用方法LaunchProjectile

 

 

 

 

你可能感兴趣的:(function,float)