unity, google play game service, apple gamecenter, admob
* AdMob 플러그인 설치 및 설정
1. 유니티용 AdMob 플러그인을 다운받는다. ( https://github.com/googleads/googleads-mobile-plugins/releases )
2. Unity에서 AdMob플러그인을 설치한다.
3. MainScene.cs에 다음의 붉은색 부분들을 삽입한다.
using UnityEngine;
using System.Collections;
#if !UNITY_IPHONE
using GooglePlayGames;
using GooglePlayGames.BasicApi;
using GooglePlayGames.BasicApi.SavedGame;
#endif
using GoogleMobileAds.Api;
public class MainScene : MonoBehaviour {
#if UNITY_ANDROID
static PlayGamesClientConfiguration _GPGConfig;
#endif
////// AdMob defintions
//
static BannerView _BannerView;
//
//////
void Start () {
#if UNITY_ANDROID
_GPGConfig = new PlayGamesClientConfiguration.Builder()
.EnableSavedGames()
.Build();
PlayGamesPlatform.InitializeInstance(_GPGConfig);
PlayGamesPlatform.DebugLogEnabled = true;
PlayGamesPlatform.Activate();
#endif
Social.localUser.Authenticate(
(bool success) =>
{
Debug.Log(" - Social:SingIn= " + success.ToString());
}
);
////// AdMob init. & shows banner
//
string banner_id = " 애드몹 배너 아이디를 여기에서 설정한다. ";
_BannerView = new BannerView(banner_id, AdSize.Banner, AdPosition.Bottom);
_BannerView.LoadAd(new AdRequest.Builder().Build());
_BannerView.Show();
//
//////
}
public void OnButtonClick()
{
long score = 123;
#if UNITY_ANDROID
string leader_board_id = "CgkI2-i6kL8CEAIQAQ";
#elif UNITY_IPHONE
string leader_board_id = "SOCIALTEST_HIGH_SCORE";
#endif
Social.ReportScore(score, leader_board_id,
(bool success) =>
{
#if UNITY_ANDROID
PlayGamesPlatform.Instance.ShowLeaderboardUI(leader_board_id);
#elif UNITY_IPHONE
Social.ShowLeaderboardUI();
#endif
}
);
}
}
- banner_id는 애드몹 페이지에서 복사하여 붙여넣는다.
4. Android로 빌드 및 실행.