- Home /
Performant update texture rectangle from unmanaged byte*
I have an library written in C, which creates a bitmap in CPU memory and updates parts of it regulary, I can access it via a byte*
. I want to update a Texture with the changes. How can I go about it in a performant way? I have tried to use Bufer.MemoryCopy()
to copy the blocks to a Color32
array and then use Texture2D.SetPixels()
but so far it is much slower then reloading the whole texture using LoadRawTextureData(IntPtr data, int size)
. Is there a better way?
From the documentation I would say passing the texture pointer to your c plugin and manipulate the texture directly would be the fastest way.
https://docs.unity3d.com/ScriptReference/Texture.GetNativeTexturePtr.html
Yea, so far it seams there is no way to avoid doing it in C. I will have to read up on how to do it in C.