Advertisement
Guest User

Untitled

a guest
Apr 28th, 2017
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class FadeIn : MonoBehaviour {
  6.  
  7. List<float> portalAlphaValues = new List<float>();
  8. public float fadeInSpeed;
  9.  
  10. // Use this for initialization
  11. void Start () {
  12. foreach (Transform child in transform)
  13. {
  14. if (child.GetComponent<Material>())
  15. {
  16. portalAlphaValues.Add(child.GetComponent<Material>().color.a);
  17. }
  18. }
  19. }
  20.  
  21. public void FadeInChildren()
  22. {
  23. int i = 0;
  24. foreach (Transform child in transform)
  25. {
  26. Material m = child.GetComponent<Material>();
  27. Color newColor = m.color;
  28. newColor.a = Mathf.Lerp(newColor.a, portalAlphaValues[i], Time.deltaTime * fadeInSpeed);
  29. m.color = newColor;
  30. }
  31. }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement