当前位置: 移动技术网 > IT编程>开发语言>C/C++ > 调用Native Plugin

调用Native Plugin

2017年12月30日  | 移动技术网IT编程  | 我要评论

巴中火车站,数码相机像素,决战上海滩电视剧

使用C/C++生成的库,调用方法如下

// Native Plugin 中声明的函数
float FooPluginFunction () { return 5.0F; } 
using UnityEngine;
    using System.Runtime.InteropServices;

    class SomeScript : MonoBehaviour {

       #if UNITY_IPHONE

       // On iOS plugins are statically linked into
       // the executable, so we have to use __Internal as the
       // library name.
       [DllImport ("__Internal")]

       #else

       // Other platforms load plugins dynamically, so pass the name
       // of the plugin's dynamic library.
       [DllImport ("PluginName")]

       #endif

       private static extern float FooPluginFunction ();

       void Awake () {
          // Calls the FooPluginFunction inside the plugin
          // And prints 5 to the console
          print (FooPluginFunction ());
       }
    }

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网