Exemplo n.º 1
0
		/// <summary>
		/// Use to dispose of an Ad.
		/// NOTE: Use "ad.Visible = true/false;" instead in most cases.
		/// </summary>
		/// <param name="ad"></param>
		public static void DisposeAd(Ad ad)
		{
			int index = getAdIndex(ad);
			if (index == -1)
			{
				Debug.LogError("DisposeAd Failed: Ad not found in AdManager.");
				return;
			}
			
			var plugin = plugins[index];
			plugin.Dispose();
			plugins.Remove(plugin);
		}
Exemplo n.º 2
0
		private static int getAdIndex(Ad ad)
		{
			for (int i = 0; i != plugins.Count; ++i)
			{
				if (ad.plugin == plugins[i]) return i;
			}
			
			return -1;
		}
Exemplo n.º 3
0
		/// <summary>
		/// Use to create multiple Ads.
		/// </summary>
		/// <param name="descs">Your AdDesc settings.</param>
		/// <param name="createdCallback">The callback that fires when done.</param>
		/// <returns>Returns array of Ad objects</returns>
		public static Ad[] CreateAd(AdDesc[] descs, AdCreatedCallbackMethod createdCallback)
		{
			if (creatingAds)
			{
				Debug.LogError("You must wait for the last ads to finish being created!");
				if (createdCallback != null) createdCallback(false);
				return null;
			}
			creatingAds = true;
			AdManager.createdCallback = createdCallback;

			int startLength = plugins.Count;
			for (int i = 0; i != descs.Length; ++i) plugins.Add(AdPluginAPI.New(descs[i], async_CreatedCallback));
			
			var ads = new Ad[descs.Length];
			for (int i = 0, i2 = startLength; i != descs.Length; ++i, ++i2) ads[i] = new Ad(plugins[i2]);
			return ads;
		}