Auto Play and Skip All buttons

Announcements, support questions, and discussion for the Dialogue System.
User avatar
Tony Li
Posts: 21989
Joined: Thu Jul 18, 2013 1:27 pm

Re: Auto Play and Skip All buttons

Post by Tony Li »

You need to replace your DialogueSystemTrigger component with CustomDialogueSystemTrigger (or whatever you decided to call your subclass). Then change this line in your sequencer command:

Code: Select all

DialogueSystemTrigger dialogueTrigger = FindObjectOfType<DialogueSystemTrigger>();
to:

Code: Select all

CustomDialogueSystemTrigger dialogueTrigger = FindObjectOfType<CustomDialogueSystemTrigger>();
mac
Posts: 81
Joined: Sat Aug 22, 2020 7:54 pm

Re: Auto Play and Skip All buttons

Post by mac »

Hey Tony, sorry for taking so long, but it seems I made something wrong with the subclass, because inside my sequencer, this:

Code: Select all

CustomDialogueSystemTrigger dialogueTrigger = FindObjectOfType<CustomDialogueSystemTrigger>();
Still gives me a missing reference.

My subclass is set up like this:

Code: Select all

using UnityEngine;

namespace PixelCrushers.DialogueSystem.Wrappers
{

    public class CustomDialogueSystemTrigger : DialogueSystemTrigger
    {
        public static DialogueSystemTrigger LastInteractedDialogueSystemTrigger = null;

        protected override void DoConversationAction(Transform actor)
        {
            LastInteractedDialogueSystemTrigger = this;
            base.DoConversationAction(actor);
        }
    }
}
Replacing the Dialogue System Trigger worked I guess, it looks fine in the inspector. (Attached image)
Attachments
Screenshot_1.png
Screenshot_1.png (36.07 KiB) Viewed 1025 times
User avatar
Tony Li
Posts: 21989
Joined: Thu Jul 18, 2013 1:27 pm

Re: Auto Play and Skip All buttons

Post by Tony Li »

Hi,

Remove ".Wrappers" from:

Code: Select all

namespace PixelCrushers.DialogueSystem.Wrappers
mac
Posts: 81
Joined: Sat Aug 22, 2020 7:54 pm

Re: Auto Play and Skip All buttons

Post by mac »

Hello Tony, it seems removing '.Wrappers' did not work, still missing reference.
'CustomDialogueSystemTrigger' does not contain a definition for 'LastInteractedSystemTrigger'
How my Custom Dialogue System Trigger is set up:

Code: Select all

using UnityEngine;

namespace PixelCrushers.DialogueSystem
{

    public class CustomDialogueSystemTrigger : DialogueSystemTrigger
    {
        public static DialogueSystemTrigger LastInteractedDialogueSystemTrigger = null;

        protected override void DoConversationAction(Transform actor)
        {
            LastInteractedDialogueSystemTrigger = this;
            base.DoConversationAction(actor);
        }
    }
}
How the sequencer is set up:

Code: Select all

using UnityEngine;
using System.Collections;
using PixelCrushers.DialogueSystem;

namespace PixelCrushers.DialogueSystem.SequencerCommands
{

    public class SequencerCommandReenableDialogue : SequencerCommand
    { // Rename to SequencerCommand<YourCommand>

        public void Awake()
        {

            CustomDialogueSystemTrigger dialogueTrigger = FindObjectOfType<CustomDialogueSystemTrigger>();

            dialogueTrigger.LastInteractedSystemTrigger.enabled = true; //Missing reference.

            Stop();
        }

    }

}
User avatar
Tony Li
Posts: 21989
Joined: Thu Jul 18, 2013 1:27 pm

Re: Auto Play and Skip All buttons

Post by Tony Li »

Hi,

Is dialogueTrigger or dialogueTrigger.LastInteractedSystemTrigger null? Check both before using them. I'm guessing that dialogueTrigger.LastInteractedSystemTrigger is null. Maybe change the line to:

Code: Select all

if (dialogueTrigger != null && dialogueTrigger.LastInteractedSystemTrigger != null)
{
    dialogueTrigger.LastInteractedSystemTrigger.enabled = true;
}
or, in newer versions of Unity that use later versions of C#:

Code: Select all

dialogueTrigger?.LastInteractedSystemTrigger?.enabled = true;
mac
Posts: 81
Joined: Sat Aug 22, 2020 7:54 pm

Re: Auto Play and Skip All buttons

Post by mac »

Its ' dialogueTrigger.LastInteractedSystemTrigger ' that is missing for some unknown reason.
Attachments
Screenshot_2.png
Screenshot_2.png (7.02 KiB) Viewed 1007 times
User avatar
Tony Li
Posts: 21989
Joined: Thu Jul 18, 2013 1:27 pm

Re: Auto Play and Skip All buttons

Post by Tony Li »

Your custom script defines LastInteractedSystemTrigger to be null, so it will be null in Awake. In fact, you don't need that Awake method at all.
mac
Posts: 81
Joined: Sat Aug 22, 2020 7:54 pm

Re: Auto Play and Skip All buttons

Post by mac »

Sorry I dont get it, the script that contains an Awake method doesn't set LastInteractedSystemTrigger as null, and you said I dont need this Awake method (The only Awake() present in those two scripts we are looking at):

Code: Select all

public class SequencerCommandReenableDialogue : SequencerCommand
    { // Rename to SequencerCommand<YourCommand>

        public void Awake()
        {

            CustomDialogueSystemTrigger dialogueTrigger = FindObjectOfType<CustomDialogueSystemTrigger>();

            dialogueTrigger.LastInteractedSystemTrigger.enabled = true; //Still does not contain a definition for LastInteractedSystemTrigger.

            Stop();
        }

    }
Where would the Sequencer Command run if I remove this Awake method?

Regarding setting the LastInteractedSystemTrigger as null Inside my Custom Dialogue System Trigger, I changed this line:

Code: Select all

public static DialogueSystemTrigger LastInteractedDialogueSystemTrigger = null;
To

Code: Select all

public static DialogueSystemTrigger LastInteractedDialogueSystemTrigger;
And still got no definition for LastInteractedSystemTrigger.
User avatar
Tony Li
Posts: 21989
Joined: Thu Jul 18, 2013 1:27 pm

Re: Auto Play and Skip All buttons

Post by Tony Li »

Sorry, scratch my entire last message. I misread your previous posts and thought Awake was in your CustomDialogueSystemTrigger.

Try changing your sequence command script to:

Code: Select all

using UnityEngine;
using System.Collections;
using PixelCrushers.DialogueSystem;

namespace PixelCrushers.DialogueSystem.SequencerCommands
{
    public class SequencerCommandReenableDialogue : SequencerCommand
    {
        public void Awake()
        {
            CustomDialogueSystemTrigger.LastInteractedSystemTrigger?.enabled = true;
            Stop();
        }
    }
}
(Note that question mark that implicitly checks if LastInteractedSystemTrigger is null.)

If that doesn't work, try adding some Debug.Log lines to both scripts:

Code: Select all

using UnityEngine;
using System.Collections;
using PixelCrushers.DialogueSystem;

namespace PixelCrushers.DialogueSystem.SequencerCommands
{
    public class SequencerCommandReenableDialogue : SequencerCommand
    {
        public void Awake()
        {
            Debug.Log("Re-enabling: " + CustomDialogueSystemTrigger.LastInteractedSystemTrigger, CustomDialogueSystemTrigger.LastInteractedSystemTrigger);
            CustomDialogueSystemTrigger.LastInteractedSystemTrigger?.enabled = true;
            Stop();
        }
    }
}
and:

Code: Select all

using UnityEngine;

namespace PixelCrushers.DialogueSystem
{
    public class CustomDialogueSystemTrigger : DialogueSystemTrigger
    {
        public static DialogueSystemTrigger LastInteractedDialogueSystemTrigger = null;

        protected override void DoConversationAction(Transform actor)
        {
            Debug.Log("Recording LastInteractedDialogueSystemTrigger = " + this);
            LastInteractedDialogueSystemTrigger = this;
            base.DoConversationAction(actor);
        }
    }
}
mac
Posts: 81
Joined: Sat Aug 22, 2020 7:54 pm

Re: Auto Play and Skip All buttons

Post by mac »

I think that adding console debugs for this won't do much since the game cannot compile with or without those changes.
Assets\Scripts\Sequencer\SequencerCommandReenableDialogue.cs(12,69): error CS0117: 'CustomDialogueSystemTrigger' does not contain a definition for 'LastInteractedSystemTrigger'
Attachments
Screenshot_2.png
Screenshot_2.png (10.46 KiB) Viewed 1003 times
Post Reply