FadeInOutBase
A class in Root.Township, the global namespace.
Base for objects that fade out using a _Progress shader value, or by spawning pooled mesh fader effects in their place. Does nothing on a headless server.
- Listed in Global namespace: E to H
- Inherits or implements
MonoBehaviour,IBuildRendererPostBake,IBuildBakeable - Derived types
PracticeAreaShrinkFader
Constructors
| Member | What it is |
|---|---|
FadeInOutBase() | Unity makes components itself; use AddComponent or spawn a prefab instead of new. |
Fields
| Member | What it is |
|---|---|
protected static readonly int _Progress | Shader property ID for _Progress. |
protected Material baseMaterial | The material copied for the fade. |
protected Coroutine fadingCoroutine | The running fade coroutine, or null. |
protected Material material | The copied material the renderers use. |
protected PooledObjectDefinition meshFaderObject | Pooled effect spawned per mesh by FadeOut. |
3 private and internal fields
| Member | What it is |
|---|---|
private float fadeDuration | Seconds the _Progress shader value takes to go from 1 to 0 in Fade. Read through FadeDuration. |
private List<MeshFilter> filters | Mesh filters that get a pooled ProgressMaterialEffect copy of their mesh on FadeOut. Filled from renderers if empty. |
private List<Renderer> renderers | Renderers given the copied fade material. Filled from child renderers in OnValidate or ForceInitialize if empty. |
Properties
| Member | What it is |
|---|---|
float FadeDuration { get; } | How long the fade takes, in seconds. |
Methods
| Member | What it is |
|---|---|
void FadeOut() | Stops any running fade and spawns a pooled mesh fader effect for each mesh. |
void ForceInitialize(Material baseMaterial, PooledObjectDefinition meshFaderObject) | Finds renderers and mesh filters if none are set, fills in missing material and fader, then copies the material. |
virtual void PostBake() | Removes destroyed renderers and filters from the lists after a build bake. |
protected void CopyBaseMaterial() | Makes a copy of the base material, puts it on every renderer and sets its progress to 1 (fully shown). |
protected virtual IEnumerator Fade() (iterator) | Coroutine that lowers _Progress from 1 to 0 over FadeDuration. |
protected virtual void OnValidate() | Editor: fills the renderer and mesh filter lists from children, preferring renderers that use the base material. |
protected void StartFade() | Starts the fade coroutine if one is not already running. |