Question by
Venatal · Jan 22, 2016 at 02:39 AM ·
c#not workingsdkthreads
Threading using Thread Ninja to use Adtapsy SDK
This is my Advert script:
using UnityEngine;
using System.Collections;
using CielaSpike;
public class Adverts : MonoBehaviour
{
public static Adverts manager;
void Awake()
{
manager = this;
}
void Start()
{
this.StartCoroutineAsync(LoadAds());
}
IEnumerator LoadAds()
{
AdTapsy.StartSessionAndroid("54982cf7e4b052cd2a20a7b8");
yield return Ninja.JumpToUnity;
AdTapsy.OnAdCached += delegate (int zoneId) {
if (zoneId == AdTapsy.InterstitialZone)
{
this.StopCoroutine(LoadAds());
}
else
{
this.StopCoroutine(LoadAds());
}
};
}
public void ShowInterstitial()
{
if (AdTapsy.IsInterstitialReadyToShow())
{
AdTapsy.ShowInterstitial();
}
}
}
My adverts do not seem to cache thus not loading any ads I've noticed this happens due to StartSession being called in the background thread, Does anyone know how to fix this as if I load StartSession on the main thread my game seems to freeze (lag) for a second or two as it caches the ads.
Comment