var srcTex = new Texture2D(width, height, format, mipChain, linear);
var nativeTex = srcTex.GetNativeTexturePtr();
var dstTex = Texture2D.CreateExternalTexture(width, height, format, mipChain, linear, nativeTex);
I am using a library which requires a native pointer texture, and performs a Texture2D.CreateExternalTexture() with this native pointer.
I tryed to create a normal Texture2D, retrive the NativeTexturePtr, then transmit to the library, but the UnityEditor crash in CreateExternalTexture.
Does someone have a solution to copy the native pointer from a Texture2D to another ?
Sincerely
PS: I am using Unity 2019.2.3f1 on Windows 10.
PS: This script is only for Editor Debug, but possibly Windows, Mac and Linux
Your nativeTex will contain the info needed to access the native texture in your external library
you don’t need to use CreateExternalTexture. This method will do the reverse, if your library would create a native texture then you can make a Unity Texture2D out of it with this method.
It is indeed a bug that Unity crashes with this code though.