Hi,
i would like to create an animated texture, i would like to create 15 planes, add a texture to each of them, and hide them one after the other to fake the animation. This code does not work because it says “NullReferenceException: Object reference not set to an instance of an object”, i have put 2 planes with a mesh renderer (set automatically) in an empty object named “AT”, then i created a script linked to the camera, or to the AT object (in this case, i changed “at” with “this” ) :
//private var at : GameObject;
private var renderers : Renderer[];
function Start () {
//at = GameObject.Find("AT");
//renderers = at.GetComponentsInChildren(Renderer);
//renderers = GetComponentsInChildren(Renderer);
renderers = this.GetComponentsInChildren(Renderer);
}
function Update () {
for (var r : Renderer in renderers) { /* NullReferenceException */
r.enabled = !r.enabled;
}
}
Would you know how to achieve this?
Thanks