Created
March 6, 2018 08:52
-
-
Save yasuyuki-kamata/814af6a967d7df797ad1764805df6559 to your computer and use it in GitHub Desktop.
Unity Adsのアセットストアパッケージを使っている際のコード(Start時にGame IDを使った初期化がはいる)
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 ShowUnityAdsWithAssetstorePackage : MonoBehaviour | |
{ | |
public string GameId_iOS = "INPUT YOUR GAMEID FOR IOS"; | |
public string GameId_Android = "INPUT YOUR GAMEID FOR ANDROID"; | |
public bool TestMode = false; | |
private string _gameId; | |
void Start () | |
{ | |
if (!Advertisement.isInitialized) | |
{ | |
#if UNITY_IOS | |
_gameId = GameId_iOS; | |
#elif UNITY_ANDROID | |
_gameId = GameId_Android; | |
#endif | |
Advertisement.Initialize(_gameId, TestMode); | |
} | |
} | |
public void ShowAd() | |
{ | |
if (Advertisement.IsReady()) | |
{ | |
Advertisement.Show(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment