Page 1 of 1

Sequence Message Question..

Posted: Tue Jan 12, 2021 8:06 am
by wlchfl5359
Hi, I'm trying to use 2 Messages in Custom Sequence like

ChangeLayout()@Message(Start);

SetActive(Noah, True)@Message(Change);
SetActive(Nia, True)@Message(Change);

if i press G key, (start) message sends and ChangeLayout() Method will start, and after ChangeLayout() Finishes,
I have Method (Sequencer.Message("Change")) in ChangeLayout(). so it will send (Change) Message.
I hoped it works but it doesn't work.
SetActive() didn't work.

is there any way to use 2 messages in Sequence??

Thank you

Re: Sequence Message Question..

Posted: Tue Jan 12, 2021 8:18 am
by Tony Li
Try this:

Code: Select all

ChangeLayout()@Message(Start)->Message(Change);

SetActive(Noah, True)@Message(Change);
SetActive(Nia, True)@Message(Change);
This shows that ChangeLayout sends the message Change when it's done, which clarifies when Change is sent.

Make sure ChangeLayout stays active until it's done, and then calls the Stop() method.

Re: Sequence Message Question..

Posted: Tue Jan 12, 2021 8:55 am
by wlchfl5359
Thank you for reply.

Can i call Method which i made CallStop() to call Stop() in Custom SequencerCommand class?

i was about to use Coroutine from this class to other class but i saw it is not good idea.

i call this method 'CameraControl.Instance.ChangeCameraLayout(GetParameter(0));' in Custom SequencerCommand's Awake();

Re: Sequence Message Question..

Posted: Tue Jan 12, 2021 8:59 am
by Tony Li
Hi,

Sure, that's fine. And coroutines are fine, too.

Re: Sequence Message Question..

Posted: Tue Jan 12, 2021 10:32 am
by wlchfl5359
ChangeLayout()@Message(Start)->Message(Change);

SetActive(Noah, True)@Message(Change);
SetActive(Nia, True)@Message(Change);

I just used this Method and it doesn't send Message(Change).

i used coroutine in Custom SequencerCommand's Start() Method but Coroutine just turns off.

My Continue Button sends Message(Start) and SequencerCommandChangeLayout starts, and it calls Coroutine in Start(),
and Coroutine has Stop() like this.

IEnumerator Coroutine()
{
while(true)
{

Debug.Log("11"); <-- when i start coroutine, it calls this 2 times and just turns off coroutine.

if( ~~~ )
{
Stop();
}


yield return new WaitForFixedUpdate();
}

}

i don't know why coroutine stops..

++ I think if i move to next dialogue Text, SequencerCommands stop.

Re: Sequence Message Question..

Posted: Tue Jan 12, 2021 12:07 pm
by Tony Li
Hi,
wlchfl5359 wrote: Tue Jan 12, 2021 10:32 amI think if i move to next dialogue Text, SequencerCommands stop.
Yes, that's correct. If you move to the next dialogue entry, the current dialogue entry's sequence will stop. If you are moving to the next entry before the sequence has finished, use the 'required' keyword to guarantee that the SetActive() commands run anyway:

Code: Select all

ChangeLayout()@Message(Start)->Message(Change);
required SetActive(Noah, True)@Message(Change);
required SetActive(Nia, True)@Message(Change);
Also, Start can be a coroutine. Example:

Code: Select all

public class SequencerCommandChangeLayout : SequencerCommand
{
    IEnumerator Start()
    {
        while(true)
        {
            if( ~~~ )
            {
                Stop();
                yield break; // REMEMBER TO STOP YOUR COROUTINE, TOO!
            }
        }
    }
}
p.s. - To show in your forum posts, use [ code ] ... [ /code ].

Re: Sequence Message Question..

Posted: Tue Jan 12, 2021 4:12 pm
by wlchfl5359
Thank you for reply.

I used 'required' and it works

Code: Select all

ChangeLayout(Village)@Message(Start)->Message(Change);

required SetActive(House State 0)@Message(Change);
required SetActive(Ayanna, true)@Message(Change);
it calls SetActive(), but Coroutine stops if i move next dialogue entry.
Is there no way to keep Coroutine live?

Code: Select all

IEnumerator Start()
{
	while(true)
	{
		if(~~)
		{
			Debug.log("here");		<- it can't be reach this point if i move next dialogue entry..								
			Stop();				<- i need SetActive() works after here.
			Yield break;
		}
		yield return new WaitForFixedUpdate();
	}
}

Re: Sequence Message Question..

Posted: Tue Jan 12, 2021 6:38 pm
by Tony Li
If you really need to keep a coroutine going, start a coroutine outside of the sequencer command. Example:

Code: Select all

public class SequencerCommandChangeLayout : MonoBehaviour
{
    IEnumerator Start()
    {
        // Start a coroutine on another GameObject:
        SomeOtherGameObject.StartCoroutine(SomeOtherScript.SomeCoroutine());
        
        // Then stop this command when appropriate:
        while (keepGoing)
        {
            yield return null;
        }
        Stop();
    }
}

Re: Sequence Message Question..

Posted: Tue Jan 12, 2021 7:57 pm
by wlchfl5359
Thank you very much for help :)

I modified script, so i made Continue Button can't work until method in other script is finish, and dialogue doesn't move to next dialogue and SequencerCommand is not dying.

So i can send message(Change) from other script.

It was very helpful to use this asset. Thank you!!

Re: Sequence Message Question..

Posted: Tue Jan 12, 2021 8:12 pm
by Tony Li
Happy to help!