Page 1 of 1

Stop and Start conversation in a same frame

Posted: Mon Nov 23, 2020 9:23 am
by fkkcloud
Hello,

I am stopping a conversation with Override Dialogue UI and starting a conversation with non-override dialogue UI (default dialogue UI).
The latter conversation should use the default dialogue UI has no Override Dialogue UI component in any of actor/speaker/conversant in the conversation. Conversation info/setting in the inspector does not have any Override setting as well.

Below is sequence command that I am using to call/switch the conversation.

Code: Select all

public class SequencerCommandAmberAlert : SequencerCommand
    {
        public void Awake()
        {
            PixelCrushers.UIPanel.monitorSelection = false;

            StartCoroutine(coroutine_StartAmberAlert());
        }

        IEnumerator coroutine_StartAmberAlert()
        {
            GameObject obj = GameObject.Find("SMS_Dialogue_Panel");
            Debug.Log("object found:" + obj);
            if (obj)
            {
                Animator SMS_ScreenEventAnimator = obj.GetComponent<Animator>();
                Debug.Log("object found:" + SMS_ScreenEventAnimator);
                if (SMS_ScreenEventAnimator)
                {
                    SMS_ScreenEventAnimator.SetTrigger("AmberAlert");
                }
            }

            yield return new WaitForSeconds(5); // wait until the animation end.
            
            DialogueManager.StopConversation();

            GameManager.Instance.eventSystemModule.enabled = true;
            PixelCrushers.UIPanel.monitorSelection = true;
            DialogueManager.StartConversation("Ch01_Intro01_Apt_Scn_05_B");

            Stop();
        }
    }

and calling it in sequence

Code: Select all

SetInput(false);
AmberAlert()@1;

Re: Stop and Start conversation in a same frame

Posted: Mon Nov 23, 2020 10:26 am
by Tony Li
Thanks for sharing!

Re: Stop and Start conversation in a same frame

Posted: Mon Nov 23, 2020 6:32 pm
by fkkcloud
Hello!

I meant it is not working. It still uses the previous conversation's Dialogue UI which was override!

Re: Stop and Start conversation in a same frame

Posted: Mon Nov 23, 2020 6:43 pm
by Tony Li
Can you try waiting 1 frame?

Code: Select all

            yield return new WaitForSeconds(5); // wait until the animation end.
            
            DialogueManager.StopConversation();
            
            yield return null; //<--- ADD THIS.

            GameManager.Instance.eventSystemModule.enabled = true;
            PixelCrushers.UIPanel.monitorSelection = true;
            DialogueManager.StartConversation("Ch01_Intro01_Apt_Scn_05_B");

            Stop();
If that doesn't work, can you please send a reproduction project to tony (at) pixelcrushers.com?

Re: Stop and Start conversation in a same frame

Posted: Mon Nov 23, 2020 6:58 pm
by fkkcloud
Still no luck.

As I Stop the conversation who is the owner of the sequencer command, the coroutine might have destroyed at that moment too?

Re: Stop and Start conversation in a same frame

Posted: Mon Nov 23, 2020 9:01 pm
by Tony Li
When you stop a conversation, it gives all active sequencer commands one frame to finish. So waiting 1 frame should be acceptable.

I made this simplified test scene in Unity 2020.1:

DS_TestAmberAlert_2020-11-23.unitypackage

Please compare it to your scene. It might help you find what is different that is preventing your scene from working the way you want.

Re: Stop and Start conversation in a same frame

Posted: Mon Nov 23, 2020 11:44 pm
by fkkcloud
Okay, it was because I had DialogueActor component for SMS (override Dialogue UI) object within the regular one that has its own DialogueActor component for default Dialogue UI.

For instance, the prefab of the actor character is like below in the hierarchy.

Code: Select all

gameObject ([b]DialogueActor [/b]- actor = "Char_default")
----
---------gameObject ([b]DialogueActor [/b]- actor = "Char_SMS", Override Dialgoue UI)
If I remove the override DialogueActor gameObject right before going back to the default one, then it works.

Any suggestion so I can keep both DialogueActor in a single prefab?

edit: also, with DialogueManager's Debug Info, the speaker/conversant of the conversation that needs to trigger default UI is "correct" in the default Dialogue UI conversation.
It is using Char_default rather than Chat_SMS. but somehow, since the override dialogue UI component within the default, has been activated, it is using the override dialogue UI.
Only after once it is "used" - it does not do that for the first time.
For instance, if I just start conversation with Char_default for the first time, it works.
Only after I start a conversation with Char_SMS at least one time, it override the conversation with Char_default's conversation.

For a solution, I can detach the Char_SMS DialogueActor gameObject from Char_default DialogueActor gameObject so they are 2 separate prefab - which works perfectly. - maybe it is better like this anyway.

Re: Stop and Start conversation in a same frame

Posted: Tue Nov 24, 2020 1:29 pm
by Tony Li
Yes, it's better to keep them separate. You can still keep them in the same prefab if the Dialogue Actors are on two separate children and not nested in each other. Example:

Code: Select all

- Main GameObject
--- Child 1 (Dialogue Actor: "Char_default")
------- Child 1's children...
--- Child 2 (Dialogue Actor: "Char_SMS")
------- Child 2's children...

Re: Stop and Start conversation in a same frame

Posted: Tue Nov 24, 2020 11:17 pm
by fkkcloud
works great- thank you

Re: Stop and Start conversation in a same frame

Posted: Wed Nov 25, 2020 9:16 am
by Tony Li
Glad to help!