Page 4 of 6
Re: Auto Play and Skip All buttons
Posted: Sun Apr 25, 2021 7:36 pm
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>();
Re: Auto Play and Skip All buttons
Posted: Thu Apr 29, 2021 8:21 pm
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)
Re: Auto Play and Skip All buttons
Posted: Thu Apr 29, 2021 8:45 pm
by Tony Li
Hi,
Remove ".Wrappers" from:
Code: Select all
namespace PixelCrushers.DialogueSystem.Wrappers
Re: Auto Play and Skip All buttons
Posted: Thu May 06, 2021 6:41 pm
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();
}
}
}
Re: Auto Play and Skip All buttons
Posted: Thu May 06, 2021 9:10 pm
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;
Re: Auto Play and Skip All buttons
Posted: Thu May 06, 2021 11:49 pm
by mac
Its ' dialogueTrigger.LastInteractedSystemTrigger ' that is missing for some unknown reason.
Re: Auto Play and Skip All buttons
Posted: Fri May 07, 2021 9:10 am
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.
Re: Auto Play and Skip All buttons
Posted: Fri May 07, 2021 9:58 am
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.
Re: Auto Play and Skip All buttons
Posted: Fri May 07, 2021 10:15 am
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);
}
}
}
Re: Auto Play and Skip All buttons
Posted: Fri May 07, 2021 2:58 pm
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'