Show Twison Node-Name(Title) in update void

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
Tyommm
Posts: 4
Joined: Sun Nov 28, 2021 3:28 pm

Show Twison Node-Name(Title) in update void

Post 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
Attachments
Screenshot_2.png
Screenshot_2.png (13.22 KiB) Viewed 574 times
User avatar
Tony Li
Posts: 22154
Joined: Thu Jul 18, 2013 1:27 pm

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

Post 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);
Tyommm
Posts: 4
Joined: Sun Nov 28, 2021 3:28 pm

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

Post by Tyommm »

Thank you. i 'll check that
User avatar
Tony Li
Posts: 22154
Joined: Thu Jul 18, 2013 1:27 pm

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

Post by Tony Li »

Glad to help!
Tyommm
Posts: 4
Joined: Sun Nov 28, 2021 3:28 pm

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

Post 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.
Attachments
Screenshot_5.png
Screenshot_5.png (103.61 KiB) Viewed 330 times
User avatar
Tony Li
Posts: 22154
Joined: Thu Jul 18, 2013 1:27 pm

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

Post 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.
Tyommm
Posts: 4
Joined: Sun Nov 28, 2021 3:28 pm

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

Post by Tyommm »

Thank you) It works
User avatar
Tony Li
Posts: 22154
Joined: Thu Jul 18, 2013 1:27 pm

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

Post by Tony Li »

Glad to help!
Post Reply