Zůžil jsem to na jeden kód. Ten má funkce, že po kliknutí na klávesu X se začnou po 1 vteřině střídat obrázky. Jenomže když zmáčknu klávesu X třeba 10x, tak se spustí ten script 10x najednou a lítá jeden obrázek přes druhej. Potřeboval bych přidat funkci aby se po stisknutí X pokud je script spuštěnej, tak aby se zastavil a spustil odzačátku. Aby běžel jenom jednou odznova.
var texture1 : Texture2D;
var texture2 : Texture2D;
var texture3 : Texture2D;
var texture4 : Texture2D;
var texture5 : Texture2D;
var texture6 : Texture2D;
function Update() {
if (Input.GetKey(KeyCode.X))
{
RenderSometing();
}
}
function RenderSometing() {
yield WaitForSeconds(1);
renderer.material.mainTexture = texture1;
yield WaitForSeconds(1);
renderer.material.mainTexture = texture2;
yield WaitForSeconds(1);
renderer.material.mainTexture = texture3;
yield WaitForSeconds(1);
renderer.material.mainTexture = texture4;
yield WaitForSeconds(1);
renderer.material.mainTexture = texture5;
yield WaitForSeconds(1);
renderer.material.mainTexture = texture6;
}