---
description: v4.0
---

# Create a Custom Quest Reward

Often your game will have unique mechanics, and you may wish to include those as rewards.

Read on to learn more about the anatomy of a Quest Reward Inspector, or visit the pages below to create the required scripts, and then code your first custom Quest Reward.

{% content-ref url="create-a-custom-quest-reward/your-quest-reward" %}
[your-quest-reward](create-a-custom-quest-reward/your-quest-reward)
{% endcontent-ref %}

{% content-ref url="create-a-custom-quest-reward/your-quest-reward-editor" %}
[your-quest-reward-editor](create-a-custom-quest-reward/your-quest-reward-editor)
{% endcontent-ref %}

{% content-ref url="create-a-custom-quest-reward/your-quest-reward-drawer" %}
[your-quest-reward-drawer](create-a-custom-quest-reward/your-quest-reward-drawer)
{% endcontent-ref %}

{% embed url="https://www.youtube.com/watch?v=i9MHBTfAUQE" %}

## Anatomy of a Quest Reward Inspector

Each Quest Reward may have a different inspector. I've created custom Inspectors for each of the Quest Rewards that ship with Game Modules, however custom Inspectors are not required -- they're just a convenience and look prettier.

We will be looking at the `PointReward` reward.

<figure><img src="https://2431624982-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MY3N_li2jPq7az6mYfq%2Fuploads%2F3g6WL92OT1nb3FT1T64Q%2FScreenshot%202023-06-27%20at%209.41.51%20PM.png?alt=media&#x26;token=19257743-6d85-4d05-8bec-512ed7a01e81" alt=""><figcaption></figcaption></figure>

This is a "`PointReward`" `QuestReward`, which I've named "300 Experience". The top portion is the custom Inspector, while the bottom portion is the default Inspector. Both accomplish the same thing, and have the same fields exposed.

{% hint style="info" %}
If you create custom Quest Rewards, you can create custom Inspectors, or not -- entirely up to you. If you do choose to create custom Inspectors, you can follow the same pattern explained here.
{% endhint %}

There are three scripts that make up a fully formed Quest Reward which can be viewed in the Editor with a custom Inspector. See full details about creating your own on the pages nexted in this section.

### Class which inherits from QuestReward

The `PointReward` class inherits from `QuestReward`. This is the class which performs the actual reward code. The derived class is required to have their own version of `GiveReward()`.

```csharp
// Each derived class is required to have this method
public abstract void GiveReward(IUseGameModules owner);
```

### Editor Class

The `PointRewardEditor` class inherits from `QuestRewardEditor`, and is the script which tells Unity to draw a custom Inspector when the `PointReward` object is being viewed.

It overrides the `CreateDrawer()` method, and nothing else. While it does not seem like much, it is required for displaying the custom Inspector.

```csharp
protected override QuestRewardDrawer CreateDrawer()
{
    questRewardDrawer = ScriptableObject.CreateInstance<PointRewardDrawer>();
    return questRewardDrawer;
}
```

### Drawer Class

Finally the `PointRewardDrawer` class inherits from `QuestRewardDrawer`. This is the class which does the actual drawing of the custom Inspector.

This is using the static class `InfinityPBR.InfinityEditor`, which you can also use to make your own custom Inspectors.

```csharp
public override bool CanHandle(QuestReward questReward) 
    => questReward is PointReward;

protected override void ShowSpecificData(QuestReward questReward) 
    => ShowDataForPointReward(questReward as PointReward);
       
private void ShowDataForPointReward(PointReward questReward)
{
    // Draw Stuff
}
```
