YarnSpinnerTool / YarnSpinner-Unity

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

DialogueException: Cannot continue running dialogue. No node has been selected. #262

Closed Bryan-Legend closed 7 months ago

Bryan-Legend commented 8 months ago

Often after Runner.Dialogue.Stop(); is called I am seeing the following exception.

Could you please not throw an exception when dialog is stopped and using the standard LineView?

image

Bryan-Legend commented 8 months ago

This is using the latest 2.4.0 release.

DialogueException: Cannot continue running dialogue. No node has been selected. Yarn.VirtualMachine.CheckCanContinue () (at <015661c7468d41c3b0a915d84199b7f6>:0) Yarn.VirtualMachine.Continue () (at <015661c7468d41c3b0a915d84199b7f6>:0) Yarn.Dialogue.Continue () (at <015661c7468d41c3b0a915d84199b7f6>:0) Yarn.Unity.DialogueRunner.ContinueDialogue (System.Boolean dontRestart) (at ./Library/PackageCache/dev.yarnspinner.unity@2.4.0/Runtime/DialogueRunner.cs:1142) Yarn.Unity.DialogueRunner.DialogueViewCompletedDismissal (Yarn.Unity.DialogueViewBase dialogueView) (at ./Library/PackageCache/dev.yarnspinner.unity@2.4.0/Runtime/DialogueRunner.cs:1217) Yarn.Unity.DialogueRunner+<>c__DisplayClass111_0.b0 () (at ./Library/PackageCache/dev.yarnspinner.unity@2.4.0/Runtime/DialogueRunner.cs:1202) Yarn.Unity.LineView+d22.MoveNext () (at ./Library/PackageCache/dev.yarnspinner.unity@2.4.0/Runtime/Views/LineView.cs:278) UnityEngine.SetupCoroutine.InvokeMoveNext (System.Collections.IEnumerator enumerator, System.IntPtr returnValueAddress) (at <30adf90198bc4c4b83910c6fb1877998>:0)

McJones commented 8 months ago

I would recommend calling Stop() on the dialogue runner, not the dialogue itself. While you can interface directly with the dialogue object it's not really got any safeguards on it, so what is happening is the dialogue is being stopped but then the line view isn't being told about it, and then is asking the runner to continue stopped dialogue which is throwing the exception. The Stop method on the runner does tell views to dismiss themselves which will prevent this bug. So use Runner.Stop(); in place of Runner.Dialogue.Stop();.

I am going to close this issue as the solution is to not call stop on the dialogue but on the runner. If you do want to talk directly to the dialogue object it's on you to make sure that important dialogue events are passed on to the different pieces that need to be informed about them.

Bryan-Legend commented 8 months ago

Okay. I changed my code to call Runner.Stop instead, but unfortunately the bug is still happening.

The presence of LineView.DismissLineInternal high in the call stack (LineView.cs line 278) makes me think that the view dismissing itself is what is causing this issue. The code to dismiss the line view seems to be checking continue after it's already been stopped.

Bryan-Legend commented 8 months ago

Also, here is the DialogueRunner.Stop method. It doesn't appear to be doing anything with the views.

        /// <summary>
        /// Stops the <see cref="Dialogue"/>.
        /// </summary>
        public void Stop()
        {
            IsDialogueRunning = false;
            Dialogue.Stop();
        }
McJones commented 8 months ago

The HandleDialogueComplete method which is a dialogue event on the runner is what tells the views to dismiss, not Stop itself, but it is called as an effect of Stop being called.

If the issue is still happening though I will reopen the issue but can you give more information as to how you are triggering this? Because when I stop dialogue in the middle of a line I don't get this error.

Bryan-Legend commented 8 months ago

Yes. It's still happening. I'm wondering if HandleDialogComplete is not getting run for some reason.

I suspect that it has something to do with the Auto Advance setting on the Line View. The exception seems to happen about a half second after the dialog is skipped (via Runner.Stop) as shown in this screenshot console log time stamps. I also show my line view inspector so you can match my settings.

image

image

Bryan-Legend commented 8 months ago

I've confirmed that HandleDialogComplete is running and calling LineView.DialogueComplete correctly.

Also I've confirmed that the exception does not happen with Auto Advance off, but then sometimes text will be left on the screen after a cancel when Auto-Advance is turned off.

McJones commented 8 months ago

thanks, investigating.

Bryan-Legend commented 7 months ago

♥️

On Thu, Jan 18, 2024 at 7:33 PM Tim Nugent @.***> wrote:

Closed #262 https://github.com/YarnSpinnerTool/YarnSpinner-Unity/issues/262 as completed via 010611a https://github.com/YarnSpinnerTool/YarnSpinner-Unity/commit/010611ab6acf1db32612b4a58490160c59df1655 .

— Reply to this email directly, view it on GitHub https://github.com/YarnSpinnerTool/YarnSpinner-Unity/issues/262#event-11532067918, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAHAUOEZ4BPJSNCZGK4LDETYPHLQ3AVCNFSM6AAAAABBR7L7GWVHI2DSMVQWIX3LMV45UABCJFZXG5LFIV3GK3TUJZXXI2LGNFRWC5DJN5XDWMJRGUZTEMBWG44TCOA . You are receiving this because you authored the thread.Message ID: <YarnSpinnerTool/YarnSpinner-Unity/issue/262/issue_event/11532067918@ github.com>