Fading with Unity UI

This script delegates the rendering of fade effects to Unity UI, instead of the OnGUI method used by the MainCamera. Since OnGUI is always drawn on top of everything else, using Unity UI gives you finer control over what can be drawn on top of any fading effect.

Note: AC v1.68.0 or newer is required for this script to work.
 * 1) In your game's first scene, create a new UI Canvas, with a RawImage component that spans the screen.
 * 2) Attach a Canvas Group component to the Canvas
 * 3) Copy the script below into a C# script named FadeUI.cs
 * 4) Attach the new Fade UI component to the Canvas, and assign the two fields in its Inspector
 * 5) Select your scene's MainCamera, and uncheck Draw fade?.  Repeat this for all of your MainCameras, or update the linked prefab.

FadeUI.cs: using UnityEngine; using UnityEngine.UI; using System.Collections; using AC; public class FadeUI : MonoBehaviour {     [SerializeField] private RawImage rawImage = null; [SerializeField] private CanvasGroup canvasGroup = null; private void Awake {         DontDestroyOnLoad (gameObject); }     private void Update {         if (KickStarter.settingsManager.IsInLoadingScene ) {             canvasGroup.alpha = 1f; return; }         if (KickStarter.mainCamera != null) {             canvasGroup.alpha = KickStarter.mainCamera.GetFadeAlpha ; rawImage.texture = KickStarter.mainCamera.GetFadeTexture ; }     }  }