YarnSpinnerTool / YarnSpinner-Unity

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

Deactivate option views #250

Closed bermanisaac closed 11 months ago

bermanisaac commented 11 months ago

When an option is selected in OptionsListView, disable all child OptionView GameObjects after fading the canvas alpha to 0. This is to avoid unintended effects of leaving the options active when the dialogue view itself is not active, such as animations, audio sources, or other scripts on a custom OptionView.

No longer disable all OptionView objects when initializing options in OptionsListView.RunOptions, as any existing ones will have been disabled at the end of the previous options interaction. New OptionView objects created are still disabled before their use.

See brief discussion on Discord: https://discord.com/channels/754171172693868585/1072667932078903400/1154638863877287936

When an option is selected under an OptionsListView, the child OptionView objects are left enabled and only the canvas group is made transparent, hiding all options. This can lead to unintended behavior if a custom OptionView script or Prefab is used, as animations or sounds may continue playing, scripts will continue to Update, etc.

All child OptionView objects are disabled either when an option is selected, or when OptionsListView.DialogueCompleted() is called. The canvas is faded before options are disabled, so there is no visible change in behavior.

Additionally, previously created OptionView objects are no longer disabled when presenting a new set of options since they will already have been disabled.

No. If this functionality was desired, it would almost certainly be in the context of other custom views, and writing a custom options view to restore previous behavior would be simple.

Although the change is minor, it removes the unintuitive behavior that when the options view is not active, its children remain enabled. They have to be disabled before displaying a new set of options in any case, so the work is done in advance for clarity.