Page 1 of 1

Unity version crashes when using IL2CPP

Posted: Fri Aug 08, 2025 6:43 am
by InteractiveGunRange
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

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;
    }

Re: Unity version crashes when using IL2CPP

Posted: Fri Aug 08, 2025 4:12 pm
by jillian.smythe
Hello InteractiveGunRange,

Our team has documentation on how to address that issue. Please reach out to support@optitrack.com so we can share it with you.

Kind Regards,