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

# 네이티브 광고

> Unity 프로젝트에서 DARO 네이티브 광고를 구현하는 방법을 알아봅니다.

## 네이티브 광고 형태 소개

* 앱 UI에 맞게 광고 자산을 직접 배치하는 광고입니다.
* Unity UI 프리팹에 `DaroNativeAdView`를 붙여 슬롯을 연결하거나, `DaroNativeAd.Info`를 직접 읽어 커스텀 UI에 바인딩할 수 있습니다.

***

## 광고 연동하기

<Steps>
  <Step title="Native Ad View 준비">
    Unity UI 프리팹 루트에 `DaroNativeAdView`를 추가하고 `TitleText`, `BodyText`, `IconImage`, `CtaButton`, `MediaContainer` 슬롯을 연결합니다.

    `MediaContainer`는 선택 항목입니다. media asset이 없는 광고가 바인딩되면 `DaroNativeAdView`가 `MediaContainer`를 자동으로 숨깁니다.

    `Bind(ad)`는 Android와 iOS에서 `CtaButton` 탭을 네이티브 클릭 흐름에 자동으로 연결합니다.
  </Step>

  <Step title="광고 인스턴스 생성">
    ```csharp theme={null}
    private DaroNativeAd ad;
    [SerializeField] private DaroNativeAdView adView;

    ad = new DaroNativeAd("your-native-ad-unit-id");
    ```
  </Step>

  <Step title="이벤트 핸들러 등록">
    ```csharp theme={null}
    ad.OnAdLoaded += info => adView.Bind(ad);
    ad.OnAdFailedToLoad += error => Debug.LogWarning(error.Message);
    ad.OnAdImpression += info => Debug.Log("impression");
    ad.OnAdClicked += info => Debug.Log("clicked");
    ```
  </Step>

  <Step title="광고 로드">
    ```csharp theme={null}
    adView.LoadFor(ad);
    ```
  </Step>

  <Step title="광고 해제">
    ```csharp theme={null}
    adView.Unbind();
    ad?.Dispose();
    ad = null;
    ```
  </Step>
</Steps>

<Tip>
  `DaroNativeAdView` 대신 `DaroNativeAd.Info`를 사용해 커스텀 UI를 구성하는 경우, CTA 버튼 핸들러에서 `ad.NotifyClicked()`를 호출하세요.
</Tip>

<Warning>
  `Info.Icon`과 `Info.MediaImage` 텍스처는 `DaroNativeAd`가 소유하며, 광고를 다시 로드하거나 해제할 때 정리됩니다. `Unbind()`와 `Dispose()` 후에 해당 텍스처를 보관하거나 다시 사용하지 마세요.
</Warning>

***

## Example

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

public sealed class NativeAdHost : MonoBehaviour
{
    [SerializeField] private string adUnitId = "your-native-ad-unit-id";
    [SerializeField] private DaroNativeAdView adView;
    private DaroNativeAd ad;

    private void OnEnable()
    {
        ad = new DaroNativeAd(adUnitId);
        ad.OnAdLoaded += info => adView.Bind(ad);
        ad.OnAdFailedToLoad += error => Debug.LogWarning(error.Message);
        adView.LoadFor(ad);
    }

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