Hey everyone,
I was just trying to use an external DLL developed in flat assembly. I got everything nicely imported, except I am stuck on the "UINT pointer to an array of floats:
original:
UINT GetData(
UINT ptrFloatArray);
my version:
[DllImport (“dll”)]
private static extern uint GetData( uint ptrFloatArray );
I have tried a lot the last couple of hours, but Unity keeps crashing (and I am totally the one to blame for that! ;)).
Most of the time I have been trying to use the GCHandle in various ways:
private GCHandle _hGCFile;
public float[] buffer;
// get the legth of the file
uint length = 512;
// create the buffer which will keep the file in memory
buffer = new float[length];
_hGCFile = GCHandle.Alloc( buffer, GCHandleType.Pinned );
and then using GCHandle.ToIntPtr(_hGCFile) as parameter, or other variants including casts to uint, UInt32, Int32, etc. Or just passing the array as float[ ] to the function.
But nothing works, and if Unity does not crash, the array stays empty (which is not good as well ;)). Anyone have a simple suggestion on what I might be overlooking?
Thanks!