> ## Documentation Index
> Fetch the complete documentation index at: https://guide.daro.so/llms.txt
> Use this file to discover all available pages before exploring further.

# 리워드 비디오 광고

> Unity 프로젝트에서 DARO 리워드 비디오 광고를 구현하는 방법을 알아봅니다.

## 리워드 비디오 광고 형태 소개

* 사용자가 광고 시청을 선택하고, 시청 완료 후 보상을 받는 광고입니다.
* 보상 지급은 반드시 `OnEarnedReward` 이벤트에서 처리하세요.

![보상형 광고 예시](https://mintcdn.com/delightroom-5a71a6a8/dxU0bpsPoPvkYh_g/sdk-integration/common-img/ad-formats/rv-example-image.png?fit=max\&auto=format\&n=dxU0bpsPoPvkYh_g\&q=85\&s=42c4b8429cf25ce598c679e6eee00f70)

***

## 광고 연동하기

**1. 광고 인스턴스 생성**

```csharp theme={null}
private DaroRewardedAd ad;

ad = new DaroRewardedAd("your-rewarded-ad-unit-key");
```

**2. 이벤트 핸들러 등록**

```csharp theme={null}
ad.OnAdLoaded += info => Debug.Log("rewarded loaded");
ad.OnAdFailedToLoad += error => Debug.LogWarning(error.Message);
ad.OnEarnedReward += (info, reward) =>
{
    Debug.Log($"earned {reward.Amount} {reward.RewardType}");
};
```

**3. 광고 로드**

```csharp theme={null}
ad.Load();
```

**4. 광고 표시**

```csharp theme={null}
if (ad != null && ad.IsReady())
{
    ad.SetCustomData("user=12345");
    ad.Show();
}
```

**5. 광고 해제**

```csharp theme={null}
ad?.Dispose();
ad = null;
```

***

## Example

```csharp expandable theme={null}
using Daro;
using UnityEngine;

public sealed class RewardedHost : MonoBehaviour
{
    [SerializeField] private string adUnitKey = "your-rewarded-ad-unit-key";
    private DaroRewardedAd ad;

    private void OnEnable()
    {
        ad = new DaroRewardedAd(adUnitKey);
        ad.OnAdLoaded += info => Debug.Log("rewarded loaded");
        ad.OnAdFailedToLoad += error => Debug.LogWarning(error.Message);
        ad.OnEarnedReward += OnEarnedReward;
        ad.OnAdDismissed += info => ad?.Load();
        ad.Load();
    }

    public void ShowForReward()
    {
        if (ad != null && ad.IsReady())
        {
            ad.SetCustomData("user=12345");
            ad.Show();
        }
    }

    private void OnEarnedReward(DaroAdInfo info, DaroRewardItem reward)
    {
        Debug.Log($"earned {reward.Amount} {reward.RewardType}");
        // Grant the in-game reward here.
    }

    private void OnDisable()
    {
        ad?.Dispose();
        ad = null;
    }
}
```

> [!WARNING]
>
> `OnAdDismissed`에서 보상을 지급하지 마세요. 사용자가 광고를 끝까지 시청한 경우에만 `OnEarnedReward`가 호출됩니다.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.