Creating a Dialogue entry in Code
Creating a Dialogue entry in Code
I've trying to do this myself but I don't think I'm supplying the entry with all the data it needs because the system if throwing me errors. There are some places in my game where I'd just like to have an actor speak a line of dialogue that I write in code.
Re: Creating a Dialogue entry in Code
Hi,
Do you want the actor to speak it as a bark (i.e, through a bark UI) or as a subtitle (through the dialogue UI)?
Barks are easier. You need to create a Subtitle object. Then start the BarkController.Bark() coroutine.
To play it as a subtitle, you can either create a conversation on the fly and start it:
Or manually open the dialogue UI with IDialogueUI.Open(), create a Subtitle object like above and call IDialogueUI.ShowSubtitle, and then when the sequence is done (or whenever is the right time), call IDialogueUI.Close() to close the dialogue UI.
If I completely misunderstood you, and you simply want to use your own code to set the Dialogue Text of an existing conversation's dialogue entry, that's much easier! Register a Lua function. Then use the [lua] tag to call that function in your Dialogue Text:
Do you want the actor to speak it as a bark (i.e, through a bark UI) or as a subtitle (through the dialogue UI)?
Barks are easier. You need to create a Subtitle object. Then start the BarkController.Bark() coroutine.
Code: Select all
var speakerInfo = new CharacterInfo(actorID, nameInDatabase, speakerTransform, CharacterType.NPC, portraitTexture);
var listenerInfo = new CharacterInfo(/*similar parameters*/);
var formattedText = FormattedText.Parse("This is a bark!", DialogueManager.MasterDatabase.emphasisSettings);
var sequence = string.Empty; // Play this sequence while barking.
var responseMenuSequence = string.Empty; // Not used in barks.
DialogueEntry dialogueEntry = null;
var subtitle = new Subtitle(speakerInfo, listenerInfo, formattedText, sequence, responseMenuSequence, dialogueEntry);
StartCoroutine(BarkController.Bark(subtitle));
Code: Select all
var conversation = new Conversation(/*etc.*/);
DialogueManager.MasterDatabase.conversations.Add(conversation);
DialogueManager.StartConversation("title", actor, conversant);
If I completely misunderstood you, and you simply want to use your own code to set the Dialogue Text of an existing conversation's dialogue entry, that's much easier! Register a Lua function. Then use the [lua] tag to call that function in your Dialogue Text:
- Dialogue Text: "[lua( MyDynamicTextFunction() )]"
Re: Creating a Dialogue entry in Code
bark will be perfect! trying this now.
Re: Creating a Dialogue entry in Code
I'm getting an error that 'emphasisSettings' doesn't exist in DisplaySettings.
"DialogueManager.DisplaySettings.emphasisSettings"
"DialogueManager.DisplaySettings.emphasisSettings"
Re: Creating a Dialogue entry in Code
Oops, typo. My fingers must have disconnected from my brain for a sec. It should be DialogueManager.MasterDatabase.emphasisSettings. I'll fix that in my post above, too.