Hi guys, I made a short script to change the texture on the scene, but would like the others to take a look on it to improve it, any hint is welcome.
Script:
#pragma strict
var texture : Texture2D[];
var minWait : int;
var maxWait : int;
private var time : int;
private var nextTime : int;
function Start () {
newNextTime();
if (minWait <= 0) minWait = 2;
if (maxWait <= 1) maxWait = 10;
}
function Update () {
if (time >= nextTime) {
if (texture.Length != 0) {
renderer.material.mainTexture = texture[Random.Range( 0, texture.Length)];
newNextTime();
}
}
time = Time.time;
}
function newNextTime () {
nextTime = time + Random.Range(minWait, maxWait);
}
Thanks in advance.