Skip to content

Unity AOT support C# #1832

@vincentBrth

Description

@vincentBrth

Hello,

I am currently using SWIG to generate C++ bindings to C# for the development of a Unity plugin for SolAR Framework. When I am using C# wrapped in Unity editor or on standalone it is working perfectly. However, while using Unity for mobile development (Android) with IL2CPP compiler its throw an exception :

ADB output
image

This is due to IL2CPP that throws exceptions. It detects that there is not callback emitted ahead and as a consequences it is trying to marshal a function pointer from unmanaged code (Unity ScriptingRestrictions). The error suggest to add MonoPInvokeCallback to manage it and it works. I have found more details thanks to the issue #1165 and many posts on the web.

How is it possible to directly add MonopInvoke annotation in SWIG rules for SWIG Helper static method ? I tried typemap, manage exception but it only works with my declared method.

As a temp hack, we use for the moment a script to parse all *PINVOKE.cs generated to add MonoPInvokeCallback annotation to the static's method of SWIGHelper and it works on Android.

Thanks for your help.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions