原文地址:http://blog.sina.com.cn/s/blog_62f7cb730100zhhf.html

首先用vc建立一个dll工程

然后在里面建立一个testunity.h文件。内容如下

 
1
extern "C" int
_declspec(dllexport)testunity();

保存,ok,在建立一个testunity.cpp,代码如下:

 
1
2
3
4
5
#include "testunity.h"
int testunity()
{
      return
0;//这是函数,里面可以写你想要实现的任何功能
}

然后编译、组建。就生成了testunity.dll文件。然后再把这个文件放在你的unity工程的assert的Plugins(如果没有这个文件,那你就要新建了,呵呵)。

然后在unity里面新建C#脚本文件dlltest。代码如下

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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了。

然后运行,就可以实现效果了哈。呵呵

这是小弟的第一个教程,当然也是简单的教程

最新文章

  1. 基于Qt5.5.0的sql,C++备忘录软件的编写
  2. Fiddler怎么对IPhone手机的数据进行抓包分析
  3. WCF入门(8)
  4. Java Applet与Java Application的区别
  5. H5 input type="search" 不显示搜索 解决方法
  6. struts2中利用POI导出Excel文档并下载
  7. [转] CSS3混合模式mix-blend-mode/background-blend-mode简介 ---张鑫旭
  8. datazen 备份还原
  9. HTML5 HybridApp开发上手指引
  10. 基于visual Studio2013解决C语言竞赛题之1024求和
  11. unity调用c++ dll方法介绍
  12. Mybatis基本用法--下
  13. Salesforce知识整理(一)之Lightning Web Component Tools
  14. [物理学与PDEs]第1章第9节 Darwin 模型 9.3 Darwin 模型
  15. luogu1966 火柴排队(离散化+树状数组)
  16. linux系统下安装tomcat及配置
  17. NOIP 2016 天天爱跑步 (luogu 1600 & uoj 261) - 线段树
  18. Redis在linux环境下的安装和部署
  19. kubernetes下安装mysql
  20. OpenGl 知识一

热门文章

  1. svn导出历史版本
  2. mongo操作及相关资料
  3. WebService之CXF注解之四(測试类)
  4. How to add elements to a List in Scala
  5. vue实现复制粘贴的两种形式
  6. Jquery 禁用元素的所有属性
  7. eclipse 安装插件的几种方式
  8. python 字符和数值转换
  9. 【WPF】ScrollViewer无法滚动的问题
  10. Linux 修改mac 地址方法记录