I'm writing a plugin for unity, I need to send a texture from ios to unity.
There is a UnitySendMessage
function which takes char*
as parameter, but I didn't find a way to convert id<MTLTexture>
to char*
.
How can I send id<MTLTexture>
from ios and receive it in unity?
My current code :
//ios side ...
_texture = CVMetalTextureGetTexture(texture);
UnitySendMessage(CALLBACK_OBJECT, CALLBACK_TEXTURE_READY,_texture);//error
//...
//unity side
private void OnTextureReady(string texture_str)
{
IntPtr texture = new IntPtr(Int32.Parse(texture_str));
int width = 256;
int height = 256;
rawImage.texture = Texture2D.CreateExternalTexture(width, height,
TextureFormat.ARGB32, false, false, texture);
}