Quantcast
Viewing all articles
Browse latest Browse all 1416

AdColony-- works on testing but not on published

I created my first game using AdColony recently. The ads showed up during test mode (as a placeholder) but when I published the game-- and set it to real ads-- they didn't show up at all. My code: private const string ANDROID_VERSION = "version:1.2,store:google"; private const string ZONE_ID = ""; private const string ANDROID_APP_ID = ""; public void Initialize() { AdColony.OnVideoFinished = AdHandler; if (Application.platform == RuntimePlatform.Android) AdColony.Configure(ANDROID_VERSION, ANDROID_APP_ID, ZONE_ID); //if(Application.platform == RuntimePlatform.IPhonePlayer) // AdColony.Configure(ANDROID_VERSION, ANDROID_APP_ID, ZONE_ID); Debug.Log("Todo: iOS implementation"); } // Use this for initialization void Start () { if (instance != null) { //Don't make two of em! Destroy(this.gameObject); return; } else { instance = this; Object.DontDestroyOnLoad(this.gameObject); //StartCoroutine(StartAdSystem()); } } /* IEnumerator StartAdSystem() { if (Advertisement.isSupported) { // If runtime platform is supported... Advertisement.Initialize(); // ...initialize. } while (!Advertisement.isInitialized || !Advertisement.IsReady()) { yield return new WaitForSeconds(0.5f); } yield return null; } */ /// /// Reset the ad prompts (should only be called by panels that show a prompt) /// public void DisableAllPrompts() { promptChargeGun.SetActive(false); promptKeepPlaying.SetActive(false); adFailedPanel.SetActive(false); } IEnumerator AdFailurePanel() { adFailedPanel.SetActive(true); yield return new WaitForSeconds(2f); adFailedPanel.SetActive(false); failureCallbackFunction(); } /// /// Show the prompt to charge the gun (returns false if it can't play) /// public bool ShowPromptGun() { if (!Application.isMobilePlatform) return false; //if (!Advertisement.IsReady(RewardedZoneId)) // return false; if (!AdColony.IsVideoAvailable(ZONE_ID)) return false; DisableAllPrompts(); promptChargeGun.SetActive(true); return true; } /// /// Show the prompt to watch an ad and continue playing (returns false if it can't play the ad) /// public bool ShowKeepPlaying() { if (!Application.isMobilePlatform) return false; //if (!Advertisement.IsReady(RewardedZoneId)) // return false; if (!AdColony.IsVideoAvailable(ZONE_ID)) return false; DisableAllPrompts(); successCallbackFunction = SparePlayer; failureCallbackFunction = ReturnToTitle; promptKeepPlaying.SetActive(true); adProcess = DEATH_PROCESS.WAITING_FOR_AD; return true; } /// /// Show the prompt to watch an ad to make the gun charge faster (returns false if you can't play the ad) /// /// public bool ShowChargeGun() { if (!Application.isMobilePlatform) return false; //if (!Advertisement.IsReady(RewardedZoneId)) // return false; if (!AdColony.IsVideoAvailable(ZONE_ID)) return false; DisableAllPrompts(); successCallbackFunction = SparePlayer; failureCallbackFunction = ReturnToTitle; promptChargeGun.SetActive(true); adProcess = DEATH_PROCESS.WAITING_FOR_AD; return true; } /// /// The player chose to watch an ad to keep going /// public void RunSparePlayerAd() { PlayAd(SparePlayer, ReturnToTitle); } public void ReturnToTitle() { SceneManager.LoadScene("Title"); } void SparePlayer() { PlayerController.instance.RevivePlayer(); DisableAllPrompts(); } public void RunChargeGunAd() { PlayAd(ChargeGun, DoNothing); } void ChargeGun() { GlobalVars.instance.chargeUpgrades++; DisableAllPrompts(); } void DoNothing() { } private void ShowAdFailed() { DisableAllPrompts(); adFailedPanel.SetActive(true); StartCoroutine(AdFailurePanel()); } public delegate void ON_AD_OVER(); public ON_AD_OVER successCallbackFunction; public ON_AD_OVER failureCallbackFunction; /// /// Play an ad and run a function if it works /// /// void to call if successful /// void to call if failure private void PlayAd(ON_AD_OVER s, ON_AD_OVER f) { successCallbackFunction = s; failureCallbackFunction = f; /* UnityEngine.Advertisements.ShowOptions options = new ShowOptions(); options.resultCallback = AdHandler; Advertisement.Show(RewardedZoneId, options); */ AdColony.ShowVideoAd(ZONE_ID); //StartCoroutine(WaitForAd()); } void AdHandler(bool adWasShown) { switch (adWasShown) { case false: ShowAdFailed(); break; case true: successCallbackFunction(); break; } }

Viewing all articles
Browse latest Browse all 1416

Trending Articles