> For the complete documentation index, see [llms.txt](https://espergames.gitbook.io/inventool/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://espergames.gitbook.io/inventool/general/dataset-setup.md). Agents can also search and read this documentation through its [MCP server](https://espergames.gitbook.io/inventool/~gitbook/mcp).

# Dataset Setup

Instructions for setting up a dataset.

A dataset is used to assign custom static data to the item. It's good for referencing Unity objects such as the item prefab that should be applied to the player character when the item is equipped, VFX assets to apply to the item, or anything else related to the item.

## Setup Steps

#### Step 1: Create Your Dataset

Create a class that inherits from Dataset and add your custom fields.

```csharp
using Esper.Inventool.Items;
using UnityEngine;

[CreateAssetMenu(fileName = "Custom Dataset", menuName = "Inventool/Custom Dataset")]
public class CustomDataset : Dataset
{
    public GameObject itemPrefab;
}
```

#### Step 2: Create An Instance

<figure><img src="https://658062748-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkBIjnmm9A7LqfwoDhaeR%2Fuploads%2FZAsR9uJWoMO5rFu0yxVs%2Fimage.png?alt=media&amp;token=f08d82ee-9f7e-4488-aba4-47b2666a2361" alt="" width="442"><figcaption></figcaption></figure>

Create an instance of the dataset by right-clicking in the project section and navigating to the menu option created in [#step-1-create-your-dataset](#step-1-create-your-dataset "mention").

#### Step 3: Assign Dataset In Settings

<figure><img src="https://658062748-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkBIjnmm9A7LqfwoDhaeR%2Fuploads%2FKAF47iettXIKJhHdJtb3%2Fimage.png?alt=media&amp;token=b133c3ed-cfc1-43cb-9b66-a758b269df03" alt="" width="320"><figcaption></figcaption></figure>

{% hint style="info" %}
Editing a dataset does not require reassignment.
{% endhint %}

Open settings from **Window > Inventool > Settings** and drag and drop the dataset instance into the **Dataset** field. A prompt will open asking you to confirm the action. Click "confirm," **but remember, all previous dataset data will be lost for all items.**

#### Step 4: Final Notes

The dataset should be set up. Open the object manager and select an item. You will see new options in the **Dataset** section. You may now freely use the new fields.

You can set methods you add to your dataset on the **On Equip**, **On Unequip**, and **On Consume** fields.

Within a dataset method, you can access the target object through conversion like this:

```csharp
public void MyOnConsumeMethod()
{
    ItemStack targetItemStack = onConsumeMethod.invokeTarget as ItemStack;
    // Your code here...
}
```

Remember to use the appropriate field for each method. For example, for the equip method, you would use `onEquipMethod.invokeTarget` instead of `onConsumeMethod.invokeTarget`.

Here are the target object types for each field:

* Equip: `Slot`
* Unequip: `Slot`
* Consume: `ItemStack`

At runtime, you can access a dataset from an `ItemStack` like this:

```csharp
var customDataset = myItemStack.item.dataset as CustomDataset;
```
