Passing a C # object to a lua function with moonsharp.

I'm having problems using Moonsharp in Unity3d. I am trying to pass AppletMessage objects:

[MoonSharpUserData] public class AppletMessage { public string Name; public string[] Args; public AppletMessage(string _name, string[] _args) { Name = _name; Args = _args; } } 

into a function in lua, and I'm not sure how to do this. What I am doing now is:

 //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}); 

this gives me this error coming from the applet class when trying to call a function and pass AppletMessage to:

 cannot access field of userdata<AppletMessage> 
+5
source share

Source: https://habr.com/ru/post/1264930/


All Articles