Created
April 28, 2017 18:52
-
-
Save anonymous/9fb8368a7ca2b3d9d0c4b8f56cd476a4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections; | |
public class FadeInWithPanel : MonoBehaviour { | |
public float fadeInTime; | |
private Image fadePanel; | |
private Color currentColor; | |
public int stayTime = 1; | |
void Start (){ | |
currentColor = Color.black; | |
fadePanel = GetComponent<Image> (); | |
} | |
void Update (){ | |
if (Time.timeSinceLevelLoad < stayTime) { | |
currentColor = Color.black; | |
} | |
else { | |
float alphaChange = Time.deltaTime / fadeInTime; | |
currentColor.a -= alphaChange; | |
fadePanel.color = currentColor; | |
} if (Time.timeSinceLevelLoad > fadeInTime + stayTime) { | |
gameObject.SetActive (false); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment