Advertisement
Guest User

Untitled

a guest
Jul 20th, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. IEnumerator ColorLerp(int id)
  2. {
  3. float endTime = Time.time + fadeTime;
  4. float step = 0;
  5.  
  6. while (Time.time < endTime)
  7. {
  8. glows[id].color = Color.Lerp(Color.clear, Color.white, step)
  9. step += Time.deltaTime; // This would only work if you're lerping over 1 second, otherwise you probably wanna divide by your fadeTime somewhere
  10. yield return null; // Skip one frame, then loop again..
  11. }
  12.  
  13. // Step should be 1 here??
  14.  
  15. endTime = Time.time + fadeTime;
  16.  
  17. while (Time.time < endTime)
  18. {
  19. glows[id].color = Color.Lerp(Color.clear, Color.white, step)
  20. step -= Time.deltaTime; // Decrementing instead!
  21. yield return null; // Skip one frame, then loop again..
  22. }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement