CreateExternalTexture - error - nativeTex can not be null

I recently updated to Unity 2017 and now the following line is failing:

SurfaceTexture = Texture2D.CreateExternalTexture(DEFAULT_SURFACE_WIDTH, DEFAULT_SURFACE_HEIGHT, TextureFormat.RGBA32, true, false, IntPtr.Zero);

The error is: ArgumentException: nativeTex can not be null

So it seems that I can no longer pass IntPtr.Zero as the last argument in CreateExternalTexture.

Does anyone know what I should be doing instead? For context, this is for the Android Platform

Thanks!
Sunny

I fixed it by creating a texture2d with same attributes and passing it into CreateExternalTexture as a native pointer

Texture2D tex = new Texture2D(DEFAULT_SURFACE_WIDTH, DEFAULT_SURFACE_HEIGHT, TextureFormat.RGBA32, true, false);         
IntPtr texPtr = tex.GetNativeTexturePtr();
SurfaceTexture = Texture2D.CreateExternalTexture(DEFAULT_SURFACE_WIDTH, DEFAULT_SURFACE_HEIGHT, TextureFormat.RGBA32, true, false, texPtr);

I use Unity 2018.2.0f2, but It seems the unity editor will crash when createExternalTexture.

Old thread, but same crash on Unity 2019.2.3f1

Does someone have a solution to copy the native pointer from a Texture2D to another ?

Does anyone have any solution for this?

Crashes in 2019.2.12f1 as well :frowning: