moonsharp-devs / moonsharp

An interpreter for the Lua language, written entirely in C# for the .NET, Mono, Xamarin and Unity3D platforms, including handy remote debugger facilities.
http://www.moonsharp.org
Other
1.41k stars 213 forks source link

error #262

Closed qxa792 closed 5 years ago

qxa792 commented 5 years ago

image image image

admalledd commented 5 years ago

You need to register the types otherwise Moonsharp won't know to auto-convert for you.

See for example: https://github.com/moonsharp-devs/moonsharp/blob/master/src/Tutorial/Tutorials/Chapters/Chapter6.cs#L169

and http://www.moonsharp.org/objects.html and http://www.moonsharp.org/mapping.html have some notes about registering types.

You can also set your own Type Registration Policy (eg allow all types of namespace, all types in certain assemblies...) see https://github.com/moonsharp-devs/moonsharp/blob/master/src/MoonSharp.Interpreter/Interop/RegistrationPolicies/AutomaticRegistrationPolicy.cs for the automatic version.

UserData.RegistrationPolicy = InteropRegistrationPolicy.Automatic; (NOT recommended if code is untrusted!)

qxa792 commented 5 years ago

thanks