Skip to main content

ExposurePlayerScreenFader

A class in Root.Township, the global namespace.

Client screen fader that fades to black by lowering post-process exposure, and shortens the camera far plane while fully dark. Also does camera-flash effects.

Constructors​

MemberWhat it is
ExposurePlayerScreenFader()Unity makes components itself; use AddComponent or spawn a prefab instead of new.

Fields​

4 private and internal fields
MemberWhat it is
private const float BlackFadeExposureExposure used for full black, -50.
private const float FadedFarDistanceFar clip distance while fully faded, 1.
private float fullFarDistanceNormal far clip distance.
private IPostProcessController postProcessControllerPost-process controller that owns exposure.

Methods​

MemberWhat it is
void FlashFadeOut(float flashDuration, float flashFadeoutDuration, float flashExposure)Cancels the current fade and plays a flash: jump to an exposure, hold, then fade back to normal.
protected void Inject(IPostProcessController postProcessController)Receives the post-process controller from VContainer.
protected override IEnumerator LerpFadeScreen(float duration, float alphaStart, float alphaEnd) (iterator)Fades by lerping exposure towards -50 times the end alpha.
protected override void Set(float alpha)Sets the fade at once as exposure alpha times -50.
8 private and internal methods
MemberWhat it is
private void Awake()Remembers the camera's normal far clip distance.
private IEnumerator DelayFlash(float flashDuration, float flashFadeoutDuration, float flashExposure) (iterator)Sets the flash exposure, holds it, then fades back.
private IEnumerator LerpExposure(float duration, float alphaStart, float alphaEnd, float exposure) (iterator)Coroutine that moves exposure between fade levels over a duration.
private void OnDestroy()Unsubscribes from the post-process controller's ValuesChanged, though it subscribed to ValuesReset.
private void OnDestroyByScene(NetworkEntity entity, bool isUnload)Unsubscribes and stops the current fade.
private void OnPostProcessValuesReset()Reapplies a locked fade and sets the far clip to match the current exposure.
private void SetExposure(float targetExposure)Sets exposure, switching the far clip plane when crossing full dark.
private void Start()Off headless servers, hooks the destroy and post-process reset events and applies the current state.