Unity3D 调用C++的DLL的代码
来源:互联网 发布:网络推广及优化 编辑:程序博客网 时间:2024/05/18 11:26
我使用的是 vs2012生成的DLL
1使用vs创建一个 名为 TestDll 的 Win32控制台应用程序
, 应用程序类型选择: DLL, 附加类型选择:空项目.
2添加TestDll.h, TestDll.cpp文件,并生成 TestDll.dll文件
TestDll.h
#ifndef _TEST_DLL_H_#define _TEST_DLL_H_#endif#if defined (EXPORTBUILD)# define _DLLExport __declspec (dllexport)# else# define _DLLExport __declspec (dllimport)#endifextern "C" int _DLLExport add( int x, int y );_DLLExport class TestDll{public:TestDll(void);~TestDll(void);};TestDll.cpp
#define EXPORTBUILD#include "TestDll.h"int add(int x, int y ){return x + y;}TestDll::TestDll(void){}TestDll::~TestDll(void){}
生成DLL
3把生成的TestDll拖到Unity的Asset-->Plugins目录(没有就创造一个)
4新建一个UnityTestDll C#文件
UnityTestDll.cs
using UnityEngine;using System.Collections;using System.Runtime.InteropServices;public class UnityTestDll : MonoBehaviour {[DllImport("TestDll")]private static extern int add( int x, int y );int i = add( 5, 7 );// Use this for initializationvoid Start () {}// Update is called once per framevoid Update () {}void OnGUI(){GUI.Button( new Rect( 1, 1, 200, 100 ), "this dll i = 5+7, i is" + i );}}
5运行Unity显示结果
0 0
- Unity3D 调用C++的DLL的代码
- Unity3D 调用C++的Dll代码
- Unity3d中调用C/C++封装的DLL
- Java调用C/C++代码-生成java调用的DLL
- unity3d 调用加密狗的dll
- Unity3d 调用C++写的DLL
- [Unity3d]调用自己封装的dll
- Unity3D教程:静态调用C#的dll
- unity3d 调用C#的dll文件
- [Unity3d]调用自己封装的dll
- Unity3D调用自己封装的dll
- Unity3D调用自己封装的dll
- C#+.NET中调用VB编写的DLL代码事例
- Java JNI调用dll中的C代码的流程
- C#调用C的DLL
- Qt调用C的DLL
- delphi调用c的dll
- C程序DLL调用。砸七烂八的C。
- 虚拟机安装CentOS以及SecureCRT设置【完美无错版】
- Eclipse/Myeclipse 快捷键大全
- 查看struts常量
- 2013年11月26日星期二(t3dlib1剩余部分---2)
- 学习鸟哥私房菜 记录关键词-4 2013-12-27
- Unity3D 调用C++的DLL的代码
- 讨厌的哪些人
- 2013年12月20日星期五(OUTPOST)
- 黑马程序员_委托
- Symantec Netbackup training I
- dos 常用命令的收集与使用
- Ubuntu shell 条件测试
- 谷歌词霸 2014 发布
- 我的index