Hello… I’m struggling with this issue for quite some time, and I have no clue what to do about it…
I have my game integrated with Unity Ads, and display a video ad every few games. Now comes the weird thing… The ads sometime work great (leaving aside the fill rate, I have a backup system for when the ad is not ready, and Admob shows up).
The issue is, that sometimes before showing the ad, or after, the whole screen remains black, and can’t do anything other than close the whole application & restarting the game.
Is there any solution or anything about this? Also happened to me with the test application provided by you guys… I have the game already released, and had to take them out because this was crashing my game… Also, Im getting a blog post here on the Unity Blog about the game, and I would like you guys to feature this, that like I mentioned, at the moment I had to take out.
Thanks, and I hope we can resolve this
Enviroment:
Unity 4.6
Have latest version of Unity Ads
Happens both on Android (s4 mini, galaxy tab 3) & iOS (ipod touch 5th gen, Ipad)
Hello GastoonC,
You should post a logcat log when this problem accured. I assure you you will get more quick answer from this forum.
Because, there is lots of things may crush your app with unity ads. It may be a network connection timeout problem or maybe something with your code. I suspicious about your code actually, because you said error generated both in android and ios.
Thanks,
Thanks! I’ll post a logcat about the issue…
I doubt its my code, because like I mentioned, I tried to use the example game that comes with unity ads, and had the same result!
This is an issue I’ve been researching. Might have a possible workaround for you.
Unity Ads essentially pauses the game by setting the timeScale and volume to 0 when an ad is shown. The resume method might not be getting called when the ad is closed.
There’s a MonoBehavior method called OnApplicationPause that takes a bool value. Use this method to set Time.timeScale and AudioListener.volume back to 1.
public bool usePauseOverride;
private static bool _isPaused;
void OnApplicationPause (bool isPaused)
{
if (!usePauseOverride || isPaused == _isPaused) return;
if (isPaused) Debug.Log ("App was paused.");
else Debug.Log("App was resumed.");
if (usePauseOverride) PauseOverride(isPaused);
}
public static void PauseOverride (bool pause)
{
if (pause) Debug.Log("Pause game while ad is shown.");
else Debug.Log("Resume game after ad is closed.");
AudioListener.volume = pause ? 0f : 1f;
Time.timeScale = pause ? 0f : 1f;
_isPaused = pause;
}
There’s a full integration example here. Let me know how that works out.
Thanks!
3 Likes
Hi I saw this workaround.
How does it work?
OnApplicationPause() is a unity callback that get called when the game has lost focus.
Is this function called once when the Unity Ads show up and go away?
So the app looses focus to the web view, which displays the ad. As a result, this method is called when an ad is shown and when it is hidden or closed. You can use it to set the volume and timeScale values manually.