How to do it...

With all of our assets gathered and the screen effect system running smoothly, let's begin to add the code necessary to both the script and shader. We will begin our coding with the RenderNightVision.cs script, so double-click on this file now to open it in your code editor of choice:

  1. We will begin by entering the code in our script. Our first step in modifying our script is to rename the class to match our filename, RenderNightVision:
[ExecuteInEditMode]public class RenderNightVision : MonoBehaviour {
  1. We need to create a few variables that will allow the user of this effect to adjust it in the script's Inspector. Enter the following code in the NightVisionEffect.cs script:
#region Variables public Shader curShader; public ...

Get Unity 2018 Shaders and Effects Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.