[Unity] Unity ads 붙히기
유니티 5.0 이상에게 해당!!!!
1. 유니티에서 ctrl+0을 누르면 Services가 나옴
1-1. Ads를 ON을 함
1-2. 우측상단에 있는 Go to Dashborad를 누름.
https://dashboard.unityads.unity3d.com/
1-3. Add new project를 누르고 프로젝트를 만든다.
2. 유니티 services에서 Advanced를 클릭
2-1. Android GameID를 복사
3. 유니티에서 C# 스크립트를 생성하고 소스를 입력
3-1. Hierarchy에서 create empty를 생성하고 c#을 추가시킨다.
// 일반 광고
using UnityEngine;
using System.Collections;
using UnityEngine.Advertisements;
public class UnityAds : MonoBehaviour {
// Use this for initialization
void Start () {
Advertisement.Initialize ("game id", true);
}
// Update is called once per frame
void Update () {
}
public void ShowAd(){
if (Advertisement.IsReady ()) {
Advertisement.Show ();
}
}
}
// 보상형 광고
using System.Collections;
using UnityEngine.Advertisements;
public class UnityRewardAds : MonoBehaviour {
// Use this for initialization
void Start () {
Advertisement.Initialize ("game id", true);
}
// Update is called once per frame
void Update () {
}
public void ShowRewardedAd(){
if (Advertisement.IsReady ("rewardedVideo")) {
ShowOptions opt = new ShowOptions ();
opt.resultCallback = adCallBack;
Advertisement.Show ("rewardedVideo");
}
}
void adCallBack(ShowResult result) {
Debug.Log ("result :" + result);
}
}
':::::: STUDY :::::: > Unity' 카테고리의 다른 글
GPGS data storage limit (0) | 2017.02.01 |
---|---|
Unity에서 Android Log 찍는법 (0) | 2017.01.11 |
Preventing uGUI mouse click from passing through GUI controls (0) | 2016.06.23 |
[Unity] there are 2 audio listeners in the scene (0) | 2016.04.28 |
[Unity] Admob 광고 붙히기 (0) | 2016.03.03 |