- Home /
Stream bytes from unmanaged C++ to Unity ?
Hi, I'm working on some rather low system operations (assembly) that I just can't perform in a managed environment. Periodically I would like to pass an "array" of bytes from my c++ code to unity. Can this be done in a relatively performant way? Since this is unmanaged c++ I do not have any type of array that would be recognized by both Unity and c++. Is there perhaps a way to stream the data via the memory? Or is serialization/deserialization to the harddrive the only option there is? Any help would be appreciated. Thanks!
Answer by Landern · Oct 17, 2014 at 12:36 PM
Since this is unmanaged c++ I do not have any type of array that would be recognized by both Unity and c++.
Well in c# it will be a byte[] array of course, from c++ you could use Marshal.Copy, some examples:
Go to the self answer: http://stackoverflow.com/questions/21512259/fast-copy-of-color32-array-to-byte-array
Or is serialization/deserialization to the harddrive the only option there is?
Of course not, see above.
Also make sure you put your plugin(your unmanaged code) in the plugin folder.
Thanks a lot for this thorough answer. I didn't know something as neat as the marshal functionality existed.
Your answer
Follow this Question
Related Questions
Is there a way to create a C++ Managed DLL for Unity? 0 Answers
Android Native Plugin (*.SO) 2 Answers
C++ plugin for Unity “EntryPointNotFoundExeption” 0 Answers
Performance: C# vs C++ (plugin) 0 Answers