why is my game lagging when using Unity Ads?

When my game starts the welcome screen has quite a few animations that play out. It was working fine until I implemented Unity Ads into my game. Now there is a noticeable lag when this bit of code executes:

Advertisement.Initialize ();.

It only lasts for a second but it is quite nasty. I tried putting the code in a co-routine and calling after the bulk of the heavy animations are completed but it still causes a considerable disruption to the remaining simple animations that are looping.

I’m thinking about putting it inside of my “Earn Button” onClick event but then the user will have to wait for the ads to load up which can take up to 5 seconds in my experience.

Is there a way I can call this code while the splash screen is loading?

I am testing on a Samsung S5 if that helps.

I use a second splash screen for my game. It simply waits to be informed that the Ads component has been initialized then loads the level/game. Only issue is that if no active internet, game will never load. But this link: How to 100% check internet availability - Unity Answers covers how to check for an internet connection. Hope it helps :slight_smile:


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

public class DestroyLogo : MonoBehaviour {

	void Start ()
		// initialize adverts
		if (Advertisement.isSupported) {
			Advertisement.allowPrecache = true;
			Advertisement.Initialize ("131625064");
		} else {
			Debug.Log("Platform not supported");
		// end initialize 
	void Update()
    // see if its done.
	if (Advertisement.isInitialized)
		Application.LoadLevel ("level");