Page 1 of 1
Direct calls from C#
Posted: Fri Nov 22, 2019 10:38 am
by Kale
Hello! I recently purchased Dialogue System and I love it, but am having trouble integrating it into my project in the way that I would like. Everything I've found deals with integrating it into projects with an actor walking around a world, using trigger volumes and such. I'm trying to use it for a menu-based game (similar to Crying Suns, for instance) and need to be able to trigger conversations from code, as well as passing variables or function calls back into code as a result of dialogue choices. Is there a good resource for that use case? Thanks in advance.
Re: Direct calls from C#
Posted: Fri Nov 22, 2019 1:14 pm
by Tony Li
Hi,
Thanks for using the Dialogue System!
To start a conversation from code, use
DialogueManager.StartConversation().
You can still use
Dialogue System Trigger components, too, if you prefer. A common use is to add a Dialogue System Trigger to a UI button and configure the UI button's OnClick() to call DialogueSystemTrigger.OnUse.
At runtime, the Dialogue System puts its changeable data (such as variables) in
Lua. Use the
DialogueLua class to access Lua values. For example:
Code: Select all
using PixelCrushers.DialogueSystem;
...
int numApples = DialogueLua.GetVariable("NumApples").asInt;
You can also
register your own C# methods with Lua so you can call them in dialogue entry nodes' Conditions and Script fields.
In addition to exposing your own C# code to Lua, you can also
write your own sequencer commands in C#.
Re: Direct calls from C#
Posted: Sat Nov 23, 2019 2:22 pm
by Kale
Thank you so much! I'm off to doing fun things now. I appreciate the excellent documentation.
Re: Direct calls from C#
Posted: Sat Nov 23, 2019 2:35 pm
by Tony Li
Happy to help!