C# unmanaged function pointers for iOS

C# unmanaged function pointers for iOS

Just a reminder to myself when I need this thing next time for making Unity work with native code:

  • delegate method should be static to please AOT compiler required for iOS
  • method should have have [MonoPInvokeCallback(typeof(YourDelegate))] attribute. its code is as simple as this:

    [AttributeUsage (AttributeTargets.Method)]
    public sealed class MonoPInvokeCallbackAttribute : Attribute
    {
    public MonoPInvokeCallbackAttribute (Type t) {}
    }
  • for other platforms, delegate should have [UnmanagedFunctionPointer(YourCallingConvention)] attribute, but for iOS it prevents AOT compilation for some reason, so we need to #if it

From : http://nadako.tumblr.com/post/82111636787/c-unmanaged-function-pointers-for-ios

上一篇:[转]Eclipse中的Web项目自动部署到Tomcat


下一篇:angular源码阅读3:真的,依赖注入的原理