# Unity에서 인터스티셜 광고 구현

> Unity 프로젝트에 인터스티셜 광고를 구현합니다. 게임플레이 순간이나 앱 전환 시점에 광고 콘텐츠를 로드하고 C# 스크립트를 통해 표시합니다.

[`Advertisements API`](/grow/ads/unity-sdk/unity-api.md)를 사용하여 전체 화면 인터스티셜 광고를 표시하려면 SDK를 초기화한 다음 [`Load`](/grow/ads/unity-sdk/unity-api.md#load) 함수를 사용하여 광고 콘텐츠를 [광고 단위](/grow/dashboard/ad-units.md)로 로드하고 [`Show`](/grow/ads/unity-sdk/unity-api.md#show) 함수를 사용하여 광고를 표시합니다.

> **Note:**
>
> SDK 버전 4.4.1부터 Unity 에디터에서는 Unity Ads 패키지를 Advertisement Legacy 패키지라고 부릅니다.
> Advertisement Legacy 패키지 버전 4.12는 계속 작동하지만 새로운 기능이나 향상된 기능에 대한 추가 업데이트는 수신하지 않습니다.
> SDK 버전 4.12는 Apple 개인정보 보호 매니페스트 업데이트를 지원하며, 패키지에 대한 추가 업데이트는 계획되어 있지 않습니다.

SDK 3.7.0 이상에서는 [`IUnityAdsLoadListener`](/grow/ads/unity-sdk/unity-api.md) 및 [`IUnityAdsShowListener`](/grow/ads/unity-sdk/unity-api.md) 콜백을 사용하여 광고 콘텐츠를 Load 또는 Show에 성공하거나 실패하는 경우에 대한 로직을 각각 구현할 수 있습니다.

> **Note:**
>
> `Show` 메서드를 호출할 때 플레이스먼트 ID를 지정해야 합니다. 그렇지 않으면 오류가 발생합니다.

## 인터스티셜 광고 예시##interstitial-ad-example

1. **C#**

   ```cs
   using UnityEngine;
   using UnityEngine.Advertisements;

   public class InterstitialAdExample : MonoBehaviour, IUnityAdsLoadListener, IUnityAdsShowListener
   {
     [SerializeField] string _androidAdUnitId = "Interstitial_Android";
     [SerializeField] string _iOSAdUnitId = "Interstitial_iOS";
     string _adUnitId;

     void Awake()
     {
       // Get the Ad Unit ID for the current platform:
       _adUnitId = (Application.platform == RuntimePlatform.IPhonePlayer)
       ? _iOSAdUnitId
       : _androidAdUnitId;
     }

     // Load content to the Ad Unit:
     public void LoadAd()
     {
       // IMPORTANT! Only load content AFTER initialization (in this example, initialization is handled in a different script).
       Debug.Log("Loading Ad: " + _adUnitId);
       Advertisement.Load(_adUnitId, this);
     }

     // Show the loaded content in the Ad Unit:
     public void ShowAd()
     {
       // Note that if the ad content wasn't previously loaded, this method will fail
       Debug.Log("Showing Ad: " + _adUnitId);
       Advertisement.Show(_adUnitId, this);
     }

     // Implement Load Listener and Show Listener interface methods: 
     public void OnUnityAdsAdLoaded(string adUnitId)
     {
       // Optionally execute code if the Ad Unit successfully loads content.
     }

     public void OnUnityAdsFailedToLoad(string _adUnitId, UnityAdsLoadError error, string message)
     {
       Debug.Log($"Error loading Ad Unit: {_adUnitId} - {error.ToString()} - {message}");
       // Optionally execute code if the Ad Unit fails to load, such as attempting to try again.
     }

     public void OnUnityAdsShowFailure(string _adUnitId, UnityAdsShowError error, string message)
     {
       Debug.Log($"Error showing Ad Unit {_adUnitId}: {error.ToString()} - {message}");
       // Optionally execute code if the Ad Unit fails to show, such as loading another ad.
     }

     public void OnUnityAdsShowStart(string _adUnitId) { }
     public void OnUnityAdsShowClick(string _adUnitId) { }
     public void OnUnityAdsShowComplete(string _adUnitId, UnityAdsShowCompletionState showCompletionState) { }
   }
   ```

**다음 단계**: 구현 내용을 한 단계 더 발전시키려면 [Unity에서 보상형 광고 구현](/grow/ads/unity-sdk/rewarded-ads.md) 기술 자료를 참조하십시오.
