转载请著名出处:http://oulehui.blog.163.com/blog/static/79614698201011835819382/
JS用法
import System;
import System.Runtime.InteropServices;
@DllImport("user32.dll")
public static function MessageBox(Hwnd : int,text : String,Caption : String,iType : int) : int {};
function Start()
{
MessageBox(0, "API Message Box", "Win32 API", 64) ;
}
function Update () {
}
补充C#用法
C文件
float FooPluginFunction () { return 5.0F; }
将DLL放在 Assets->Plugins文件夹中,文件夹自己建立
C#脚本
using UnityEngine;
using System.Runtime.InteropServices;
class SomeScript : MonoBehaviour {
}
本文详细介绍了如何在C#中通过DllImport调用Win32 API函数,并提供了实例演示如何将DLL文件整合到Unity项目中,以及如何在C#脚本中调用插件函数。
588

被折叠的 条评论
为什么被折叠?



