# CreateExternalTexture(int, TextureFormat, bool, nint)

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

## Definition

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

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

```csharp
public static Cubemap CreateExternalTexture(int width, TextureFormat format, bool mipmap, nint nativeTex)
```

### Parameters

**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): **** (\[TextureFormat]\(/engine/6000.7/script-reference/unityengine/textureformat)): Format of underlying cubemap object.**** (\[bool]\(https\://learn.microsoft.com/dotnet/api/system.boolean)): Does the cubemap have mipmaps?**** (\[IntPtr]\(https\://learn.microsoft.com/dotnet/api/system.intptr)): Native cubemap texture object.

### Returns

| Type                                                              | Description |
| ----------------------------------------------------------------- | ----------- |
| [Cubemap](/engine/6000.7/script-reference/unityengine/cubemap.md) |             |

### Remarks

This function is mostly useful for [native code plugins](/engine/6000.7/manual/scripting/compilation-and-code-reload/plug-ins/native-plugin-interface.md) that create platform specific cubemap texture objects outside of Unity, and need to use these cubemaps in Unity Scenes. It is also possible to create a cubemap in Unity and get a pointer to the underlying platform representation; see [Texture.GetNativeTexturePtr()](/engine/6000.7/script-reference/unityengine/texture/getnativetextureptr.md).

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

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 `ID3D11Texture2D*`

• **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: [Cubemap.UpdateExternalTexture](/engine/6000.7/script-reference/unityengine/cubemap/updateexternaltexture.md), [Texture.GetNativeTexturePtr()](/engine/6000.7/script-reference/unityengine/texture/getnativetextureptr.md).
