Skip to content

Instantly share code, notes, and snippets.

@PiTatva
Created December 26, 2020 13:31
Show Gist options
  • Save PiTatva/138efeec25b48a480964fe6c02bb42fd to your computer and use it in GitHub Desktop.
Save PiTatva/138efeec25b48a480964fe6c02bb42fd to your computer and use it in GitHub Desktop.
[Flash or blink] uses - turning renderer on/off 4 time per seconds to show blink or flash-like animation. this continues for long time coz of i=1000 . the object using blink is meant to be destroyed. #manyuses
/// <summary>
/// flash the product renderer to help player pick up this object asap.
/// </summary>
private bool isFlashing = false;
IEnumerator flash() {
if(isFlashing)
yield break;
isFlashing = true;
while(isFlashing) {
for(int i = 0; i < 1000; i++) {
//GetComponent<Renderer>().material.color = new Color(1,1,1,0.5f);
GetComponent<Renderer>().enabled = false;
yield return new WaitForSeconds(0.25f);
//GetComponent<Renderer>().material.color = new Color(1,1,1,1);
GetComponent<Renderer>().enabled = true;
yield return new WaitForSeconds(0.25f);
}
yield return 0;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment