Skip to main content
Namespace: MolcaSDK.VR.UI
File: Assets/_MolcaSDK/_VR/Scripts/Fade/VRFadeManager.cs
Type: RuntimeSubsystem (child on RuntimeManager 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 / loaders that call SkipNextAutoFade to avoid double fades).

Inspector setup

FieldPurpose
Fade speedDefault duration when FadeInAsync / FadeOutAsync use -1 for duration.
Fade materialMaterial with _FadeAmount; required — init logs error if null.
Scene start fade delaySeconds 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):
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:
fade.SetFadeAmount(1f);

API (key members)

MemberDescription
InstanceRuntimeManager.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).
IsTransitioningTrue 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.

Unity Editor

VRFadeManager on prefab with fade material reference.

VRFadeManager in Unity Inspector