zoukankan      html  css  js  c++  java
  • 制作和unity调用动态链接库dll文件

    首先用vc建立一个dll工程

    未命名.jpg

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

     
    extern "C" int _declspec(dllexport)testunity();
    
    保存,ok,在建立一个testunity.cpp,代码如下:

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

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

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

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

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

  • 相关阅读:
    Ubuntu安装k8s
    SecureCRT连ubuntu
    硬盘安装ubuntu系统
    发布服务
    使用rancher2建k8s集群--个人学习记录
    spring boot 注解
    用STS构建spring boot
    使用js调用麦克风并录音
    全国省市区信息,mysql数据库记录
    ef core 3 migration
  • 原文地址:https://www.cnblogs.com/lm3515/p/1839428.html
Copyright © 2011-2022 走看看