I have a question.

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
swang
Posts: 19
Joined: Sat May 13, 2023 10:28 pm

I have a question.

Post by swang »

Is there a way to run the function you wrote in the C# script in the edit window?
If there is a way, please let me know in detail.

I'm using a translator. Please excuse me.

![image](https://github.com/kaYeonTan/OhMyHonor/ ... 391cd74ce8)
User avatar
Tony Li
Posts: 22110
Joined: Thu Jul 18, 2013 1:27 pm

Re: I have a question.

Post by Tony Li »

Hello,

If you want to run a C# function in a conversation's dialogue entry:

1. Register the function with Lua. Example:

Code: Select all

public AudioClip beep;

void Awake() 
{
    Lua.RegisterFunction(nameof(Beep), this, SymbolExtensions.GetMethodInfo(() => Beep()));
}

public void Beep()
{
    AudioSource.PlayClipAtPoint(beep, Vector3.zero);        
}
2. Use the function in the dialogue entry's Script field:

beepLuaFunction.png
beepLuaFunction.png (10.44 KiB) Viewed 142 times
Post Reply