Page 1 of 1

Show Twison Node-Name(Title) in update void

Posted: Sun Nov 28, 2021 3:38 pm
by Tyommm
Hello. We use Twison import for create a story. Which sript should i write in Unity for show the name(title) of current Twine node during the conversation? I need to get "Begin" in unity update

Re: Show Twison Node-Name(Title) in update void

Posted: Sun Nov 28, 2021 7:54 pm
by Tony Li
Hi,

If you're using an OnConversationLine() method, you can use the Subtitle object passed to the method:

Code: Select all

void OnConversationLine(Subtitle subtitle)
{
    Debug.Log("Title of current line is: " + subtitle.dialogueEntry.Title);
}
Otherwise you can use DialogueManager.currentConversationState:

Code: Select all

Debug.Log("Title of current line is: " + DialogueManager.currentConversationState.subtitle.dialogueEntry.Title);

Re: Show Twison Node-Name(Title) in update void

Posted: Mon Nov 29, 2021 6:13 am
by Tyommm
Thank you. i 'll check that

Re: Show Twison Node-Name(Title) in update void

Posted: Mon Nov 29, 2021 9:01 am
by Tony Li
Glad to help!

Re: Show Twison Node-Name(Title) in update void

Posted: Sun Dec 05, 2021 1:58 pm
by Tyommm
Tony Li wrote: Mon Nov 29, 2021 9:01 amGlad to help!
Yes, it works in some manner. But I am interested in next case:
When I atach function to current node, that function must show me the title of current node(Using DialogueManager.currentConversationState.subtitle.dialogueEntry.Title), but it shows me the Title of previous node.

Re: Show Twison Node-Name(Title) in update void

Posted: Sun Dec 05, 2021 3:00 pm
by Tony Li
Hi,

An immediate solution is to wait until the end of the frame:

Code: Select all

public class GameController
{
    public void change....()
    {
        StartCoroutine(CheckTitleAtEndOfFrame());
    }
    IEnumerator CheckTitleAtEndOfFrame()
    {
        yield return new WaitForEndOfFrame();
        string title = DialogueManager.currentConversationState.subtitle.Title;
    }
In version 2.2.22 and earlier, the idea is that the Scene Events are run to prepare the node for display. The node isn't actually being displayed yet, so DialogueManager.currentConversationState hasn't been set to that node.

However, I think it may work better for most users to update DialogueManager.currentConversationState before running the Scene Events. I will evaluate this for version 2.2.23 and consider changing the behavior. In any case, if you use the code above it will work fine even if the behavior changes.

Re: Show Twison Node-Name(Title) in update void

Posted: Wed Dec 08, 2021 2:32 pm
by Tyommm
Thank you) It works

Re: Show Twison Node-Name(Title) in update void

Posted: Wed Dec 08, 2021 4:49 pm
by Tony Li
Glad to help!