5

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 を渡そうとすると、アプレット クラスからこのエラーが発生します。

cannot access field  of userdata<AppletMessage>
4

1 に答える 1

0

Moonsharp.Interpreter.UserData.RegisterAssembly();ゲームの開始時に追加しましたか?[MoonSharpUserData]これは、タグを検出して正しく機能させるために必要です。

于 2018-08-05T04:54:40.943 に答える