-
-
Save yasuyuki-kamata/fd58f227b41beee98af9 to your computer and use it in GitHub Desktop.
UnityAds の呼び出しサンプルコード
This file contains 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 System.Collections; | |
using UnityEngine.Advertisements; | |
public class UnityAdsManager : MonoBehaviour | |
{ | |
static UnityAdsManager _instance; | |
/// <summary> | |
/// Get instance. | |
/// </summary> | |
/// <returns>The instance.</returns> | |
public static UnityAdsManager GetInstance () { | |
if (null == _instance) { | |
GameObject go = new GameObject ("UnityAdsManager"); | |
_instance = go.AddComponent<UnityAdsManager>(); | |
} | |
return _instance; | |
} | |
[SerializeField] | |
string appId = "14775"; | |
public void Init () { | |
if (Advertisement.isSupported) { | |
Advertisement.Initialize(appId); | |
} | |
} | |
public void ShowAds () { | |
if (Advertisement.isReady()) { | |
Advertisement.Show(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment