Unity version crashes when using IL2CPP
Posted: Fri Aug 08, 2025 6:43 am
Uploading Crash Report
NotSupportedException: IL2CPP does not support marshaling delegates that point to instance methods to native code. The method we're attempting to marshal is: TrackIRNativeMethods+<>c__DisplayClass4_0::<GetUnityHwnd>b__0
at TrackIRNativeMethods.GetUnityHwnd () [0x00000] in <00000000000000000000000000000000>:0
at TrackIRComponent.InitializeTrackIR () [0x00000] in <00000000000000000000000000000000>:0
NotSupportedException: IL2CPP does not support marshaling delegates that point to instance methods to native code. The method we're attempting to marshal is: TrackIRNativeMethods+<>c__DisplayClass4_0::<GetUnityHwnd>b__0
at TrackIRNativeMethods.GetUnityHwnd () [0x00000] in <00000000000000000000000000000000>:0
at TrackIRComponent.InitializeTrackIR () [0x00000] in <00000000000000000000000000000000>:0
Code: Select all
static
IntPtr foundHwnd = IntPtr.Zero;
public static bool KevinFix(IntPtr hwnd, IntPtr lParamContext)
{
StringBuilder outClassnameBuilder = new StringBuilder( 32 );
// Clear the string builder's contents with each iteration.
outClassnameBuilder.Length = 0;
GetClassName( hwnd, outClassnameBuilder, outClassnameBuilder.Capacity );
string hwndClass = outClassnameBuilder.ToString();
if ( hwndClass == "UnityWndClass" || hwndClass == "UnityContainerWndClass" )
{
// We found the right window; stop enumerating.
foundHwnd = hwnd;
return false;
}
// Continue enumeration.
return true;
}