How to pass Array from c++ plugin to c#? I have tried different methods, still can’t work out. Does any one give some help?
[DllImport (“ASimplePlugin”)]
private static extern bool Get(ref Vector4[ ] ptrResultVerts, ref int resultVertLength);
Vector4 MarshalMethod (){
//IntPtr ptrResultVerts = IntPtr.Zero;
Vector4[ ] ptrTresultVerts = new Vector4 (0,0,0,0);
int resultVertLength = 0;
bool success = Get(ref ptrResultVerts, ref resultVertLength);
Vector4[ ] resultVertices = null;
if (success)
{
// Load the results into a managed array.
resultVertices = new Vector4[resultVertLength];
Marshal.Copy(ptrResultVerts
, resultVertices
, 0
, resultVertLength);
}
return resultVertices[0];
}
Even I change Vector4 to float numbers, still not works.