- Home /
[Solved] Chartboost ad is not working when reloading scene
Hi. I am trying to integrate Chartboost Ad into my game.
I have added interstitial Ad & rewarded video code. Both Ad work fine when i first start up the game. However, both Ad do not work after i called Restart ().
I am using Unity version 5.1.1 and the newest Chartboost SDK version 5.5.3
My workflow:
Interstitial Ad is shown when player lose the game. Lose () is called in this situation. Rewarded video is shown when player press EarnCoin button. EarnCoins() is called when the button is pressed. Restart() is called when restart button is pressed.
My code:
private int frameCount = 0;
void Start () {
Chartboost.cacheInterstitial(CBLocation.Default);
Chartboost.cacheRewardedVideo(CBLocation.Default) ;
Chartboost.setAutoCacheAds(true);
}
void Lose () {
if (Chartboost.hasInterstitial(CBLocation.Default)) {
Chartboost.showInterstitial (CBLocation.Default);
}
}
void EarnCoins () {
if (Chartboost.hasRewardedVideo (CBLocation.Default)) {
Chartboost.showRewardedVideo (CBLocation.Default);
}
}
void Restart () {
Application.LoadLevel (Application.loadedLevel);
}
void Update () {
frameCount++;
if( frameCount > 30 && Chartboost.hasInterstitial(CBLocation.Default) == false){
Chartboost.cacheInterstitial(CBLocation.Default);
frameCount = 0;
}
if( frameCount > 30 && Chartboost.hasRewardedVideo(CBLocation.Default) == false){
Chartboost.cacheRewardedVideo(CBLocation.Default);
frameCount = 0;
}
I have used ChartboostExampleScript to check. Everytime i play the game as the 1st time, both Ad can cache automatically. However, after i pressed restart button, both Ad can't cache automatically. Chartboost.hasInterstitial and Chartboost.hasRewardedVideo keep showing "false" in the log.
Do you guys have any ideas? Any suggestion would be appreciated :]
@huloo Did you find any solution to your problem? I am in similar situation and have tried many things. No luck yet.
Answer by huloo · Nov 23, 2015 at 02:22 PM
@IES
I solved the problem by putting the Chartboost prefab in a scene which only load once.
Hope this help :]
Please remove the "Solved" from your question That's not how to mark questions as solved on this forum. That's what the "Accept answer" function is for ;)
You can click accept on your answer and after that you can close it. That's fine. ;)
Here a quick re$$anonymous$$der:
The Frequently Asked Questions and the User Guide.
Your answer
![](https://koobas.hobune.stream/wayback/20220612001011im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
LeadBolt Ads For Android 1 Answer
Admob Plugin - Android License 0 Answers
Is there any multi-platform Ads solution or plugin? 1 Answer
Homebase SDK android Plugin Help 0 Answers