CreateExternalTexture(int, int, TextureFormat, bool, bool, nint)
Creates a Unity Texture out of an externally created native texture object.
Read time 1 minuteLast updated 6 days ago
Definition
- Type: Method
- Namespace: UnityEngine
- Assembly: UnityEngine.CoreModule
CreateExternalTexture(int, int, TextureFormat, bool, bool, IntPtr)
public static Texture2D CreateExternalTexture(int width, int height, TextureFormat format, bool mipChain, bool linear, nint nativeTex)
Parameters
Returns
Type | Description |
|---|---|
| Texture2D |
Remarks
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.
For Direct3D-like devices, the parameter is a pointer to the underlying Direct3D base type, from which a texture can be created. They can be:
nativeTex• D3D11: or
ID3D11ShaderResourceView*ID3D11Texture2D*• D3D12:
ID3D12Resource*For OpenGL/OpenGL ES, the parameter is a .
nativeTexGLuintFor Metal, the parameter is an .
nativeTexid<MTLTexture>For Vulkan, the parameter is a .
nativeTexVkImage*Additional Resources: Texture2D.UpdateExternalTexture, Texture.GetNativeTexturePtr().