tri*_*ini 5 c# mono lua unity-game-engine moonsharp
我在Unity3d中使用Moonsharp时遇到问题.我正在尝试传递'AppletMessage'对象:
[MoonSharpUserData]
public class AppletMessage {
public string Name;
public string[] Args;
public AppletMessage(string _name, string[] _args) {
Name = _name;
Args = _args;
}
}
Run Code Online (Sandbox Code Playgroud)
进入lua的一个函数,我不知道该怎么做.我目前正在做的是:
//In a start function
UserData.RegisterType<AppletMessage>();
//Later on, after popping the latest message from a stack as 'LatestMessage'
result = applet.Call( applet.Globals["OnCatchMessage"],new AppletMessage[] {LatestMessage});
Run Code Online (Sandbox Code Playgroud)
当它试图调用函数并传递AppletMessage时,这给了我来自applet类的错误:
cannot access field of userdata<AppletMessage>
Run Code Online (Sandbox Code Playgroud)
小智 1
你Moonsharp.Interpreter.UserData.RegisterAssembly();在游戏开始时添加了吗?您需要它来检测标签并使[MoonSharpUserData]标签正常工作。