Hello.
Does anybody know of a good fading in and out tutorial that is updating? The few that I found were outdated and confused me.
Thanks
Hello.
Does anybody know of a good fading in and out tutorial that is updating? The few that I found were outdated and confused me.
Thanks
Get a tweening engine, like DOTween. It’s easy to make things fade in and out with a tweening engine, plus do all sorts of other animations like slide in and out.
Thanks! But I ended up using DrawRect in the OnGUI method and changing the alpha each time the method is called. The only thing I have to figure out now is how to calculate the length of time that passes for the entire fade.
Here is some code snippets you can add to your project to fade things
// add these variables at the top of your class
private bool isFading;
private float elapsedTime;
void Start()
{
isFading = false;
elapsedTime = 0;
}
void Update()
{
if (isFading)
{
// this is the time since the last Update
elapsedTime += Time.deltaTime
YourFunctionToFade()
}
}
void YourFunctionToFade()
{
// Write your code here to fade based
// on how big elapsedTime is
// check if we've faded to target color (black?)
if ( // code to check our color is correct) )
{
isFading = false;
// maybe other code here like Load the next scene
}
}
// call this to start the fade
void StartFade()
{
//reset our elapsedTIme and set the IsFading flag
elapsedTime = 0;
isFading = true;
}
Thanks! I should’ve said so but I’ve already got fading done. Thanks thanks!