> ## Documentation Index
> Fetch the complete documentation index at: https://docs-unity.molca.id/llms.txt
> Use this file to discover all available pages before exploring further.

# VRFadeManager

> Fullscreen fade quad for transitions and scenario completion.

**Namespace:** `MolcaSDK.VR.UI`\
**File:** `Assets/_MolcaSDK/_VR/Scripts/Fade/VRFadeManager.cs`\
**Type:** [RuntimeSubsystem](/core/runtime-subsystem) (child on [RuntimeManager](/core/runtime-manager) prefab)

Uses a **fade material** with **`_FadeAmount`** (0 = clear, 1 = fully black). On non-additive scene loads, optionally fades from black after a short delay unless a **managed** load set **`SkipNextAutoFade`**.

## When to use

Use **`VRFadeManager`** when you need:

* **Scene transition cover** — automatic fade-in after single-scene loads (unless skipped).
* **Manual fades** — black out before loading, or reveal after async work (coordinate with [ScenarioSessionManager](/vr/session-authentication) / loaders that call **`SkipNextAutoFade`** to avoid double fades).

## Inspector setup

| Field                      | Purpose                                                                     |
| -------------------------- | --------------------------------------------------------------------------- |
| **Fade speed**             | Default duration when `FadeInAsync` / `FadeOutAsync` use `-1` for duration. |
| **Fade material**          | Material with **`_FadeAmount`**; required — init logs error if null.        |
| **Scene start fade delay** | Seconds to wait after scene load before **`FadeOutAsync`** in auto path.    |

Subsystem must be **active** (`IsActive`); otherwise fade methods return early.

## Code

**Manual fade around your own scene load** (call **`SkipNextAutoFade`** first if you also use single-mode `LoadScene` and want to avoid the built-in auto fade):

```csharp theme={null}
using Molca;
using MolcaSDK.VR.UI;

public static async Awaitable FadeThenAct(System.Func<Awaitable> loadWork)
{
    var fade = RuntimeManager.GetSubsystem<VRFadeManager>();
    fade?.SkipNextAutoFade();
    if (fade != null)
        await fade.FadeInAsync(0.5f);

    if (loadWork != null)
        await loadWork.Invoke();

    if (fade != null)
        await fade.FadeOutAsync(0.5f);
}
```

Pass a delegate that performs your **`LoadSceneAsync`** or Addressables load so you do not rely on a non-existent `ToAwaitable` helper.

**Snap opacity:**

```csharp theme={null}
fade.SetFadeAmount(1f);
```

## API (key members)

| Member                                                       | Description                                                            |
| ------------------------------------------------------------ | ---------------------------------------------------------------------- |
| **`Instance`**                                               | `RuntimeManager.GetSubsystem<VRFadeManager>()`                         |
| **`FadeInAsync(float duration = -1)`**                       | Lerps **`_FadeAmount`** toward **1** (to black).                       |
| **`FadeOutAsync(float duration = -1)`**                      | Lerps toward **0** (clear).                                            |
| **`SetFadeAmount(float amount)`**                            | Immediate clamped value.                                               |
| **`SetFadeAmountAsync(float targetAmount, float duration)`** | Animated change to target.                                             |
| **`GetFadeAmount()`**                                        | Current shader value.                                                  |
| **`GetFadeMaterial()`**                                      | Assigned material (for camera/stack setup).                            |
| **`IsTransitioning`**                                        | True while an async fade runs.                                         |
| **`SkipNextAutoFade()`**                                     | Next **`OnSceneLoaded`** skips automatic fade (for coordinated loads). |

## Troubleshooting

* **No fade, material error on init** — Assign **fade material** on the subsystem; ensure **`_FadeAmount`** exists on the shader.
* **Double fade or flash on session-driven loads** — Call **`SkipNextAutoFade`** before loads that already fade (e.g. session / loading manager flows).
* **`FadeInAsync` / `FadeOutAsync` return immediately** — Another transition may be running (**`isTransitioning`**); or subsystem is inactive / not initialized.
* **Additive scenes** — Auto fade bails for **`LoadSceneMode.Additive`**; use manual fades if you need overlay behavior.

## Related

* [RuntimeManager](/core/runtime-manager) — subsystem hosting
* [Runtime subsystem](/core/runtime-subsystem) — lifecycle
* [ScenarioManager](/vr/scenario-manager) — completion fades (typical consumer)

## Unity Editor

<Frame hint="VRFadeManager on prefab with fade material reference." caption="VRFadeManager Inspector">
  <img src="https://mintlify.s3.us-west-1.amazonaws.com/ptmolcateknologinusantara/images/features/vr/vr-fade-manager-inspector.png" alt="VRFadeManager in Unity Inspector" />
</Frame>
