调用Native Plugin

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

// Native Plugin 中声明的函数
float FooPluginFunction () { return 5.0F; } 

调用插件

using UnityEngine;
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 ());
   }
}

https://docs.unity3d.com/560/Documentation/Manual/NativePlugins.html

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • Spring Cloud为开发人员提供了快速构建分布式系统中一些常见模式的工具(例如配置管理,服务发现,断路器,智...
    卡卡罗2017阅读 135,269评论 19 139
  • # Python 资源大全中文版 我想很多程序员应该记得 GitHub 上有一个 Awesome - XXX 系列...
    aimaile阅读 26,645评论 6 427
  • Android 自定义View的各种姿势1 Activity的显示之ViewRootImpl详解 Activity...
    passiontim阅读 174,650评论 25 709
  • po主对清新唯美的风格有特殊的偏好,刚好看到有人求推荐类似的美型动漫,现就以往的阅片量来个总结多图预警 分情况讨论...
    繁歆el阅读 1,192评论 0 2
  • 文/景萧 昨天晚上与今天上午备受瞩目的两场比赛,女子气步枪决赛与男子400米自由泳决赛,中国运动员杜丽、孙杨获得银...
    三月景萧阅读 337评论 1 2