SHARE
TWEET

AppodealManager

gOzaru Jun 25th, 2018 102 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using AppodealAds.Unity.Api;
  2. using AppodealAds.Unity.Common;
  3. using UnityEngine;
  4. using UnityEngine.SceneManagement;
  5.  
  6. public class AdsManager : MonoBehaviour, INonSkippableVideoAdListener
  7. {
  8. #if UNITY_EDITOR && !UNITY_ANDROID && !UNITY_IPHONE
  9.         string appKey = "";
  10. #elif UNITY_ANDROID
  11.     string appKey = "d0128dc4f67e393fe5ae7c5254d2d1fa80a652358dcd6be9";
  12. #elif UNITY_IPHONE
  13.         string appKey = "375f0f934d48eb08a21ee1091b7009a9e9d2b98db76353e1";
  14. #else
  15.         string appKey = "";
  16. #endif
  17.  
  18.     public static AdsManager instance;
  19.  
  20.     // Use this for initialization
  21.     void Start()
  22.     {        
  23.         Appodeal.disableNetwork("inmobi");
  24.         Appodeal.disableNetwork("mmedia");
  25.         Appodeal.disableNetwork("ogury");
  26.         Appodeal.initialize(appKey, Appodeal.NON_SKIPPABLE_VIDEO);
  27.         Appodeal.setNonSkippableVideoCallbacks(this);
  28.     }
  29.  
  30.     void Awake()
  31.     {
  32.         if (instance != null)
  33.             Destroy(gameObject);
  34.         else
  35.         {
  36.             instance = this;
  37.             //DontDestroyOnLoad(gameObject);
  38.         }
  39.     }
  40.  
  41.     public void showVideo()
  42.     {
  43.         if(Appodeal.isLoaded(Appodeal.NON_SKIPPABLE_VIDEO))
  44.         {
  45.             Appodeal.show(Appodeal.NON_SKIPPABLE_VIDEO);
  46.             onNonSkippableVideoClosed(true);
  47.         }
  48.         else
  49.         {
  50.             onNonSkippableVideoFailedToLoad();
  51.         }
  52.     }
  53.  
  54.     #region Non Skippable Video callback handlers
  55.     public void onNonSkippableVideoLoaded() { Debug.Log("NonSkippable Video loaded"); }
  56.     public void onNonSkippableVideoFailedToLoad()
  57.     {
  58.         GameControl.instance.LoadLevel();
  59.         Debug.Log("NonSkippable Video failed to load");
  60.     }
  61.     public void onNonSkippableVideoShown() { Debug.Log("NonSkippable Video opened"); }
  62.     public void onNonSkippableVideoClosed(bool isFinished)
  63.     {
  64.         Debug.Log("NonSkippable Video, finished:" + isFinished);
  65.         if (isFinished)
  66.         {
  67.             GameControl.instance.LoadLevel();
  68.         }        
  69.     }
  70.     public void onNonSkippableVideoFinished()
  71.     {
  72.         Debug.Log("NonSkippable Video finished");
  73.     }
  74.     #endregion
  75. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top