/ScreenFadeURP

This is a URP Only Renderer Feature that creates a ScreenFade that runs after Post Processing. It will most likely work on the latest LTS version. but was test on the package.json version.

Primary LanguageC#MIT LicenseMIT

{\rtf1\ansi\ansicpg1252\deff0\nouicompat\deflang1033{\fonttbl{\f0\fnil\fcharset0 Courier New;}}
{\colortbl ;\red0\green0\blue255;}
{\*\generator Riched20 10.0.19041}\viewkind4\uc1 
\pard\b\f0\fs22 Author: \b0 mbalrog6 (Scott Heinrichs)\par
\par
These set of files were inspired by the following YouTube creators and their Tutorials: \par
\par
\b WarpedImagination\b0\par
({{\field{\*\fldinst{HYPERLINK https://www.youtube.com/watch?v=p5DCv7loLbw }}{\fldrslt{https://www.youtube.com/watch?v=p5DCv7loLbw\ul0\cf0}}}}\f0\fs22 )\par
[This was for the actual ScreenFade System]\par
\par
\b Bardent\b0\par
({{\field{\*\fldinst{HYPERLINK https://www.youtube.com/watch?v=Ubuu4ZoTb5Y }}{\fldrslt{https://www.youtube.com/watch?v=Ubuu4ZoTb5Y\ul0\cf0}}}}\f0\fs22 )\par
[This was for using Reflection to populate the Editor Inspector with the EaseFunctions]\par
\par
\b GDC\b0\par
"Math for Game Programmers: Fast and Funky 1D Nonlinear Transformations"\par
({{\field{\*\fldinst{HYPERLINK https://www.youtube.com/watch?v=mr5xkf6zSzk }}{\fldrslt{https://www.youtube.com/watch?v=mr5xkf6zSzk\ul0\cf0}}}}\f0\fs22 )\par
[I used this for creating the Easing Functions]\par
\par
\b VR with Andrew\b0\par
({{\field{\*\fldinst{HYPERLINK https://www.youtube.com/watch?v=OGDOC4ACfSE }}{\fldrslt{https://www.youtube.com/watch?v=OGDOC4ACfSE\ul0\cf0}}}}\f0\fs22 )\par
[WarpedImagination was inspired by this video for his tutorial)\par
\par
\b NOTE: \b0 I used the #if UNITY_EDITOR #endif to wrap the Editor Inspector script so that the custom inspector will not conflict with your build process, if you are using assebly defs, since that causes the Editor Folder functionality to stop working in Unity and you would have to move those files out of the runtime compile assemblies otherwise. \par
\par
This currently was only tested and known to work for URP (Universial Render Pipeline.) \par
\par
Unity Assembly Dependencies: \par
- Unity.RendererPipelines.Universal.Runtime\par
- Unity.RendererPipelines.Core.Runtime\par
\par
WHAT IT DOES: \par
This package adds a URP Renderer Feature that will allow you to create a FadeIn and FadeOut Effect that does not require additional Geometry in the Scene to obscure the camera view. It just applies a shader that blends a mat material to the view after the Post Processing Pass. You can easily add some supplied easing functions to the Fade, or create your own that will work with it. It has a callback event to tie into if you have code that needs to be made aware of the fade completing. After setting it up you should only ever have to call the the public void ScreenFade(bool fade) function from the ScreenFade Component to activate the screen fade. \par
\par
HOW TO USE: \par
1. You will need to find the URP Renderer and click "Add Renderer Feature"\par
2. Make sure the "Render Pass Event" is set to "After Rendering Post Processing"\par
3. The Settings Material should auto-populate with the Material found in the FadeShader folder.\par
4. Add the ScreenFade Component Script to a GameObject. (Typically added to a Camera)\par
5. Click "Fix It" button in the ScreenFade Inspector window. (Or drag in the ScreenFadeFeature Renderer Feature found under the URP Renderer Object)\par
6. While in the Editor you can click the "Add FadeIn Ease Function" and "Add FadeOut Ease Function" buttons to add an Ease Function. (If it is left blank then on Run it will instanciate a LinearEase Function from 0f to 1f for FadeIn, and a LinearEase from 1f to 0f for FadeOut.)\par
7. You will need to be sure and set the Start and End Values so that the End Value of FadeIn Matches the Start Value of FadeOut. This will make sure that there is no visible jump to a different Alpha for the transition. You may need to expand the "Fade In Ease Function" and "Fade Out Ease Function" if you have added one of the custom Ease Functions. \par
You can test the Fade while the editor is playing by pressing the Fade Button. Some Easing Functions will not update their values while in playmode they are setup by an initialization function on first update. \par
\par
You can call the function: \par
\par
public void Fade(bool fade, float? delayTime = null, Color? color = null, float? duration = null)\par
\par
setting \ul\b fade\ulnone\b0  to true causes ScreenFade to call FadeIn. \par
setting \ul\b fade\ulnone\b0  to false cause ScreenFade to call Fadeout. \par
\par
\ul\b delayTime\ulnone\b0  (optional) will run a timer prior to running the FadeEffect, is useful if you want to wait before starting the FadeOut Effect to ensure your GameLogic has had time to process. \par
\par
\ul\b color\ulnone\b0  and \ul\b duration\ulnone\b0  will override the value set in the inspector and are optional. \par
\par
\b Event: \b0\par
public Action<bool> FinishedFading;\par
\par
You can assign any function with the signature:\par
public void Function(bool fadingIn)\par
\par
If bool is true, the function fired after the FadeIn Ease completed. \par
\par
If bool is false the function fired after the FadeOut Ease completed. \par
\par
\b Custom EaseFunctions: \b0\par
public interface IEaseFunction \{public float Evaluate(float time);\}\par
\par
Evaluate(float time) just needs to return a value from 0f to 1f.\par
\par
The Add Ease Function Buttons will populate with any classes that implement IEaseFunction in the current assembly domain.\par
\par
\par
\par
\par
\par
\par
\par
\par
\par
}