title: Unity - use GetRawTextureData to change underlying RGB bytes without copying
body: <p>I am trying to use OpenCV with Unity for image processing, and I am trying to make the data transfers between OpenCV and Unity code as efficient as possible. </p>
  
  <p>Currently, I am able to create a new <code>byte[]</code> in C#, then load an image into these bytes in OpenCV, and then use <code>texture.LoadRawTextureData(array)</code> and <code>texture.Apply()</code> to show this texture in Unity.</p>
  
  <p>However, the Unity documentation recommends to use <code>texture.GetRawTextureData()</code> to get a reference to the NativeArray (the version of function that returns <code>byte[]</code> makes a copy of the raw data) and then  write the data directly into this buffer (+ call <code>Apply()</code>).</p>
  
  <p>Unfortunately, the documentation on NativeArrays is rather scarce - how exactly do NativeArrays look in the memory? They do have an <code>ToArray()</code> function, but this again makes a copy of the data. What I need is a byte[] array, which can be either RGB24 or RGBA32 (RGBA seems to be preferred, as even though it is memory-inefficient if the texture is opaque, the modern GPUs apparently do not support RGB24).</p>
  
  <p>Is there any way to pass the pointer to the beginning of the buffer in the texture without making copies and calling <code>LoadRawTextureData()</code>? Or are the data in the Texture in a completely different format?</p>