Page 1 of 1

I have a question.

Posted: Sat Jul 15, 2023 1:06 am
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)

Re: I have a question.

Posted: Sat Jul 15, 2023 10:07 am
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 143 times