Open tamv-ika opened 3 years ago
Are you using xlua in unity? If so, delegate with valuetype must add to a list (static field) which has tag [CSharpCallLua]. If you are not using xlua in unity, winform for example, update to this version: https://github.com/Tencent/xLua/commit/2c1c80fe03f14cbcdfa3826485e31d40fc8f2d68
I use Unity 2019.4 I also added to the list, with other type like string, double or other class it work fine but with int value it throw eception. I walk around by wrap it into a class then it works
I did same as example, the weird thing is other type work fine but it failed with int param and enum :(
Delegate without valuetype parameter not required add to CSharpCallLua, that is why other type work fine. CSharpCallLua list configure is existing for years and not changed, it impossible not working. i think it is something wrong with your configure, show your configure?
Here is my configure list
[CSharpCallLua] public static List<Type> csharpCallLua = new List<Type>() { typeof(System.Net.Security.RemoteCertificateValidationCallback), typeof(Test.MyDelegateStr), typeof(Test.MyDelegateInt), typeof(Test.MyDelegateDouble), typeof(EventHandler), typeof(Action), typeof(Action<string>), typeof(Action<byte[]>), typeof(Action<int>), typeof(UnityEngine.Events.UnityAction), typeof(System.Collections.IEnumerator) };
the Action<int>
is not working. I also tried with custom delegates Test.MyDelegateStr, Test.MyDelegateInt, Test.MyDelegateDouble which take one argument with the type string, int and double, then only string and double work, the delegate with int throws exception. Could you check it?
you mush clear generate code after you change the configure.
Of course, I cleared and re-generated code but it’s still fail
Have you found a solution? For me its Func<bool>
that causing issues. Even though it is added to CSharpCallLua and generated properly it gives error.
Hi, I use xlua-2.1.16 build with luajit for win64, I got a problem with calling delegate from lua, I try to call a delegate with int parameter then it throws an exception "This type must add to CSharpCallLua: ...". But when I try the same thing with another delegate which pass a string as parameter, It worked as expected. Both are add to a list which has tag [CSharpCallLua]. This exception also rise when the parameter is an enum type.