纳金网
标题:
unity中调用dll
[打印本页]
作者:
她。
时间:
2012-8-7 10:46
标题:
unity中调用dll
进入这个unity论坛也这么久了。在这里,让我感觉到了家的温暖,让小弟学习到了很多东西,这个感谢大家了。但是我还没怎么在这里发过教程,没能问论坛朋友,没能为祖国、为人民做点什么,每念及此,伤心欲绝。于是,今天就发了这个教程。希望大家喜欢 首先用vc建立一个dll工程 下载 (7.34 KB) 2009-7-20 22:48 然后在里面建立一个testunity.h文件。内容如下 extern "C" int _declspec(dllexport)testunity(); 复制代码 保存,ok,在建立一个testunity.cpp,代码如下: #include "testunity.h" int testunity() { return 0;//这是函数,里面可以写你想要实现的任何功能 } 复制代码 然后编译、组建。就生成了testunity.dll文件。然后再把这个文件放在你的unity工程的assert的Plugins(如果没有这个文件,那你就要新建了,呵呵)。 然后在unity里面新建C#脚本文件dlltest。代码如下 using UnityEngine; using System.Collections; using System.Runtime.InteropServices; public class dlltest : MonoBehaviour { [DllImport ("testunity")] private static extern int testunity(); // Use this for initialization int i=testunity(); void Start () { print(i); } // Update is called once per frame void Update () { } } 复制代码 然后再把这个文件在unity里面拖到camera里面就ok了。 然后运行,就可以实现效果了哈。呵呵 本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/ouczoe/archive/2010/03/21/5401595.aspx
作者:
王者再临
时间:
2012-12-30 04:21
学习了,虽然还是有难度,谢谢楼主的用心
作者:
狂风大尉
时间:
2012-12-31 02:07
谢谢楼主的帖子分享,学习了
欢迎光临 纳金网 (http://go.narkii.com/club/)
Powered by Discuz! X2.5