Version: 2019.1 (switch to 2018.3 or 2017.4)
LanguageEnglish
  • C#

Texture2D.CreateExternalTexture

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

public static Texture2D CreateExternalTexture(int width, int height, TextureFormat format, bool mipChain, bool linear, IntPtr nativeTex);

Parameters

nativeTexNative 2D texture object.
widthWidth of texture in pixels.
heightHeight of texture in pixels.
formatFormat of underlying texture object.
mipmapDoes the texture have mipmaps?
linearIs texture using linear color space?

Description

Creates Unity Texture out of externally created native texture object.

This function is mostly useful for native code plugins that create platform specific texture objects outside of Unity, and need to use these textures in Unity Scenes. It is also possible to create a texture in Unity and get a pointer to the underlying platform representation; see Texture.GetNativeTexturePtr.

Parameters passed to CreateExternalTexture should match what the texture actually is; and the underlying texture should be 2D (Cubemaps or 3D textures will not work).

Native texture object on Direct3D-like devices is a pointer to the base type, from which a texture can be created (IDirect3DBaseTexture9 on D3D9, ID3D11ShaderResourceView on D3D11). On OpenGL/OpenGL ES it is GLuint. On Metal it is id<MTLTexture>.

See Also: UpdateExternalTexture, Texture.GetNativeTexturePtr.

Did you find this page useful? Please give it a rating: