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 the code and it shows errors. Like:
error CS0619:
UnityEngine.Component.renderer' is obsolete:
Property renderer has been deprecated. Use GetComponent() instead. (UnityUpgradable)'error CS1061: Type
UnityEngine.Component' does not contain a definition for
material' and no extension methodmaterial' of type
UnityEngine.Component' could be found (are you missing a using directive or an assembly reference?)
Also the script is this.
using UnityEngine;
using System.Collections;
public class Colors : MonoBehaviour
{
public float timer = 0.0f;
void Start()
{
}
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
renderer.material.color = newColor;
timer = 0;
}
}
}