|
I am using the Unity Plugin feature to transfer data from Obj-C to Unity. After much blind falling about, I eventually settled on the method outlined below. Obj-C side:
C# side:
It all works - The data gets into Unity just fine. Right after the C method finishes executing, however, I am getting the following output in the console when running the app on-device in Debug mode:
Research tells me that this error comes up when free() is called on something that hasn't been malloc'ed. I haven't the faintest clue about how to go about using malloc correctly to solve this problem in my particular instance; all the strings are malloc'ed, and the struct is created C# side. Help? :) ** ===== EDIT ===== ** Turns out that making the struct's strings non const and actually using MakeStringCopy() for every instance of a string fixes it! Part misunderstanding and part pebcak (problem-exists-between-keyboard-and-chair)! Thanks jonas echterhoff for taking the time to help me.
(comments are locked)
|
|
While I'm not sure what exactly is happening here, I'm pretty sure you cannot simply cast a C++ string to a C# string in a struct, as they are represented different internally. However, IIRC, you should be able to do that by passing the C++ string as a return value. This is because the mono runtime detects the case of having strings as a return value and performs an automatic cast from C++ to C# strings in that case. At least that is how I remember it, probably worth experimenting with anyways.
(comments are locked)
|
