I\'m having script errors. But first what I\'m doing.
I\'m making my text colorful, the system should look like this. Every second, new differet color. But I scripted th
You can no longer access renderer.material.color
directly anymore starting from Unity 5 up. you must use GetComponent<Renderer>();
to get the component of the GameObject first, then you can access the material from the Renderer
.
public float timer = 0.0f;
Renderer rd;
void Start()
{
rd = gameObject.GetComponent<Renderer>();
}
void Update()
{
timer += Time.deltaTime;
if (timer >= 2.0f)//change the float value here to change how long it takes to switch.
{
// pick a random color
Color newColor = new Color(Random.value, Random.value, Random.value, 1.0f);
// apply it on current object's material
rd.material.color = newColor;
timer = 0;
}
}