# Unity

> Python API functions

### configureFunctionLogger

```python
unity.configureFunctionLogger(functionName, enableFunction, enableParameters, enableExecutionTime)
```

Parameters

| Type                            | Name                | Description |
| ------------------------------- | ------------------- | ----------- |
| [String](./core_types#string)   | functionName        |             |
| [Boolean](./core_types#boolean) | enableFunction      |             |
| [Boolean](./core_types#boolean) | enableParameters    |             |
| [Boolean](./core_types#boolean) | enableExecutionTime |             |

## Direct3D

### getD3D11Device

```python
unity.getD3D11Device() -> unity.ID3D11Device
```

Returns

| Type                                       | Name   | Description |
| ------------------------------------------ | ------ | ----------- |
| [ID3D11Device](./unity_types#id3d11device) | device |             |

See also:

* [unity.getD3D11RenderTargetViewFromRenderBuffer](./unity_functions#getd3d11rendertargetviewfromrenderbuffer)
* [unity.getD3D11ShaderResourceViewFromNativeTexture](./unity_functions#getd3d11shaderresourceviewfromnativetexture)
* [unity.getD3D11TextureFromNativeTexture](./unity_functions#getd3d11texturefromnativetexture)
* [unity.getD3D11TextureFromRenderBuffer](./unity_functions#getd3d11texturefromrenderbuffer)

### getD3D11RenderTargetViewFromRenderBuffer

```python
unity.getD3D11RenderTargetViewFromRenderBuffer(surface) -> unity.ID3D11RenderTargetView
```

Parameters

| Type                                                 | Name    | Description |
| ---------------------------------------------------- | ------- | ----------- |
| [UnityRenderBuffer](./unity_types#unityrenderbuffer) | surface |             |

Returns

| Type                                                           | Name | Description |
| -------------------------------------------------------------- | ---- | ----------- |
| [ID3D11RenderTargetView](./unity_types#id3d11rendertargetview) | rtv  |             |

See also:

* [unity.getD3D11Device](./unity_functions#getd3d11device)
* [unity.getD3D11ShaderResourceViewFromNativeTexture](./unity_functions#getd3d11shaderresourceviewfromnativetexture)
* [unity.getD3D11TextureFromNativeTexture](./unity_functions#getd3d11texturefromnativetexture)
* [unity.getD3D11TextureFromRenderBuffer](./unity_functions#getd3d11texturefromrenderbuffer)

### getD3D11ShaderResourceViewFromNativeTexture

```python
unity.getD3D11ShaderResourceViewFromNativeTexture(texture) -> unity.ID3D11ShaderResourceView
```

Parameters

| Type                                           | Name    | Description |
| ---------------------------------------------- | ------- | ----------- |
| [UnityTextureID](./unity_types#unitytextureid) | texture |             |

Returns

| Type                                                               | Name | Description |
| ------------------------------------------------------------------ | ---- | ----------- |
| [ID3D11ShaderResourceView](./unity_types#id3d11shaderresourceview) | srv  |             |

See also:

* [unity.getD3D11Device](./unity_functions#getd3d11device)
* [unity.getD3D11RenderTargetViewFromRenderBuffer](./unity_functions#getd3d11rendertargetviewfromrenderbuffer)
* [unity.getD3D11TextureFromNativeTexture](./unity_functions#getd3d11texturefromnativetexture)
* [unity.getD3D11TextureFromRenderBuffer](./unity_functions#getd3d11texturefromrenderbuffer)

### getD3D11TextureFromNativeTexture

```python
unity.getD3D11TextureFromNativeTexture(texture) -> unity.ID3D11Resource
```

Parameters

| Type                                           | Name    | Description |
| ---------------------------------------------- | ------- | ----------- |
| [UnityTextureID](./unity_types#unitytextureid) | texture |             |

Returns

| Type                                           | Name      | Description |
| ---------------------------------------------- | --------- | ----------- |
| [ID3D11Resource](./unity_types#id3d11resource) | dxTexture |             |

See also:

* [unity.getD3D11Device](./unity_functions#getd3d11device)
* [unity.getD3D11RenderTargetViewFromRenderBuffer](./unity_functions#getd3d11rendertargetviewfromrenderbuffer)
* [unity.getD3D11ShaderResourceViewFromNativeTexture](./unity_functions#getd3d11shaderresourceviewfromnativetexture)
* [unity.getD3D11TextureFromRenderBuffer](./unity_functions#getd3d11texturefromrenderbuffer)

### getD3D11TextureFromRenderBuffer

```python
unity.getD3D11TextureFromRenderBuffer(buffer) -> unity.ID3D11Resource
```

Parameters

| Type                                                 | Name   | Description |
| ---------------------------------------------------- | ------ | ----------- |
| [UnityRenderBuffer](./unity_types#unityrenderbuffer) | buffer |             |

Returns

| Type                                           | Name      | Description |
| ---------------------------------------------- | --------- | ----------- |
| [ID3D11Resource](./unity_types#id3d11resource) | dxTexture |             |

See also:

* [unity.getD3D11Device](./unity_functions#getd3d11device)
* [unity.getD3D11RenderTargetViewFromRenderBuffer](./unity_functions#getd3d11rendertargetviewfromrenderbuffer)
* [unity.getD3D11ShaderResourceViewFromNativeTexture](./unity_functions#getd3d11shaderresourceviewfromnativetexture)
* [unity.getD3D11TextureFromNativeTexture](./unity_functions#getd3d11texturefromnativetexture)

## Unity Pugin Event Functions

### getDestroyFunction

```python
unity.getDestroyFunction() -> unity.UnityRenderingEvent
```

Returns

| Type                                                     | Name            | Description |
| -------------------------------------------------------- | --------------- | ----------- |
| [UnityRenderingEvent](./unity_types#unityrenderingevent) | destroyFunction |             |

See also:

* [unity.getDrawFunction](./unity_functions#getdrawfunction)
* [unity.getInitFunction](./unity_functions#getinitfunction)

### getDrawFunction

```python
unity.getDrawFunction() -> unity.UnityRenderingEventAndData
```

Returns

| Type                                                                   | Name         | Description |
| ---------------------------------------------------------------------- | ------------ | ----------- |
| [UnityRenderingEventAndData](./unity_types#unityrenderingeventanddata) | drawFunction |             |

See also:

* [unity.getDestroyFunction](./unity_functions#getdestroyfunction)
* [unity.getInitFunction](./unity_functions#getinitfunction)

### getInitFunction

```python
unity.getInitFunction() -> unity.UnityRenderingEvent
```

Returns

| Type                                                     | Name         | Description |
| -------------------------------------------------------- | ------------ | ----------- |
| [UnityRenderingEvent](./unity_types#unityrenderingevent) | initFunction |             |

See also:

* [unity.getDestroyFunction](./unity_functions#getdestroyfunction)
* [unity.getDrawFunction](./unity_functions#getdrawfunction)

## Unity View Session

### asyncPick

Asynchronous function to pick in the current viewer.

```python
unity.asyncPick(session, x, y)
```

Parameters

| Type                                               | Name    | Description |
| -------------------------------------------------- | ------- | ----------- |
| [UnityViewSession](./unity_types#unityviewsession) | session |             |
| [Int](./core_types#int)                            | x       |             |
| [Int](./core_types#int)                            | y       |             |

See also:

* [unity.asyncResize](./unity_functions#asyncresize)
* [unity.createUnityViewSession](./unity_functions#createunityviewsession)

### asyncResize

Call this function when the texture has to be resized. the resize will take effect during the next render. This will send a ViewSessionResized event when done.

```python
unity.asyncResize(session, width, height)
```

Parameters

| Type                                               | Name    | Description    |
| -------------------------------------------------- | ------- | -------------- |
| [UnityViewSession](./unity_types#unityviewsession) | session |                |
| [Int](./core_types#int)                            | width   | Viewer width.  |
| [Int](./core_types#int)                            | height  | Viewer height. |

See also:

* [unity.asyncPick](./unity_functions#asyncpick)
* [unity.createUnityViewSession](./unity_functions#createunityviewsession)

### createUnityViewSession

```python
unity.createUnityViewSession(width, height, graphicAPI, nbViews=1) -> unity.UnityViewSession
```

Parameters

| Type                                  | Name       | Description                |
| ------------------------------------- | ---------- | -------------------------- |
| [Int](./core_types#int)               | width      | Viewer width.              |
| [Int](./core_types#int)               | height     | Viewer height.             |
| [GraphicAPI](./view_types#graphicapi) | graphicAPI | Graphic api used by Unity. |
| [Int](./core_types#int)               | nbViews    | Nb views.                  |

Returns

| Type                                               | Name    | Description |
| -------------------------------------------------- | ------- | ----------- |
| [UnityViewSession](./unity_types#unityviewsession) | session |             |

See also:

* [unity.asyncPick](./unity_functions#asyncpick)
* [unity.asyncResize](./unity_functions#asyncresize)

## Vulkan

### getVulkanDevice

```python
unity.getVulkanDevice() -> unity.VulkanDevice
```

Returns

| Type                                       | Name     | Description |
| ------------------------------------------ | -------- | ----------- |
| [VulkanDevice](./unity_types#vulkandevice) | vkDevice |             |
