The opaqueness of the material that's using a Fade Shader is determined by the alpha value of its main color. This recipe is based on changing the Alpha value of the color of MeshRenderer.
There are three public variables:
- fadeDurationSeconds: The time in seconds we want our fading to take
- alphaStart: The initial Alpha (transparency) value we want the GameObject to start with (1 = fully visible, 0 = invisible)
- alphaEnd: The Alpha value we want to fade the GameObject into
The UpdateMaterialAlpha(...) method updates the Alpha value of the GameObject's color object with the given value by updating the Alpha value of the fadeColor color variable and then forcing the MeshRenderer material to update its color value to match those in fadeColor.
When the scene begins, the Start() method caches a reference to the MeshRenderer component (the...