Import in C# bundle written in c++ (Unity3D project) -
i try use functions .bundle file inside unity3d every time when call functions error:
dllnotfoundexception: libant connectant.start () (at assets/connectant.cs:13)
this script use call library antlib.bundle in assets/plugin folder:
using unityengine; using system.collections; using system.runtime.interopservices; public class connectant : monobehaviour { [dllimport("libant")] static extern bool ant_init(int ucusbdevicenum_, int ulbaudrate_); void start () { ant_init (1, 50000); } }
in bundle function declared this:
#ifdef __cplusplus extern "c" { #endif export bool ant_init(uchar ucusbdevicenum_, ulong ulbaudrate_); //initializes , opens usb connection module #ifdef __cplusplus } #endif
this example 1 function bundle. if import functions in script don't error in unity. can me figure out?
try this:
[dllimport("antlib.bundle")] static extern int ant_init(byte ucusbdevicenum_, uint ulbaudrate_);
there're 2 problems in code:
- wrong file name
- wrong argument type , return type
if want use bool return type, attribute required:
[return: system.runtime.interopservices.marshalasattribute(system.runtime.interopservices.unmanagedtype.bool)] [dllimport("antlib.bundle")] static extern bool ant_init(byte ucusbdevicenum_, uint ulbaudrate_);
Comments
Post a Comment