Last active
April 15, 2018 15:49
-
-
Save yasuyuki-kamata/effee0e451fdd37e14970126c1f1e35b to your computer and use it in GitHub Desktop.
UNIBOOK9 ゲーム内で課金アイテムのサジェストをしてみる Ads側
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using UnityEngine.Advertisements; | |
public class AdsManager : MonoBehaviour | |
{ | |
#if UNITY_IOS | |
// ここにiOSのAdsのGame ID | |
private readonly string _gameId = "1769120"; | |
#elif UNITY_ANDROID | |
// ここにAndroidのAdsのGame ID | |
private readonly string _gameId = "1769119"; | |
#else | |
private readonly string _gameId = "none"; | |
#endif | |
[SerializeField, Header("動画広告用のPlacement ID")] | |
private string _rewardedVideoPlacementId = "rewardedVideo"; | |
[SerializeField, Header("IAP Promo用のPlacement ID")] | |
private string _iapPromoPlacementId = "promo"; | |
public void Init() | |
{ | |
Debug.Log("UnityAds.Init()"); | |
if (!Advertisement.isSupported || Advertisement.isInitialized) | |
{ | |
Debug.Log("Could not initialize ads"); | |
return; | |
} | |
Debug.Log("Initializing Unity Ads with game ID: " + _gameId); | |
Advertisement.Initialize(_gameId, false); | |
} | |
public void ShowAdUnit () | |
{ | |
Debug.Log ("Unity Ads Log: Ad shown"); | |
Advertisement.Show (_rewardedVideoPlacementId); | |
} | |
public void ShowPromo() | |
{ | |
Debug.Log ("Unity Ads Log: Promo Shown"); | |
Advertisement.Show (_iapPromoPlacementId); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment