Game Development Reference
In-Depth Information
•
Lines 059-063
: Like
OnPostRender
, the
OnRenderImage
event is called
automatically on active camera objects by Unity, once per frame. It's called
after
OnPostRender
and just before the camera render is presented on
screen. This event provides two arguments, namely,
src
and
dst
. The
src
argument is a reference to a render texture that contains the completed
render from the camera, which was output from
OnPostRender
, and the
dst
argument reference defines the render texture that will be shown on screen
when the
OnRenderImage
event completes. In short, this function gives us
an opportunity to edit the pixels of the render either manually in code or
via shader. Here, the
Graphics.Blit
function is called to copy the source to
the destination render texture using the shader associated with the material
reference
Mat
.
•
Lines 067-085
:
Fade
is a
CoRoutine
that transitions a
From
color to a
To
color
over the time (
TotalTime
). This
CoRoutine
method is used to transition
the alpha of a camera color between
0
and
1
, which refer to transparent and
opaque, respectively.
The following screenshot shows the cross-fading camera effect:
Cross-fading cameras