# Runtime Web Viewer

## 👁️ RuntimeWebViewer Class

Works with a Web to provide runtime web viewing capabilities.

> Namespace: `Esper.SkillWeb.UI`\
> Inherits from: `MonoBehaviour`\
> Type: `abstract class`

***

### 📦 Fields

| Access   | Field         | Type      | Description                                                                     |
| -------- | ------------- | --------- | ------------------------------------------------------------------------------- |
| `public` | `web`         | `Web`     | The web.                                                                        |
| `public` | `webName`     | `string`  | The name of the web graph. This is used to automatically grab the web at start. |
| `public` | `loadOnStart` | `bool`    | If the web should be loaded on start.                                           |
| `public` | `centroid`    | `Vector2` | The center of all nodes.                                                        |

***

### 🔍 Properties

| Access          | Property          | Type                           | Description                                         |
| --------------- | ----------------- | ------------------------------ | --------------------------------------------------- |
| `public`        | `IsWebSet`        | `bool`                         | If a web is set.                                    |
| `public static` | `onLoadStarted`   | `UnityEvent<RuntimeWebViewer>` | A callback for when the web UI begins to load.      |
| `public static` | `onLoadCompleted` | `UnityEvent<RuntimeWebViewer>` | A callback for when the web UI is finished loading. |

***

### 🧰 Methods

| Access           | Method                            | Returns   | Description                                                                                                                                                                                     |
| ---------------- | --------------------------------- | --------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `public`         | `SetWeb(WebGraph)`                | `void`    | Sets the web.                                                                                                                                                                                   |
| `public`         | `SetWeb(Web)`                     | `void`    | Sets the web.                                                                                                                                                                                   |
| `public`         | `UnsetWeb()`                      | `void`    | Sets the web to null.                                                                                                                                                                           |
| `public`         | `AddToRevertableState(SkillNode)` | `void`    | Adds to the revertable state. If this is the first skill node added, the web will become revertable. The web is only revertable if changes have been made.                                      |
| `public`         | `ConfirmChanges()`                | `void`    | Confirms the changes made. The graph will not be revertable until changes are made once again.                                                                                                  |
| `public`         | `RevertChanges()`                 | `void`    | Reverts the changes made. The graph will not be revertable until changes are made once again.                                                                                                   |
| `public virtual` | `GetCenterPosition()`             | `Vector2` | Gets the center position of the web. This is more accurate than CalculateCenterPosition for custom UI objects added to the graph content. However, this should be used after the web is loaded. |
| `public virtual` | `CalculateCenterPosition()`       | `Vector2` | Calculates the center position of all nodes.                                                                                                                                                    |
