Notice
Recent Posts
Recent Comments
Link
«   2024/05   »
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
Archives
Today
Total
관리 메뉴

게임 프로그래밍

[unity] Unity Ads 넣는 방법 본문

프로그래밍/유니티

[unity] Unity Ads 넣는 방법

Junwe 2020. 4. 2. 00:18

(2019.3.7f1 버전으로 하였습니다.)

unity ads는 유니티에서 지원하는 보상형 광고 시스템 입니다. 아마 2018버전부터 별다른 작업없이 쉽게 넣을 수 있도록 된걸로 알고 있습니다.

 

우선 SERVICES에 Ads를 활성화 시켜줍니다.
테스트를 위해 test mode를 활성화시켜줍니다.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Advertisements;
public class UnityAds : MonoBehaviour
{
    void Awake()
    {
        Advertisement.Initialize("your Id"false);
    }
    public void ShowRewardedAD()
    {
        if (Advertisement.IsReady("rewardedVideo"))
        {
            var options = new ShowOptions { resultCallback = HandleShowResult };
            Advertisement.Show("rewardedVideo", options);
        }
    }
 
    private void HandleShowResult(ShowResult result)
    {
        switch (result)
        {
            case ShowResult.Finished:
                Debug.Log("Finished");
                break;
            case ShowResult.Skipped:
                Debug.Log("Skipped");
                break;
            case ShowResult.Failed:
                Debug.Log("Failed");
                break;
        }
    }
}
 
cs

이렇게 스크립트를 만들어 주신후 ShowRewardedAD를 실행시켜주시면 됩니다.

 

여기서 Advertisement가 빨간줄로 안되는 경우나 Advertisement.IsReady가 false로 뜰 경우에는 패키지 매니저에서 ads업데이트 시켜주시면 될것같습니다.

혹시나 isReay가 계속 false가 뜰 경우에는 Advertisement.Initialize를 사용해주시면 해결 될 것입니다.

Services에서 DashBorad를 누룬 후

 

operate -> projects -> 프로젝트 선택

저기있는 Game IDs 를 넣어주시면 됩니다.

에디터에서 이런 화면이 나오면 성공입니다!

Comments