[HOWTO] How To: Use Alternate Method To Register Lua Functions

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
User avatar
Tony Li
Posts: 21633
Joined: Thu Jul 18, 2013 1:27 pm

[HOWTO] How To: Use Alternate Method To Register Lua Functions

Post by Tony Li »

In some Unity versions, IL2CPP doesn't handle LINQ very well. The example code to register your C# methods with Lua uses an class that uses LINQ. If you can't update to a Unity version whose IL2CPP handles LINQ better, you can bypass the extension class and use this alternate syntax:

Code: Select all

using System.Reflection; // Put at top of script.
...
var methodInfo = this.GetType().GetMethod(nameof(YourMethodName), BindingFlags.Public |  BindingFlags.NonPublic | BindingFlags.Instance);
Lua.RegisterFunction(nameof(YourMethodName), null, methodInfo);
Post Reply