Hi,
I wanto add car indicators to my game. After click any button indicator should turned on.
Is it good to do animation attached to gameobject with indicator immage or script with mask?
How to make coroutine which waiting for button press?
I made something like this:
private Mask mask;
private IEnumerator coroutine;
public bool keyPressed = false;
public KeyCode key;
void Start () {
coroutine = TurnON();
mask = GetComponent<Mask>();
}
IEnumerator TurnON()
{
while (true)
{
Hide_Grtaphics();
yield return new WaitForSeconds(0.5f);
Show_Grtaphics();
yield return new WaitForSeconds(0.5f);
}
}
void Update () {
if (Input.GetKeyDown(key))
{
keyPressed = !keyPressed;
if (keyPressed)
StartCoroutine(coroutine);
else
{
StopCoroutine(coroutine);
Show_Grtaphics();
}
}
}
private void Show_Grtaphics()
{
mask.showMaskGraphic = true;
}
private void Hide_Grtaphics()
{
mask.showMaskGraphic = false;
}
I believe there is a car available in the standard assets package- it doesn’t have indicators, but I think it does have effects and lights that turn on and off with input- you could look there to find out how they did it.
thanks