2016-03-30 20 views
0

私はチャートブーストとユニティ広告を使用しているシンプルなplatformer gameを持っています。テストモードでは正常に動作していましたが、モードの両方のチャートブースト広告とユニティ広告の両方私のインタースティシャル広告とビデオがロードされていないか、同じゲームのブルームーンに一度だけ表示されてから再び表示されないことが気づきました。Unity 3DゲームでChartboost広告が表示されない

また、私の広告の印象がチャートブーストとユニティでかなり低いことに気付きました。私はそれを正しくコード化すれば教えてもらえますか?私はchartboostの例を使用して広告コントローラを構築しました。ああ、私は広告にキャッシュを使用しています。広告がキャッシュされていない限り、表示しません。インタースティシャルを表示するたびに後

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(); 
    } 
} 

} 

答えて

0

実行キャッシュ:

は、ここでは、コードです。このような

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

あなたがキャッシュにあなたが広告を表示するたびに補充されますこの方法。

初期化するとすぐにキャッシュするようにしてください。

関連する問題