게임 프로그래밍
[unity] Unity Ads 넣는 방법 본문
(2019.3.7f1 버전으로 하였습니다.)
unity ads는 유니티에서 지원하는 보상형 광고 시스템 입니다. 아마 2018버전부터 별다른 작업없이 쉽게 넣을 수 있도록 된걸로 알고 있습니다.
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업데이트 시켜주시면 될것같습니다.
![](https://blog.kakaocdn.net/dn/bndeb9/btqC8HJBg3W/J6Mi3wLgHg0G3FuxEb8CZ0/img.png)
혹시나 isReay가 계속 false가 뜰 경우에는 Advertisement.Initialize를 사용해주시면 해결 될 것입니다.
Services에서 DashBorad를 누룬 후
operate -> projects -> 프로젝트 선택
저기있는 Game IDs 를 넣어주시면 됩니다.
에디터에서 이런 화면이 나오면 성공입니다!
'프로그래밍 > 유니티' 카테고리의 다른 글
[Unity-Shader] Rim Light (0) | 2020.04.30 |
---|---|
[Unity] hierarchy 에서 특정 Scirpt를 가지고 있는 오브젝트를 찾을때 (0) | 2020.04.04 |
[Unity3D] Script Templates (0) | 2020.03.19 |
[Unity] Custom TileMap Creator (0) | 2020.03.17 |
[Unity] Custom Editor Undo (0) | 2020.03.14 |
Comments