// instance constructor public static void createInstance() { // create just one static instance for ever! if (staticInstance == null) { GameObject obj = new GameObject(); staticInstance = obj.AddComponent <SAInterstitialAd> (); staticInstance.name = "SAInterstitialAd"; DontDestroyOnLoad(staticInstance); // // set native version SAVersion.setVersionInNative(); #if (UNITY_IPHONE && !UNITY_EDITOR) SAInterstitialAd.SuperAwesomeUnitySAInterstitialAdCreate(); #elif (UNITY_ANDROID && !UNITY_EDITOR) var unityClass = new AndroidJavaClass("com.unity3d.player.UnityPlayer"); var context = unityClass.GetStatic <AndroidJavaObject> ("currentActivity"); context.Call("runOnUiThread", new AndroidJavaRunnable(() => { var saplugin = new AndroidJavaClass("tv.superawesome.plugins.publisher.unity.SAUnityInterstitialAd"); saplugin.CallStatic("SuperAwesomeUnitySAInterstitialAdCreate", context); })); #else Debug.Log("SAInterstitialAd Create"); #endif } }
public static void play(int placementId) { // create an instrance of an SAInterstitialAd (for callbacks) createInstance(); #if (UNITY_IPHONE && !UNITY_EDITOR) SAInterstitialAd.SuperAwesomeUnitySAInterstitialAdPlay(placementId, isParentalGateEnabled, isBumperPageEnabled, (int)orientation); #elif (UNITY_ANDROID && !UNITY_EDITOR) var unityClass = new AndroidJavaClass("com.unity3d.player.UnityPlayer"); var context = unityClass.GetStatic <AndroidJavaObject> ("currentActivity"); context.Call("runOnUiThread", new AndroidJavaRunnable(() => { var saplugin = new AndroidJavaClass("tv.superawesome.plugins.publisher.unity.SAUnityInterstitialAd"); saplugin.CallStatic("SuperAwesomeUnitySAInterstitialAdPlay", context, placementId, isParentalGateEnabled, isBumperPageEnabled, (int)orientation, isBackButtonEnabled); })); #else Debug.Log("SAInterstitialAd Play has not implemented"); #endif }
public static bool hasAdAvailable(int placementId) { // create an instrance of an SAInterstitialAd (for callbacks) createInstance(); #if (UNITY_IPHONE && !UNITY_EDITOR) return(SAInterstitialAd.SuperAwesomeUnitySAInterstitialAdHasAdAvailable(placementId)); #elif (UNITY_ANDROID && !UNITY_EDITOR) var unityClass = new AndroidJavaClass("com.unity3d.player.UnityPlayer"); var context = unityClass.GetStatic <AndroidJavaObject> ("currentActivity"); var saplugin = new AndroidJavaClass("tv.superawesome.plugins.publisher.unity.SAUnityInterstitialAd"); return(saplugin.CallStatic <bool>("SuperAwesomeUnitySAInterstitialAdHasAdAvailable", context, placementId)); #else Debug.Log("SAInterstitialAd HasAdAvailable has not implemented"); return(false); #endif }
void Start() { SAInterstitialAd.setCallback((placementId, evt) => { Debug.Log("Unity: SAInterstitialAd.callback " + placementId + " event: " + evt); if (evt == SAEvent.adLoaded) { SAInterstitialAd.play(placementId); } }); SAVideoAd.setCallback((placementId, evt) => { Debug.Log("Unity: SAVideoAd.callback " + placementId + " event: " + evt); if (evt == SAEvent.adLoaded) { SAVideoAd.play(placementId); } }); _bannerText.text = "Banner - " + placementIdBanner; _interstitial1Text.text = "Interstitial - " + placementIdInterstitialStandard; _interstitial2Text.text = "Interstitial - " + placementIdInterstitialKSF; _video1Text.text = "Video - " + placementIdVideoDirect; _video2Text.text = "Video - " + placementIdVPAID; }
// Interstitial via KSF public void playInterstitial2() { SAInterstitialAd.load(placementIdInterstitialKSF); }
// Standard Interstitial public void playInterstitial1() { SAInterstitialAd.load(placementIdInterstitialStandard); }