if(color==default&&fadeIn)// If no fadein color is assigned, black is given as default. If we are supposed to fadeout the rectangle, default is simply passed through.
color=Color.black;
/// Generic fade function. Communicates with <seealso cref="FadeManager.cs"/>.
/// </summary>
/// <param name="fadeIn">If true, the rectangle fades in. If false, the rectangle fades out.</param>
/// <param name="duration">How long it takes to the image to fade in/out.</param>
ColoroldColor=_imageComponent.color;// Temporarily stores the old color of the image component, as we can't assume the image will always be black.
if(color==default)
color=_imageComponent.color;// Stores the old color of the image component, as we can't assume the image will always be black, if no color is specified.
_imageComponent.color=Color.Lerp(oldColor,newColor(0,0,0,0),totalTime/duration);// Sets the image's color to a mixture between the old color and total transparency, and interpolates based on the amount of time to completion.
_imageComponent.color=Color.Lerp(color,newColor(0,0,0,0),totalTime/duration);// Sets the image's color to a mixture between the old color and total transparency, and interpolates based on the amount of time to completion.
yieldreturnnull;
}
_imageComponent.color=newColor(0,0,0,0);// Here to guarentee the image is fully transparent at the end of the loop.
}
else
{
StartCoroutine(FadeOutEnum(duration));// Fadeout doesn't need color, so the color parameter is disregarded.
// I would like to say that setting the color for the fadeout wouldn't be hard to implement, but I reckon most people wouldn't use it, so it would just be an unnecessary burden.
StartCoroutine(FadeOutEnum(duration,color));// Fadeout doesn't need color, so the color parameter is disregarded.