2016-03-30 15 views
0

Basit bir platformer game var, grafiksel ve birlik reklamları reklamları gösteriyorum ve test modunda çalışırken iyi çalışıyordum, ancak üretimden ayrıldığımdan beri ve testi devre dışı bıraktım Hem grafik hem de birleşik reklamlarda, geçiş reklamlarımın ve videoların, mavi bir ay içinde aynı oyunun çok olduğu ve ardından tekrar başarısız olmaya başladığını veya göstermediğini fark ettim.Chartboost reklamları, Unity 3D Oyun'da görünmüyor

Ayrıca, reklam gösterimi grafikleri ve Birlik üzerinde oldukça az fark ettim. Bunu doğru bir şekilde kodlamamı söyler misiniz lütfen? Çizelgeli bir örnek kullanarak reklam denetleyicimi oluşturdum. Reklamlar için önbellek kullanıyorum ve reklam önbelleğe alınmadığı sürece zaten göstermeyeceğim.

using UnityEngine; 
    using System.Collections; 
    using UnityEngine.Advertisements; 
    using ChartboostSDK; 
    using System; 

    public class AdsController : MonoBehaviour 
    { 
     public static AdsController instance; 

// app id for unity apps 
private const string _appId = "someID"; 

public bool canShowChartBoostInterstitial; 
public bool canShowChartBoostVideo; 

private void Awake() 
{ 
    MakeSingleton(); 

    if (!canShowChartBoostInterstitial) 
    { 
     LoadChartBoostInterstitialAds(); 
    } 

    if (!canShowChartBoostVideo) 
    { 
     LoadChartBoostVideoAds(); 
    } 

    LoadUnityAds(); 
} 

private void MakeSingleton() 
{ 
    if (instance != null) 
    { 
     Destroy(gameObject); 
    } 
    else 
    { 
     instance = this; 
     DontDestroyOnLoad(gameObject); 
    } 
} 

private void OnLevelWasLoaded() 
{ 
    if (Application.loadedLevelName == "LevelMenu") 
    { 
     if (GameController.instance.canShowAds) 
     { 
      if (canShowChartBoostInterstitial) 
      { 
       ShowChartBoostInterstitial(); 
      } 
      else 
      { 
       LoadChartBoostInterstitialAds(); 
      } 
     } 
    } 
} 

private void OnEnable() 
{ 
    Chartboost.didCompleteRewardedVideo += VideoCompleted; 
    Chartboost.didCacheInterstitial += DidCacheInterstitial; 
    Chartboost.didDismissInterstitial += DidDismissInterstitial; 
    Chartboost.didCloseInterstitial += DidCloseInterstitial; 
    Chartboost.didCacheRewardedVideo += DidCacheVideo; 
    Chartboost.didFailToLoadInterstitial += FailedToLoadInterstitial; 
    Chartboost.didFailToLoadRewardedVideo += FailedToLoadVideo; 
} 

private void OnDisable() 
{ 
    Chartboost.didCompleteRewardedVideo -= VideoCompleted; 
    Chartboost.didCacheInterstitial -= DidCacheInterstitial; 
    Chartboost.didDismissInterstitial -= DidDismissInterstitial; 
    Chartboost.didCloseInterstitial -= DidCloseInterstitial; 
    Chartboost.didCacheRewardedVideo -= DidCacheVideo; 
    Chartboost.didFailToLoadInterstitial -= FailedToLoadInterstitial; 
    Chartboost.didFailToLoadRewardedVideo -= FailedToLoadVideo; 
} 

public void VideoCompleted(CBLocation location, int reward) 
{ 
    canShowChartBoostVideo = false; 

    if (RewardController.instance != null) 
    { 
     RewardController.instance.VideoWatchedGiveUserAReward(); 
    } 

    LoadChartBoostVideoAds(); 

} 

public void DidCacheInterstitial(CBLocation location) 
{ 
    canShowChartBoostInterstitial = true; 
} 

public void DidDismissInterstitial(CBLocation location) 
{ 
    canShowChartBoostInterstitial = false; 
    LoadChartBoostVideoAds(); 

    LoadChartBoostInterstitialAds(); 
} 

public void DidCloseInterstitial(CBLocation location) 
{ 
    canShowChartBoostInterstitial = false; 
    LoadChartBoostVideoAds(); 

    LoadChartBoostInterstitialAds(); 
} 

public void DidCacheVideo(CBLocation location) 
{ 
    canShowChartBoostVideo = true; 
} 

private void FailedToLoadInterstitial(CBLocation location, CBImpressionError error) 
{ 
    canShowChartBoostInterstitial = false; 
    LoadChartBoostInterstitialAds(); 
} 

private void FailedToLoadVideo(CBLocation location, CBImpressionError error) 
{ 
    canShowChartBoostVideo = false; 

    if (ShopMenuController.instance != null) 
    { 
     ShopMenuController.instance.FailedToLoadTheVideo(); 
    } 

    LoadChartBoostVideoAds(); 
} 

public void LoadChartBoostVideoAds() 
{ 
    Chartboost.cacheRewardedVideo(CBLocation.Default); 
} 

public void LoadChartBoostInterstitialAds() 
{ 
    Chartboost.cacheInterstitial(CBLocation.Default); 
} 

public void ShowChartBoostInterstitial() 
{ 
    if (canShowChartBoostInterstitial) 
    { 
     Chartboost.showInterstitial(CBLocation.Default);    
    } 
    else 
    { 
     LoadChartBoostInterstitialAds(); 
    } 
} 

public void ShowChartBoostVideo() 
{ 
    if (canShowChartBoostVideo) 
    { 
     Chartboost.showRewardedVideo(CBLocation.Default); 
    } 
    else 
    { 
     LoadChartBoostVideoAds(); 
    } 
} 

public void LoadUnityAds() 
{ 
    if (Advertisement.isSupported) 
    { 
     Advertisement.Initialize(_appId, false); 
    } 
} 

public void ShowUnityAds() 
{ 
    if (Advertisement.IsReady()) 
    { 
     Advertisement.Show(null, new ShowOptions() 
     { 
      resultCallback = result => 
      { 
       switch (result) 
       { 
        case ShowResult.Finished: 
         GameController.instance.RewardPlayerWithSomething(); 
         LoadUnityAds(); 
         break; 

        case ShowResult.Failed: 
         GameController.instance.VideoNotLoadedOrUserSkippedTheVideo("Failed to load the video. Please try again."); 
         LoadUnityAds(); 
         break; 

        case ShowResult.Skipped: 
         GameController.instance.VideoNotLoadedOrUserSkippedTheVideo("Video skipped."); 
         LoadUnityAds(); 
         break; 
       } 
      } 
     }); 
    } 
    else 
    { 
     GameController.instance.VideoNotLoadedOrUserSkippedTheVideo("Failed to load the video. Please try again."); 
     LoadUnityAds(); 
    } 
} 

} 

cevap

0

Çalıştır önbellek Bir geçiş göstermek her zaman sonra:

İşte kod. Böyle

:

Chartboost.showInterstitial(CBLocation.Default); 
    Chartboost.cacheInterstitial(CBLocation.Default); 

Eğer önbelleğe Eğer bir reklam göstermek her zaman doldurmak Bu şekilde.

Başlangıcı başladığı anda önbelleği almayı unutmayın.