u3d调用自己的dll
2024-08-24 23:45:39
原文地址: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 : [DllImport "testunity" )] private static extern int testunity(); // int i=testunity(); void Start () { print(i); } // void Update () { } } |
然后再把这个文件在unity里面拖到camera里面就ok了。
然后运行,就可以实现效果了哈。呵呵
这是小弟的第一个教程,当然也是简单的教程
最新文章
- 基于Qt5.5.0的sql,C++备忘录软件的编写
- Fiddler怎么对IPhone手机的数据进行抓包分析
- WCF入门(8)
- Java Applet与Java Application的区别
- H5 input type=";search"; 不显示搜索 解决方法
- struts2中利用POI导出Excel文档并下载
- [转] CSS3混合模式mix-blend-mode/background-blend-mode简介 ---张鑫旭
- datazen 备份还原
- HTML5 HybridApp开发上手指引
- 基于visual Studio2013解决C语言竞赛题之1024求和
- unity调用c++ dll方法介绍
- Mybatis基本用法--下
- Salesforce知识整理(一)之Lightning Web Component Tools
- [物理学与PDEs]第1章第9节 Darwin 模型 9.3 Darwin 模型
- luogu1966 火柴排队(离散化+树状数组)
- linux系统下安装tomcat及配置
- NOIP 2016 天天爱跑步 (luogu 1600 &; uoj 261) - 线段树
- Redis在linux环境下的安装和部署
- kubernetes下安装mysql
- OpenGl 知识一