YarnSpinnerTool / YarnSpinner-Unity

The official Unity integration for Yarn Spinner, the friendly dialogue tool.
MIT License
491 stars 85 forks source link

Prefabs should allow running dialog when timeScale=0 #217

Closed IanLondon closed 1 year ago

IanLondon commented 1 year ago

Is your feature request related to a problem? Please describe.

Firstly, thank you for this fantastic library!

Here's the request: Many games pause everything except the dialog for the duration of a dialog interaction, eg the Zelda games. When you talk to an NPC, everything else freezes except for the dialog and maybe some dialog-driven animations.

In Unity, the go-to way to implement a pause is with Time.timeScale = 0.

However, if you set time scale to zero, the provided prefabs for quick setup like LineView & OptionView will freeze, because they use deltaTime and WaitForSeconds, and there's no option to have them use unscaledDeltaTime and WaitForSecondsRealtime instead. The text doesn't appear bc Effects.FadeAlpha never increases the opacity.

Describe the solution you'd like Maybe a checkbox "use unscaled time" in the Editor for these components? Then, dialog can function normally while the rest of the game world is frozen in time.

This could rhyme with how Unity's Animator component lets you select normal or unscaled time in its update mode.

Also the wait command is probably affected by this too (though I haven't tested), maybe add waitUnscaled??

Describe alternatives you've considered Users can implement their own dialogue views instead of using the prefabs.

Additional context

McJones commented 1 year ago

This is something we'd recommend you build a custom dialogue view for! The built-in line view is designed to be good out-of-the-box, but specific features like this are ideal for custom views.

Separately: a waitUnscaled command (or similar) is a good idea, and we'll likely implement something like it.