Start a script from a node
Start a script from a node
The doc is not so easy for a beginner. What I like to do is to start a method in one of my own c# script when the player has selected one of two nodes. How do I do that?
Re: Start a script from a node
Hi,
Use Lua.RegisterFunction() to make your C# script method available to the Dialogue System. Example:
Then call it in your node's Script field:
Use Lua.RegisterFunction() to make your C# script method available to the Dialogue System. Example:
Code: Select all
using PixelCrushers.DialogueSystem;
...
void Awake() {
// Make your C# method available to the Dialogue System:
Lua.RegisterFunction("WriteLog", this, SymbolExtensions.GetMethodInfo(() => WriteLog(string.Empty)));
}
void WriteLog(string message) { // This is your C# method.
Debug.Log(message);
}
- Script: WriteLog("Hello world")
Re: Start a script from a node
Thank You! So much easier with an example.
What about the other way. Can a script start a conversation?
What about the other way. Can a script start a conversation?
Re: Start a script from a node
Sure!
Use DialogueManager.StartConversation().
Pass it the conversation title. You can optionally also specify the actor & conversant GameObjects, and also a starting entry ID.
Use DialogueManager.StartConversation().
Pass it the conversation title. You can optionally also specify the actor & conversant GameObjects, and also a starting entry ID.