我在 Unity3d 中使用 Moonsharp 时遇到问题。我正在尝试传递“AppletMessage”对象:
[MoonSharpUserData]
public class AppletMessage {
public string Name;
public string[] Args;
public AppletMessage(string _name, string[] _args) {
Name = _name;
Args = _args;
}
}
进入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});
当它尝试调用函数并传入 AppletMessage 时,这给了我来自 applet 类的错误:
cannot access field of userdata<AppletMessage>