Game Development Reference
In-Depth Information
Next, as we need to draw our fading image (the image is a part of the material, even if it's
only a black color) to the whole screen, we are going to need a little helper function to do
that using some of Unity's primitive drawing functions.
Note
Primitives, in graphics terms, refers to when you manually draw lines, quads, or shapes
using manually-created vertexes, vertices, and indexes. For more information about the
editor, visit https://docs.Unity3D.com/Documentation/Manual/PrimitiveObjects.html . For
more information on using the low-level graphics library in scripting, visit ht-
tps://docs.Unity3D.com/Documentation/ScriptReference/GL.html .
Now, you can create a new C# class to hold the following drawing function if you wish,
but I have simply appended it to the FadeInOutManager script. Use whichever meth-
od suits you; I kept it in FadeInOutManager because it's integral to the operation of
that function. It's still static, so it is still reusable wherever I need it. The code of the re-
quired class is as follows:
public static class DrawingUtilities
{
//Helper utility to draw a full screen texture
public static void DrawQuad(
Material aMaterial,
Color aColor,
float aAlpha)
{
aColor.a = aAlpha;
aMaterial.SetPass(0);
GL.PushMatrix();
GL.LoadOrtho();
GL.Begin(GL.QUADS);
GL.Color(aColor);
GL.Vertex3(0, 0, -1);
GL.Vertex3(0, 1, -1);
GL.Vertex3(1, 1, -1);
GL.Vertex3(1, 0, -1);
GL.End();
GL.PopMatrix();
Search WWH ::




Custom Search