Пишу прямо на сайте, могу ошибиться.
Я бы сделал как то так в шарпе. Изучайте корутины, с ними куда проще делать разные таймеры.
using UnityEngine;
public class Svetofor : MonoBehaviour
{
GameObject sphR;
GameObject sphY;
GameObject sphG;
Texture2D tex;
Texture2D tex2;
Texture2D[] textures;
void Start()
{
sphR = GameObject.Find("Object01");
sphY = GameObject.Find("Object03");
sphG = GameObject.Find("Object02");
tex = renderer.material.GetTexture ("");
tex2 = renderer.material.GetTexture ("");
StartCoroutine(Timer());
sphR.renderer.material.mainTexture = tex2;
}
IEnumerator Timer()
{
while(true)
{
yield return new WaitOfSecond(4);
sphY.renderer.material.mainTexture = tex2;
yield return new WaitOfSecond(1);
sphG.renderer.material.mainTexture = tex2;
sphY.renderer.material.mainTexture = tex;
sphR.renderer.material.mainTexture = tex;
yield return new WaitOfSecond(3);
if(textures.length != 0)
{
var index : int = Time.time / changeInterval;
index = index % textures.length;
sphG.renderer.material.mainTexture = textures[index];
}
yield return new WaitOfSecond(2);
sphG.renderer.material.mainTexture = tex;
sphR.renderer.material.mainTexture = tex2;
}
}
}