在Unity中引用Dll的两种方法
来源:互联网 发布:软件测试费 编辑:程序博客网 时间:2024/05/17 05:04
原址:http://blog.sina.com.cn/s/blog_9afc14d001018og9.html
Unity3D 能够很方便的集成一些外部插件,以便调用现有的动态链接库。下面会介绍Unity中如何集成Dll的两种方法。
1. 标准引用
这里所使用的语言是C#。
1.1
1.2
以上是一个简单的测试代码。
1.3
如果选择的是4.0版会出现
Internal compiler error. See the console log for more information. output was:
Unhandled Exception: System.TypeLoadException: Could not load type 'System.Runtime.Versioning.
错误。
1.4
1.5
1.6
1.7
2. Unity的方案
官网指出,Unity已经广泛支持基于C,C++或者Objective-C语言的插件。原文说明http://docs.unity3d.com/Documentation/Manual/Plugins.html 以下示例可从官网获得,下载示例代码http://docs.unity3d.com/Documentation/Images/manual/SimplestPluginExample.zip
2.1
2.2
注意:在[DllImport ("ASimplePlugi")] 参数中不要加入 .dll 后缀。
2.3
---------------------------------------------- fen ge xian ------------------------------------------------
转载请著名出处:http://oulehui.blog.163.com/blog/static/79614698201011835819382/
JS用法
import System;
import System.Runtime.InteropServices;
@DllImport("user32.dll")
public static function MessageBox(Hwnd : int,text : String,Caption : String,iType : int) : int {};
function Start()
{
MessageBox(0, "API Message Box", "Win32 API", 64) ;
}
function Update () {
}
补充C#用法
C文件
float FooPluginFunction () { return 5.0F; }
将DLL放在 Assets->Plugins文件夹中,文件夹自己建立
C#脚本
using UnityEngine;
using System.Runtime.InteropServices;
class SomeScript : MonoBehaviour {
}
- 在Unity中引用Dll的两种方法
- 在Unity中引用Dll的两种方法
- 在Unity中引用Dll的两种方法
- 在Unity中引用Dll的两种方法
- 介绍两种在c++中调用dll的方法
- .net在同一个项目中要引用两种不同版本的dll(dll hell)的解决办法
- DLL两种常用的创建和引用方法
- 在DLL中资源切换的两中方法
- C++中引用DLL的两种方式
- unity引用dll文件方法
- unity引用dll文件方法
- Unity教程之-在Unity3d中加载外部图片的两种方法
- Unity教程之-在Unity3d中加载外部图片的两种方法
- 在VO中引用Controller层中的Session State的两种方法
- 在VC 引用DLL文件的方法
- Dll的编写 在unity中加载
- vbs脚本中引用dll的方法
- MQ4语言中dll的引用方法
- QPushButton 之 default、autoDefault 分析
- Oracle 中count函数用法
- 数据库服务器 SQLite
- CentOS 6.3 如何将自动挂载的磁盘不显示在桌面上
- 计算机图形学平台 VTK
- 在Unity中引用Dll的两种方法
- Android开发项目:CloudShare
- 常用的linux 命令
- 基于CXF restwebservice
- 在内部类中可以访问其外部类的所有域,即使是私有域
- javascript之HTML(select option)详解
- AAuto - 抓取VOA 新闻
- 字符编码详解(ANSI,UNICODE,UTF-8,GB2312,GBK)
- linux定时器