# 배너 광고

### 1 : 준비

* [프로젝트 설정](/adpie/unity/project-settings.md)을 통해 광고 연동을 위한 준비를 합니다.

### 2 : SDK 초기화

* SDK 초기화를 하지 않았다면, [사이트](http://my.adpies.com)에서 발급받은 Media ID를 입력하여 초기화를 합니다.

```csharp
AdPieSDK.Instance.Initialize("AdPie-Media-ID");
```

### 3 : 광고 요청과 표출

* [사이트](http://my.adpies.com)에서 발급받은 Slot ID를 입력하여 AdView 객체를 생성합니다.

```csharp
AdView adView = new AdView("AdPie-Slot-ID", AdView.POSITION_TOP, 320, 50);
adView.Load();
```

### 4 : 광고 리스너 사용

* 광고 요청에 대한 이벤트를 수신할 수 있습니다.
* [에러코드](/adpie/unity/common/errorcode.md)를 통해 광고 실패에 대한 이유를 알 수 있습니다.

```csharp
{
    // 광고 연동을 위한 슬롯 ID를 필수로 입력한다.
    AdView adView = new AdView("AdPie-Slot-ID", AdView.POSITION_TOP, 320, 50);
    adView.OnAdLoaded += AdView_OnAdLoaded;
    adView.OnAdFailedToLoad += AdView_OnAdFailedToLoad;
    adView.OnAdClicked += AdView_OnAdClicked;
    adView.Load();
}

void AdView_OnAdLoaded()
{
    // 광고 표출 성공 후 이벤트 발생
}

void AdView_OnAdFailedToLoad(int errorCode)
{
    // 광고 요청 또는 표출 실패 후 이벤트 발생
}

void AdView_OnAdClicked()
{
    // 광고 클릭 후 이벤트 발생
}

```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://platform-business.gitbook.io/adpie/unity/integration/banner.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
