Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class FadeIn : MonoBehaviour {
- List<float> portalAlphaValues = new List<float>();
- public float fadeInSpeed;
- // Use this for initialization
- void Start () {
- foreach (Transform child in transform)
- {
- if (child.GetComponent<Material>())
- {
- portalAlphaValues.Add(child.GetComponent<Material>().color.a);
- }
- }
- }
- public void FadeInChildren()
- {
- int i = 0;
- foreach (Transform child in transform)
- {
- Material m = child.GetComponent<Material>();
- Color newColor = m.color;
- newColor.a = Mathf.Lerp(newColor.a, portalAlphaValues[i], Time.deltaTime * fadeInSpeed);
- m.color = newColor;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement