Skip to content

Commit

Permalink
fix "useFadeEffect" not setting visible to false after fading control…
Browse files Browse the repository at this point in the history
…s out in AsyncLineView and AsyncOptionsView. hide lastLineContainer instead of lastLineText on dialogue complete in AsyncLineView
  • Loading branch information
dogboydog committed Jan 31, 2025
1 parent 57cd59b commit c9d1216
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 7 deletions.
19 changes: 13 additions & 6 deletions addons/YarnSpinner-Godot/Runtime/Async/AsyncLineView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -366,14 +366,19 @@ public async YarnTask RunLineAsync(LocalizedLine line, LineCancellationToken tok
if (IsInstanceValid(viewControl))
{
// fading up the UI
viewControl!.Visible = true;
if (useFadeEffect)
{

await Effects.FadeAlphaAsync(viewControl, 0, 1, fadeDownDuration, token.HurryUpToken);
if (!IsInstanceValid(this))
{
return;
}
}
else
{
// We're not fading up, so set the canvas group's alpha to 1 immediately.
viewControl!.Visible = true;
// We're not fading up, so set the view control's alpha to 1 immediately.
var oldModulate = viewControl.Modulate;
viewControl.Modulate = new Color(oldModulate.R, oldModulate.G, oldModulate.B, 1.0f);
}
Expand Down Expand Up @@ -441,11 +446,13 @@ public async YarnTask RunLineAsync(LocalizedLine line, LineCancellationToken tok
if (useFadeEffect)
{
await Effects.FadeAlphaAsync(viewControl, 1, 0, fadeDownDuration, token.HurryUpToken);
if (!IsInstanceValid(this))
{
return;
}
}
else
{
viewControl!.Visible = false;
}

viewControl!.Visible = false;
}

// the final bit of clean up is to remove the cancel listener from the button
Expand Down
14 changes: 13 additions & 1 deletion addons/YarnSpinner-Godot/Runtime/Async/AsyncOptionsView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,14 +89,15 @@ public partial class AsyncOptionsView : Node, AsyncDialogueViewBase
public YarnTask OnDialogueCompleteAsync()
{
lastSeenLine = null;
if (IsInstanceValid(lastLineText))
if (IsInstanceValid(lastLineContainer))
{
lastLineText.Visible = false;
}
if (IsInstanceValid(lastLineCharacterNameContainer))
{
lastLineCharacterNameContainer!.Visible = false;
}

return YarnTask.CompletedTask;
}

Expand Down Expand Up @@ -304,9 +305,14 @@ async YarnTask CancelSourceWhenDialogueCancelled()

if (useFadeEffect)
{
viewControl!.Visible = true;
// fade up the UI now
await Effects.FadeAlphaAsync(viewControl, 0, 1, fadeUpDuration,
cancellationToken);
if (!IsInstanceValid(this))
{
return null;
}
}


Expand All @@ -319,6 +325,12 @@ await Effects.FadeAlphaAsync(viewControl, 0, 1, fadeUpDuration,
// fade down
await Effects.FadeAlphaAsync(viewControl, 1, 0, fadeDownDuration,
cancellationToken);
if (!IsInstanceValid(this))
{
return null;
}

viewControl!.Visible = false;
}

// disabling ALL the options views now
Expand Down

0 comments on commit c9d1216

Please sign in to comment.