using UnityEngine; using UnityEngine.UI; public static class Initiate { private static bool areWeFading; //Create Fader object and assing the fade scripts and assign all the variables public static void Fade(string scene, Color col, float multiplier) { if (areWeFading) { Debug.Log("Already Fading"); return; } var init = new GameObject(); init.name = "Fader"; var myCanvas = init.AddComponent(); myCanvas.renderMode = RenderMode.ScreenSpaceOverlay; init.AddComponent(); init.AddComponent(); init.AddComponent(); var scr = init.GetComponent(); scr.fadeDamp = multiplier; scr.fadeScene = scene; scr.fadeColor = col; scr.start = true; areWeFading = true; scr.InitiateFader(); } public static void DoneFading() { areWeFading = false; } }