Error when using sequencer

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
Syoka
Posts: 9
Joined: Sun Apr 21, 2024 1:38 pm

Error when using sequencer

Post by Syoka »

I have the following method in the gameobject named VillageEventManager

Code: Select all

public void ActivateYuushaInform(bool activate){
        //doing stuff
    }

and when run a dialogue with following sequencer command:

Code: Select all

SendMessage(ActivateYuushaInform,true,VillageEventManager);
Then I got this error:

Code: Select all

MissingMethodException: Method 'VillageEventManager.ActivateYuushaInform' not found.
System.RuntimeType.InvokeMember (System.String name, System.Reflection.BindingFlags bindingFlags, System.Reflection.Binder binder, System.Object target, System.Object[] providedArgs, System.Reflection.ParameterModifier[] modifiers, System.Globalization.CultureInfo culture, System.String[] namedParams) (at <4a4789deb75f446a81a24a1a00bdd3f9>:0)
UnityEngine.SetupCoroutine.InvokeMember (System.Object behaviour, System.String name, System.Object variable) (at <f712b1dc50b4468388b9c5f95d0d0eaf>:0)
I cannot figure out where is the problem. Did I use sequencer incorrectly?
User avatar
Tony Li
Posts: 20737
Joined: Thu Jul 18, 2013 1:27 pm

Re: Error when using sequencer

Post by Tony Li »

Hi,

You can only use the SendMessage() sequencer command on methods that have no parameters or one string parameter, such as:

public void ActivateYuushaInform() { ... }
public void ActivateYuushaInform(string activate) { ... }

Here are two ways you could resolve the issue:

1. Write two methods:

Code: Select all

public void ActivateYuushaInform() { ... } // Only activate here
public void DeactivateYuushaInform() { ... } // Deactivate here
Then use sequencer commands such as:

SendMessage(ActivateYuushaInform, , VillageEventManager);
SendMessage(DeactivateYuushaInform, , VillageEventManager);



2. Or write a custom sequencer command:

Code: Select all

// Syntax: ActivateYuushaInform(activate, subject)
// where activate is true or false, subject is a GameObject name or blank to use speaker.
public class SequencerCommandActivateYuushaInform : SequencerCommand
{
    void Awake()
    {
        bool activate = GetParameterAsBool(0);
        Transform subject = GetSubject(0, speaker);
        if (activate) { ... } // activation code here
        else { ... } // deactivation code here
        Stop();        
    }
}
Then you can use sequencer commands such as:

ActivateYuushaInform(true, VillageEventManager)
Syoka
Posts: 9
Joined: Sun Apr 21, 2024 1:38 pm

Re: Error when using sequencer

Post by Syoka »

Oh, thank you. Then I decide to rewrite the method into no parameter.
User avatar
Tony Li
Posts: 20737
Joined: Thu Jul 18, 2013 1:27 pm

Re: Error when using sequencer

Post by Tony Li »

Glad to help!
Post Reply