注意:
1.DllImport 指定的Plugin名称里不要包括 .dll。我之前就犯了这个错误。
2.在 Assets 下面创建一个 ”Plugins“ 文件夹, 将打包成的 dll 放进去,否则找不到。
using UnityEngine; using System.Runtime.InteropServices; class SomeScript : MonoBehaviour { [DllImport ("PluginName")] private static extern float FooPluginFunction (); void Awake () { print (FooPluginFunction ()); } }