# UnityInterface

> Class

Inheritance

* [object](https://learn.microsoft.com/dotnet/api/system.object)
* [Interface](./api_interface)
* UnityInterface

***

Inherited Members

* [Equals(object)](https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals\(system-object\))

* [Equals(object, object)](https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals\(system-object-system-object\))

* [GetHashCode()](https://learn.microsoft.com/dotnet/api/system.object.gethashcode)

* [GetType()](https://learn.microsoft.com/dotnet/api/system.object.gettype)

* [MemberwiseClone()](https://learn.microsoft.com/dotnet/api/system.object.memberwiseclone)

* [ReferenceEquals(object, object)](https://learn.microsoft.com/dotnet/api/system.object.referenceequals)

* [ToString()](https://learn.microsoft.com/dotnet/api/system.object.tostring)

***

Namespace: UnityEngine.Pixyz.Unity

```csharp
public class UnityInterface : Interface
```

## Methods

### GetLastError

```csharp
public static string GetLastError()
```

Returns

| Type                                                           | Description |
| -------------------------------------------------------------- | ----------- |
| [string](https://learn.microsoft.com/dotnet/api/system.string) |             |

### ConfigureFunctionLogger

```csharp
[HandleProcessCorruptedStateExceptions]
public void ConfigureFunctionLogger(string functionName, bool enableFunction, bool enableParameters, bool enableExecutionTime)
```

Parameters

| Type                                                           | Name                | Description |
| -------------------------------------------------------------- | ------------------- | ----------- |
| [string](https://learn.microsoft.com/dotnet/api/system.string) | functionName        |             |
| [bool](https://learn.microsoft.com/dotnet/api/system.boolean)  | enableFunction      |             |
| [bool](https://learn.microsoft.com/dotnet/api/system.boolean)  | enableParameters    |             |
| [bool](https://learn.microsoft.com/dotnet/api/system.boolean)  | enableExecutionTime |             |

### GetD3D11Device

```csharp
[HandleProcessCorruptedStateExceptions]
public IntPtr GetD3D11Device()
```

Returns

| Type                                                           | Description |
| -------------------------------------------------------------- | ----------- |
| [IntPtr](https://learn.microsoft.com/dotnet/api/system.intptr) |             |

### GetD3D11RenderTargetViewFromRenderBuffer

```csharp
[HandleProcessCorruptedStateExceptions]
public IntPtr GetD3D11RenderTargetViewFromRenderBuffer(IntPtr surface)
```

Parameters

| Type                                                           | Name    | Description |
| -------------------------------------------------------------- | ------- | ----------- |
| [IntPtr](https://learn.microsoft.com/dotnet/api/system.intptr) | surface |             |

Returns

| Type                                                           | Description |
| -------------------------------------------------------------- | ----------- |
| [IntPtr](https://learn.microsoft.com/dotnet/api/system.intptr) |             |

### GetD3D11ShaderResourceViewFromNativeTexture

```csharp
[HandleProcessCorruptedStateExceptions]
public IntPtr GetD3D11ShaderResourceViewFromNativeTexture(uint texture)
```

Parameters

| Type                                                         | Name    | Description |
| ------------------------------------------------------------ | ------- | ----------- |
| [uint](https://learn.microsoft.com/dotnet/api/system.uint32) | texture |             |

Returns

| Type                                                           | Description |
| -------------------------------------------------------------- | ----------- |
| [IntPtr](https://learn.microsoft.com/dotnet/api/system.intptr) |             |

### GetD3D11TextureFromNativeTexture

```csharp
[HandleProcessCorruptedStateExceptions]
public IntPtr GetD3D11TextureFromNativeTexture(uint texture)
```

Parameters

| Type                                                         | Name    | Description |
| ------------------------------------------------------------ | ------- | ----------- |
| [uint](https://learn.microsoft.com/dotnet/api/system.uint32) | texture |             |

Returns

| Type                                                           | Description |
| -------------------------------------------------------------- | ----------- |
| [IntPtr](https://learn.microsoft.com/dotnet/api/system.intptr) |             |

### GetD3D11TextureFromRenderBuffer

```csharp
[HandleProcessCorruptedStateExceptions]
public IntPtr GetD3D11TextureFromRenderBuffer(IntPtr buffer)
```

Parameters

| Type                                                           | Name   | Description |
| -------------------------------------------------------------- | ------ | ----------- |
| [IntPtr](https://learn.microsoft.com/dotnet/api/system.intptr) | buffer |             |

Returns

| Type                                                           | Description |
| -------------------------------------------------------------- | ----------- |
| [IntPtr](https://learn.microsoft.com/dotnet/api/system.intptr) |             |

### GetDestroyFunction

```csharp
[HandleProcessCorruptedStateExceptions]
public IntPtr GetDestroyFunction()
```

Returns

| Type                                                           | Description |
| -------------------------------------------------------------- | ----------- |
| [IntPtr](https://learn.microsoft.com/dotnet/api/system.intptr) |             |

### GetDrawFunction

```csharp
[HandleProcessCorruptedStateExceptions]
public IntPtr GetDrawFunction()
```

Returns

| Type                                                           | Description |
| -------------------------------------------------------------- | ----------- |
| [IntPtr](https://learn.microsoft.com/dotnet/api/system.intptr) |             |

### GetInitFunction

```csharp
[HandleProcessCorruptedStateExceptions]
public IntPtr GetInitFunction()
```

Returns

| Type                                                           | Description |
| -------------------------------------------------------------- | ----------- |
| [IntPtr](https://learn.microsoft.com/dotnet/api/system.intptr) |             |

### AsyncPick

Asynchronous function to pick in the current viewer.

```csharp
[HandleProcessCorruptedStateExceptions]
public void AsyncPick(uint session, int x, int y)
```

Parameters

| Type                                                         | Name    | Description |
| ------------------------------------------------------------ | ------- | ----------- |
| [uint](https://learn.microsoft.com/dotnet/api/system.uint32) | session |             |
| [int](https://learn.microsoft.com/dotnet/api/system.int32)   | x       |             |
| [int](https://learn.microsoft.com/dotnet/api/system.int32)   | y       |             |

### 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.

```csharp
[HandleProcessCorruptedStateExceptions]
public void AsyncResize(uint session, int width, int height)
```

Parameters

| Type                                                         | Name    | Description    |
| ------------------------------------------------------------ | ------- | -------------- |
| [uint](https://learn.microsoft.com/dotnet/api/system.uint32) | session |                |
| [int](https://learn.microsoft.com/dotnet/api/system.int32)   | width   | Viewer width.  |
| [int](https://learn.microsoft.com/dotnet/api/system.int32)   | height  | Viewer height. |

### CreateUnityViewSession

```csharp
[HandleProcessCorruptedStateExceptions]
public uint CreateUnityViewSession(int width, int height, GraphicAPI graphicAPI, int nbViews = 1)
```

Parameters

| Type                                                       | Name       | Description                |
| ---------------------------------------------------------- | ---------- | -------------------------- |
| [int](https://learn.microsoft.com/dotnet/api/system.int32) | width      | Viewer width.              |
| [int](https://learn.microsoft.com/dotnet/api/system.int32) | height     | Viewer height.             |
| [GraphicAPI](./view_graphicapi)                            | graphicAPI | Graphic api used by Unity. |
| [int](https://learn.microsoft.com/dotnet/api/system.int32) | nbViews    | Nb views.                  |

Returns

| Type                                                         | Description |
| ------------------------------------------------------------ | ----------- |
| [uint](https://learn.microsoft.com/dotnet/api/system.uint32) |             |

### AddUnityViewSessionDestroyedCallback

```csharp
public uint AddUnityViewSessionDestroyedCallback(UnityInterface.UnityViewSessionDestroyedDelegate callback, IntPtr userData)
```

Parameters

| Type                                                                                                   | Name     | Description |
| ------------------------------------------------------------------------------------------------------ | -------- | ----------- |
| [UnityInterface.UnityViewSessionDestroyedDelegate](./unityinterface_unityviewsessiondestroyeddelegate) | callback |             |
| [IntPtr](https://learn.microsoft.com/dotnet/api/system.intptr)                                         | userData |             |

Returns

| Type                                                         | Description |
| ------------------------------------------------------------ | ----------- |
| [uint](https://learn.microsoft.com/dotnet/api/system.uint32) |             |

### RemoveUnityViewSessionDestroyedCallback

```csharp
public void RemoveUnityViewSessionDestroyedCallback(uint id)
```

Parameters

| Type                                                         | Name | Description |
| ------------------------------------------------------------ | ---- | ----------- |
| [uint](https://learn.microsoft.com/dotnet/api/system.uint32) | id   |             |

### AddUnityViewSessionHasPickedCallback

```csharp
public uint AddUnityViewSessionHasPickedCallback(UnityInterface.UnityViewSessionHasPickedDelegate callback, IntPtr userData)
```

Parameters

| Type                                                                                                   | Name     | Description |
| ------------------------------------------------------------------------------------------------------ | -------- | ----------- |
| [UnityInterface.UnityViewSessionHasPickedDelegate](./unityinterface_unityviewsessionhaspickeddelegate) | callback |             |
| [IntPtr](https://learn.microsoft.com/dotnet/api/system.intptr)                                         | userData |             |

Returns

| Type                                                         | Description |
| ------------------------------------------------------------ | ----------- |
| [uint](https://learn.microsoft.com/dotnet/api/system.uint32) |             |

### RemoveUnityViewSessionHasPickedCallback

```csharp
public void RemoveUnityViewSessionHasPickedCallback(uint id)
```

Parameters

| Type                                                         | Name | Description |
| ------------------------------------------------------------ | ---- | ----------- |
| [uint](https://learn.microsoft.com/dotnet/api/system.uint32) | id   |             |

### AddUnityViewSessionInitializedCallback

```csharp
public uint AddUnityViewSessionInitializedCallback(UnityInterface.UnityViewSessionInitializedDelegate callback, IntPtr userData)
```

Parameters

| Type                                                                                                       | Name     | Description |
| ---------------------------------------------------------------------------------------------------------- | -------- | ----------- |
| [UnityInterface.UnityViewSessionInitializedDelegate](./unityinterface_unityviewsessioninitializeddelegate) | callback |             |
| [IntPtr](https://learn.microsoft.com/dotnet/api/system.intptr)                                             | userData |             |

Returns

| Type                                                         | Description |
| ------------------------------------------------------------ | ----------- |
| [uint](https://learn.microsoft.com/dotnet/api/system.uint32) |             |

### RemoveUnityViewSessionInitializedCallback

```csharp
public void RemoveUnityViewSessionInitializedCallback(uint id)
```

Parameters

| Type                                                         | Name | Description |
| ------------------------------------------------------------ | ---- | ----------- |
| [uint](https://learn.microsoft.com/dotnet/api/system.uint32) | id   |             |

### AddUnityViewSessionResizedCallback

```csharp
public uint AddUnityViewSessionResizedCallback(UnityInterface.UnityViewSessionResizedDelegate callback, IntPtr userData)
```

Parameters

| Type                                                                                               | Name     | Description |
| -------------------------------------------------------------------------------------------------- | -------- | ----------- |
| [UnityInterface.UnityViewSessionResizedDelegate](./unityinterface_unityviewsessionresizeddelegate) | callback |             |
| [IntPtr](https://learn.microsoft.com/dotnet/api/system.intptr)                                     | userData |             |

Returns

| Type                                                         | Description |
| ------------------------------------------------------------ | ----------- |
| [uint](https://learn.microsoft.com/dotnet/api/system.uint32) |             |

### RemoveUnityViewSessionResizedCallback

```csharp
public void RemoveUnityViewSessionResizedCallback(uint id)
```

Parameters

| Type                                                         | Name | Description |
| ------------------------------------------------------------ | ---- | ----------- |
| [uint](https://learn.microsoft.com/dotnet/api/system.uint32) | id   |             |

### GetVulkanDevice

```csharp
[HandleProcessCorruptedStateExceptions]
public IntPtr GetVulkanDevice()
```

Returns

| Type                                                           | Description |
| -------------------------------------------------------------- | ----------- |
| [IntPtr](https://learn.microsoft.com/dotnet/api/system.intptr) |             |
