# CreateExternalTexture(int, int, int, TextureFormat, bool, IntPtr)

> Creates a Unity Texture out of an externally created native texture object.

## Definition

* **Type:** Method
* **Namespace:** [UnityEngine](/engine/6000.0/script-reference/unityengine.md)
* **Assembly:** UnityEngine.CoreModule

```csharp
public static Texture3D CreateExternalTexture(int width, int height, int depth, TextureFormat format, bool mipChain, IntPtr nativeTex)
```

### Parameters

**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): Width of texture in pixels.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): Height of texture in pixels.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): Depth of texture in pixels.**** (\[TextureFormat]\(/engine/6000.0/script-reference/unityengine/textureformat)): Format of underlying texture object.**** (\[bool]\(https\://learn.microsoft.com/dotnet/api/system.boolean)): **** (\[IntPtr]\(https\://learn.microsoft.com/dotnet/api/system.intptr)): Native 3D texture object.

### Returns

| Type                                                                  | Description |
| --------------------------------------------------------------------- | ----------- |
| [Texture3D](/engine/6000.0/script-reference/unityengine/texture3d.md) |             |

### Remarks

This function is mostly useful for [native code plugins](/engine/6000.0/manual/scripting/compilation-and-code-reload/plug-ins/native-plugin-interface.md) 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()](/engine/6000.0/script-reference/unityengine/texture/getnativetextureptr.md).

Parameters passed to CreateExternalTexture should match what the texture actually is; and the underlying texture should be 3D.

For **Direct3D**-like devices, the `nativeTex` parameter is a pointer to the underlying **Direct3D** base type, from which a texture can be created. They can be:

• **D3D11**: `ID3D11ShaderResourceView*` or `ID3D11Texture3D*`

• **D3D12**: `ID3D12Resource*`

For **OpenGL**/**OpenGL ES**, the `nativeTex` parameter is a `GLuint`.

For **Metal**, the `nativeTex` parameter is an `id<MTLTexture>`.

For **Vulkan**, the `nativeTex` parameter is a `VkImage*`.

Additional Resources: [Texture3D.UpdateExternalTexture](/engine/6000.0/script-reference/unityengine/texture3d/updateexternaltexture.md), [Texture.GetNativeTexturePtr()](/engine/6000.0/script-reference/unityengine/texture/getnativetextureptr.md).
