What about buffers?
Closed this issue ยท 2 comments
This incredible project shows us how to use TextureUpdateCallback
to move
textures from iOS native code -> Unity
In the "old days" you had to use a native plugin, such as explained in the famous example at the bottom of this page: https://docs.unity3d.com/Manual/NativePluginInterface.html
(Aside - Unfortunately, that demo has never worked for iOS; and I believe nobody has ever got that process working for iOS.)
So TextureUpdateCallback is a miracle for
textures from iOS native code -> Unity
But what about
buffers (like vertex buffers, matrices etc) from iOS native code -> Unity
Very often you want to load up buffers, in the native iOS code, and send that back to Unity (usually to use in a shader each frame).
Is there a way to do this?
The short answer is no, there is no such easy way to update buffer from a native plugin.
One possible alternative is using ComputeBuffer.SetData<T>(NativeArray<T>)
. You can easily update a NativeArray
from a native plugin via an unsafe pointer, then apply it to a compute buffer on the C# side using SetData
.
Thanks for the prompt answer - understood.
And that's a great idea about SetData hanks for that.
It would be great to have an example project for SetData .
Thanks again