Skip to content

Commit

Permalink
Don't immediately hang if the first option view returns null
Browse files Browse the repository at this point in the history
  • Loading branch information
desplesda committed Sep 6, 2024
1 parent 0983700 commit a0d6929
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions Runtime/DialogueRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -517,15 +517,13 @@ private async YarnTask OnOptionsReceivedAsync(OptionSet options)
}

var dialogueSelectionTCS = new YarnOptionCompletionSource();
int pendingOptionViews = 0;
int viewsNotReturningOption = 0;

async YarnTask WaitForOptionsView(AsyncDialogueViewBase? view) {
if (view == null) {
return;
}
pendingOptionViews += 1;


var result = await view.RunOptionsAsync(localisedOptions, optionCancellationSource.Token);
if (result != null) {
// We no longer need the other views, so tell them to stop
Expand All @@ -535,7 +533,7 @@ async YarnTask WaitForOptionsView(AsyncDialogueViewBase? view) {
} else {
// Our view did not return an option.
viewsNotReturningOption += 1;
if (viewsNotReturningOption >= pendingOptionViews) {
if (viewsNotReturningOption >= this.dialogueViews.Count) {
// No view returned an option, so it's unanimous. Set the result to 'null'.
dialogueSelectionTCS.TrySetResult(null);
}
Expand Down

0 comments on commit a0d6929

Please sign in to comment.