title: Passing a byte array from Unity C# into a C++ library method
body: <p>I have a C++ library method that I'd like to call from a Unity C# script. </p>
  
  <p>I understand there are three key steps. First, to declare the C++ methods to be <code>extern "C"</code>. Second, to use <code>[DllImport('foobar')]</code> before the corresponding C# extern method declaration. Third, to name the library file with the lib prefix (e.g. <code>libfoobar.so</code>) and place it in the Unity plugins folder.</p>
  
  <p>So far so good -- if I'm only passing simple parameter types like <code>int</code> from C# into C++. However, to pass a <code>byte[]</code> parameter, I will need to account for the different ways C# and C++ handle memory and pointers. I haven't been able to find a definitive example of how to this should be done. </p>
  
  <p>My question: how to pass a <code>byte[]</code> from a Unity C# script into a external C++ library method?</p>