Did GetNativeTextureID() change recently?

It seems that somewhere between Unity 4.6.2 and 4.6.5, GetNativeTextureID() changed behavior in iOS and Android. It used to return the texture “name”, which was often a two-digit ID, and was then usable with

glBindTexture(GL_TEXTURE_2D, textureId);

But now with 4.6.5, it returns a large number, and glBindTexture does not work.

I’ve run the below code in both versions:

    var textureId = (int) frame.renderer.material.mainTexture.GetNativeTexturePtr ();
    Debug.Log ("Texture ID: " + textureId + " " + frame.renderer.material.mainTexture.GetNativeTextureID());

the output of which is:

4.6.2:

Texture ID: 22 22
4.6.5:
Texture ID: 405458832 395710264

Notice that the pointer and ID are both large numbers, but not the same.

There’s nothing that I can see in the release notes of any mention of this behavior between 4.6.2 to 4.6.5. So… any ideas?

It’s because of the move to Metal on iOS in 4.6.3.

You can get the pointer to the Metal texture like this:

 id<MTLTexture> tex = (id<MTLTexture>) textureId;

Examples of how to do this are here:

https://bitbucket.org/Unity-Technologies/iosnativecodesamples