private IEnumerator fadeIn() { float intensity = 0f; while (intensity <= 1f) { //first get the camera then coroutine the shaders to progressively get grayscale; same with directional light. GameObject cameraGameObject = GameObject.Find("MainCamera"); BWEffect cameraEffect = cameraGameObject.GetComponent <BWEffect>(); Light light = GameObject.FindWithTag("Light").GetComponent <Light>(); cameraEffect.intensity = intensity; light.intensity = 1f - intensity; yield return(new WaitForSeconds(.2f)); intensity += .1f; } }
// Creates a private material used to the effect void Awake() { material = new Material(Shader.Find("Hidden/BWDiffuse")); bwEffect = this; }