Game Development Reference
In-Depth Information
}
}
This is just a very basic function using the low-level graphics library (the GL library,
more information about this library can be found at http://docs.unity3d.com/ScriptRefer-
ence/GL.html ) to define a simple 2D plane that will be displayed in front of the camera.
On that plane, I set the material/texture that will be drawn with it and then adjust the alpha
(transparency) of the plane. To see how this is used, let's add the following core fading
coroutine to the manager:
private IEnumerator Fade()
{
float t = 0.0f;
while (t < 1.0f)
{
yield return new WaitForEndOfFrame();
t = Mathf.Clamp01(
t + Time.deltaTime / fadeOutTime);
DrawingUtilities.DrawQuad(
fadeMaterial,
fadeColor,
t);
}
if (navigateToLevelName != "")
Application.LoadLevel(navigateToLevelName);
else
Application.LoadLevel(navigateToLevelIndex);
while (t > 0.0f)
{
yield return new WaitForEndOfFrame();
t = Mathf.Clamp01(t -
Time.deltaTime / fadeInTime);
DrawingUtilities.DrawQuad(
fadeMaterial,
fadeColor,
t);
}
Fading = false;
}
Search WWH ::




Custom Search