0

I'm writing a plugin for this c++ physics library for Unity3d. The library is a superset of Box2D with particle simulation added. In the c++ library there is a function that returns an array of 2d vector objects for all the particles. I'm wondering how I could pass this back to Unity so I can draw them? I Cant pass objects between the library and Unity. Could I pass a 2d array of floats? I heard that I should instantiate an array of the correct size in Unity in c#, then pass it to the c++ function where all the data will be filled in, then pass it back to Unity (this is to help avoid memory problems in c++) How would you write this in c++? Alternatively could I use an out paramater to do this? And how would you write that?

2

1 Answer 1

1

You can declare the method in your C# code as returning IntPtr and then convert it to the array you need (an array of the managed version of the objects you have in your C++ code) .

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.