• u3d调用自己的dll


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

    首先用vc建立一个dll工程

    未命名.jpg

    然后在里面建立一个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工程的assertPlugins(如果没有这个文件,那你就要新建了,呵呵)。

    然后在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了。

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

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

  • 相关阅读:
    什么是动态链接库
    <<TCP/IP高效编程>>读书笔记
    C++ 函数
    我的vim配置
    FastReport4.6程序员手册_翻译
    DUnit研究初步
    ADO BUG之'无法为更新定位行....' 解决之道
    极限编程的集成测试工具Dunit
    总结
    项目管理检查清单项目启动
  • 原文地址:https://www.cnblogs.com/dragon2012/p/3752742.html
Copyright © 2020-2023  润新知