Here's the sample code where the external C++ function is declared in the C# code:
And, here's where the function is called:
Here's the original C++ function definition's name and parameters:
The problem is that when I try to run the game in Unity or my own personal C# tester program, both programs crash. Why is that? Has anyone else successfully passed arrays as parameters between Unity and their own C++ dll's? If so, then please let me know so that I and others may benefit from your knowledge. Thank-you.
asked Dec 01 '10 at 09:37 PM
The answer I gave to your other question has some links which may be helpful.
There is a link to an MSDN page which discusses marshaling arrays. Also, there is a link to some code I use to pass arrays back and forth between Unity and a C++ plugin. (Though I haven't attempted multi-dimensional arrays.)
From experience, I strongly recommend testing all marshaling code outside Unity in an IDE. Once it is working there without any errors, then move it into Unity. You can avoid a lot of the hassle since your external IDE will usually give you better error responses than Unity can provide.