# Character Viewer

## 🎥 CharacterViewer Class

Provides interactive character preview with rotation and reset.

> **Namespace:** `Esper.Inventool.UI`\
> **Access:** `public`\
> **Type:** `class`\
> **Inherits:** `MonoBehaviour`

***

### 📦 Fields

| Access    | Field               | Type      | Description                             |
| --------- | ------------------- | --------- | --------------------------------------- |
| `public`  | `cam`               | `Camera`  | The character view camera.              |
| `private` | `startingRotation`  | `Vector2` | Cached initial rotation angles.         |
| `private` | `isResetting`       | `bool`    | True while auto-reset is in progress.   |
| `public`  | `onRotationChanged` | `Action`  | Callback invoked when rotation changes. |

***

### 🔍 Properties

| Access   | Property               | Type            | Description                              |
| -------- | ---------------------- | --------------- | ---------------------------------------- |
| `public` | `IsInStartingRotation` | `bool`          | True if rotation within 1° of the start. |
| `public` | `Render`               | `RenderTexture` | The camera’s render texture.             |

***

### 🧰 Methods

| Access    | Method                     | Returns       | Description                                          |
| --------- | -------------------------- | ------------- | ---------------------------------------------------- |
| `private` | `Awake()`                  | `void`        | Cache camera, remove audio listener, store rotation. |
| `public`  | `ResetRotation()`          | `void`        | Begin smooth reset of rotation.                      |
| `private` | `ResetRotationCoroutine()` | `IEnumerator` | Interpolate rotation back to start over time.        |
| `public`  | `Rotate(Vector2 rotation)` | `void`        | Apply manual rotation and invoke callback.           |

***

## Rotate

Rotating requires a `Vector2` that represents the new rotation. The `Rotate` method essentially sets the new view rotation.

```csharp
myCharacterViewer.Rotate(myVector2);
```

### Reset Rotation

Use `ResetRotation` to reset the rotation over a small period of time.

```csharp
myCharacterViewer.ResetRotation();
```
