Hi,
Use the SendMessage() sequencer command. For example, say your script "test100" has a function named DoSomething(), and you've added the script to a GameObject named "MyGameObject". Set the dialogue entry's
Sequence field to:
Code: Select all
SendMessage(DoSomething,,MyGameObject);
Delay({{end}})
The first line runs the DoSomething() function on the scripts on MyGameObject. Note the empty second argument (between the two commas). You can pass a string value there instead if you need to.
The second line delays the dialogue entry for a duration based on the length of the subtitle text. You only need to include it if you want to delay for that duration.
Here's an explanation of why you can't use the OnExecute() event the way your screenshot depicts: Since dialogue databases are asset files that exist independently of scenes, you can't assign a GameObject to a dialogue entry's OnExecute() event. You also can't assign a MonoBehaviour script itself to OnExecute() because they have to be added to a GameObject first. You can, however, create a ScriptableObject asset and assign it to OnExecute() because it will exist outside of the scene. It's easiest to create it in C#. For example:
Test200.cs
Code: Select all
using UnityEngine;
[CreateAssetMenu]
public class Test200 : ScriptableObject {
public void DoSomething() {
PixelCrushers.DialogueSystem.DialogueManager.ShowAlert("Hello!");
}
}
After this script compiles, right-click in the Project view and select Create > Test200. This will create an asset file. Then assign that asset file to the OnExecute() event and select the DoSomething() method.