sinai-dev / UniverseLib

A library for making plugins which target IL2CPP and Mono Unity games.
GNU Lesser General Public License v2.1
119 stars 51 forks source link

UniverseLib fails to add listeners with BepInEx 6 and Unity 2020.3.38 #11

Closed UserUnknownFactor closed 1 year ago

UserUnknownFactor commented 2 years ago

Can't make it work with BepInEx-Unity.IL2CPP-win-x64-6.0.0-be.660 (with latest Il2CppInterop) and Unity 2020.3.38f1. And it worked perfectly using the same BepInEx version with Unity 2020.3.15f2.

Here is BepInEx log:

[Warning:BepInExConfigManager] [UniverseLib] Exception invoking onInitialized callback! 
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
 ---> 
System.ArgumentException: Cannot bind to the target method because its signature is not compatible with that of the delegate type.
   at System.Delegate.CreateDelegateNoSecurityCheck(Type type, Object target, RuntimeMethodHandle method)
   at System.Reflection.Emit.DynamicMethod.CreateDelegate(Type delegateType)
   at Il2CppInterop.Runtime.DelegateSupport.<>c.<GetOrCreateNativeToManagedTrampoline>b__7_0(MethodInfo _, ValueTuple`3 tuple)
   at System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd[TArg](TKey key, Func`3 valueFactory, TArg factoryArgument)
   at Il2CppInterop.Runtime.DelegateSupport.GetOrCreateNativeToManagedTrampoline(MethodSignature signature, MethodInfo nativeMethod, MethodInfo managedMethod)
   at Il2CppInterop.Runtime.DelegateSupport.ConvertDelegate[TIl2Cpp](Delegate delegate)
   at UnityEngine.Events.UnityAction`1.op_Implicit(Action`1 )
   at UniverseLib.Il2CppExtensions.AddListener[T](UnityEvent`1 action, Action`1 listener)
   at UniverseLib.UI.UIFactory.CreateToggle(GameObject parent, String name, Toggle& toggle, Text& text, Color bgColor, Int32 checkWidth, Int32 checkHeight)
   at ConfigManager.UI.UIManager.ConstructToolbar()
   at ConfigManager.UI.UIManager.ConstructPanelContent()
   at UniverseLib.UI.Panels.PanelBase.ConstructUI()
   at UniverseLib.UI.Panels.PanelBase..ctor(UIBase owner)
   at ConfigManager.UI.UIManager..ctor(UIBase owner)
   at ConfigManager.UI.UIManager.CreateMenu()
   at ConfigManager.UI.UIManager.Init()
   at ConfigManager.ConfigManager.LateInit()
   --- End of inner exception stack trace ---
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Span`1& arguments, Signature sig, Boolean constructor, Boolean wrapExceptions)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at System.Delegate.DynamicInvokeImpl(Object[] args)
   at System.Delegate.DynamicInvoke(Object[] args)
   at UniverseLib.Universe.InvokeOnInitialized(Action onInitialized)
UserUnknownFactor commented 1 year ago

Seems fixed in BepInEx b663.