Hi!
This script makes a sequence of texture, to create an effect of lights.
My question is, at the start I would like that there was a “specific texture” (that simulates the light off) and I would like create an input, so if I press a key, the animation starts, and if I press the same or another key, return to the “specific texture” at the start (to simulate the light animation off)
This is the script, how can I do this?
Thank you in advance
using UnityEngine;
using System.Collections;
public class LightAnimator : MonoBehaviour
{
public float speed;
public Material material;
public Texture[] textures;
float frameTime;
void Update()
{
int numTextures = textures.Length;
if (numTextures == 0)
return;
frameTime += Time.deltaTime * speed;
material.mainTexture = textures[(int)Mathf.Abs(frameTime) % numTextures];
material.SetTexture("_Illum", textures[(int)Mathf.Abs(frameTime) % numTextures]);
}
}