Unity version crashes when using IL2CPP

Post Reply
InteractiveGunRange
Posts: 1
Joined: Fri Aug 08, 2025 6:42 am

Unity version crashes when using IL2CPP

Post 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;
    }
jillian.smythe
NaturalPoint Employee
NaturalPoint Employee
Posts: 570
Joined: Fri Sep 02, 2022 6:40 am

Re: Unity version crashes when using IL2CPP

Post 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,
Jillian Smythe
TrackIR Support Representative
Post Reply