Fading to black
These calls fade the screen to black and back. Each call comes in a version with no owner and a version with an owner for your mod.
ScreenFx fade the screen to black and back
ScreenFx.FadeToBlack fades the screen to black and FadeIn fades it back. Use the versions with an owner so your mod’s hold is counted and cannot lift another mod’s black screen.
public static bool FadeToBlack(float speed = 0.1f);
public static bool FadeIn(float speed = 0.1f);
public static bool FadeToBlack(string owner, float speed);
public static bool FadeIn(string owner, float speed);
| Method | Returns | What it does |
|---|---|---|
FadeToBlack(speed) | bool | Fades the screen to black, with no owner. |
FadeIn(speed) | bool | Fades back in, with no owner. |
FadeToBlack(owner, speed) | bool | Fades the screen to black, as your mod. |
FadeIn(owner, speed) | bool | Lets go of your fade. It fades in when no mod still holds the screen black. |
Things to know
FadeToBlackfades the screen to full black and keeps it black until a fade in. It does not change the player’s controls.FadeInfades the screen back. (FadeToBlackcalls the game’sBlackCanvas.FadeInandFadeIncallsfadeCanvasGroup.StartFadeOut(speed)on the same canvas. The fade’s alpha is on theCanvasGroupinBlackCanvas.fadeCanvasGroup(its privatecanvasGroupfield).BlackCanvas.canvasGroupis the instant overlay, so do not read it to find out whether the screen is black.)speedis how big each fade step is. The game’s normal fade uses0.1, which is the default here. The game uses0.5for the tenement fades. A smaller number is slower. (Steps are paced byWaitForSecondsRealtime, and the canvas’srealTimeflag changes the step size.)- The framework does not use the game’s own
BlackCanvas.FadeOut. That call gives the player’s controls back, and it would free the camera that a cutscene or a conversation had locked. The framework fades the same way without that call. Do not callBlackCanvas.ShowBlackCanvaseither, because it switches off movement and keys. (ControlsEnabledremoves only its own holder and resets the two camera look flags unconditionally (ControlsEnabledMove, which callsThirdPersonCameraController.EnableMovementandEnableFirstPersonMovement).) - With an
owner, eachFadeToBlack(owner, ...)adds one hold for your mod, and eachFadeIn(owner, ...)takes one away. So mod B’sFadeIndoes not lift mod A’s black screen. FadeIn(owner, ...)returnsfalseif your mod has no hold, andtruewhen it took one away, even if another mod keeps the screen black.- Without an
owner, the fade is shared and not counted.FadeIn(speed)lets go of it and fades in only when no mod holds the screen, otherwise it returnsfalse. If no mod holds the screen at all, it fades in as before, so it can still lift a black screen the game itself is holding. - A normal level load drops every hold. It does not fade in, so a game fade is not cut off. Nothing is saved, so fade back in yourself. (Every Single scene load drops every count.)
Limits
- A new fade stops the fade that is running. The game uses the same canvas for its own blackouts, treatments, conversations and tenement fades. So your
FadeIncan lift a black screen the game is holding, and yourFadeToBlackcan cut off a game fade in progress. (This isFadeCanvasGroup. The game’s users of the canvas includeBlackoutTrigger.)