8,305
社区成员
发帖
与我相关
我的任务
分享
#pragma strict
import System;
import System.Runtime.InteropServices;
import dLLTest; //需要测试的dll文件的命名空间
function Start () {}
function Update () {}
function OnGUI(){
GUI.Label(Rect(10,10,200,50),"i="+Add(3,4)); //Add函数原型为int Add(int a,int b),为dll文件中的函数
}
@DllImport("dlltest") //需要测试的dll文件名称,文件原本带.dll后缀,但是网上查的一些例子都木有带,所以这里也木有带
public static function Add(x:int,y:int):int{};
using System;
using UnityEngine;
namespace dLLTest {
public class MyClass {
public int c;
public int Add(int a, int b) {
c = a + b;
return c;
}
public static int GenerateRandom(int min, int max) {
System.Random rand = new System.Random();
return rand.Next(min, max);
}
}
}