본문 바로가기

:::::: STUDY ::::::/Unity

[Unity] Unity ads 붙히기

[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);

}

}