- Home /
dllimport of C++ class or member functions
I have C++ function "getPos()" which is exported as dll.
extern "C"{
extern __declspec (dllexport) void getPos(float *pPos);
}
Then the function is invoked at Unity side using C# script
[DllImport("MyDLLPlugin")]
private static extern void getPos([In, Out] float[] pPos);
While this works perfectly, I don't know how to import the DLL function(getPos) if the function is a member of some class. Or if we can import the entire class along with its member functions in C#, that'll be great too.
I would appreciate it if someone could suggest a way of importing C++ member functions into C#.
Answer by Mike 3 · Jul 26, 2010 at 05:07 PM
You can't, pretty much.
The way I usually do it is to allow access to instances through an id (be it string or int), which the c++ passes to the c# script on creation (or the c# script passes to c++ to use for creation).
Your answer
Follow this Question
Related Questions
Cant link PLUGIN.DLL with PLUGIN-EDITOR.DLL 1 Answer
Unity plugins 0 Answers
Referencing a DLL in C# 0 Answers
How can I access frame data using C# from the NatNetML.dll 0 Answers