Set dialogue text through script?


(ian) #1

it is possible to set dialogue panel text through script.
if i update bgs plugin i will lose all the work i have done on previous version?


(Leslie Young) #2

There should not be a problem with upgrading, but as with any project of value, keep backups; and especially make a backup before running an upgrade or importing new packages into a project.

As for script access, have a look at how the Dialogue node does it. You can do something very similar.
Assets\Tools\BGS\scripts\FlowGraph\NodeHandlers\UI\FlowNode_Dialogue.cs

Basically, get a reference to the dialogue panel and call Activate on it with needed params. Note that some options may be null if not used just like when you do not use an option in the dialogue node.

DialoguePanelBase p = UIPanelManager.GetPanel<DialoguePanelBase>("panel_name_ident");
p.Acivate(dialogue_text, speaker_name, speaker_icon, audio_clip, typewriteSound, hintNoAutoHide, hintEndAutoAdvance, BlackboardReference, continue_callback);

One problem will be the Blackboard, you need to provide this one. Normally this comes from the object the graph is running on. It is simply a Variables object but you want to keep this consistent and not create a new instance when you call Activate. In the VN Engine plug-in case that is provided bu the VNEngine component so you can have a look at that source to see how it can be handled.

The last field, the callback, will be called when the dialogue is done showing text - player has clicked through everything. So this would be a trigger to show the next dialogue or continue with whatever else needs to follow after. In the case of the dialogue node that would be the time it tells the graph it can continue with the following nodes.