Guest User

Untitled

a guest
Dec 18th, 2017
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.05 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5.  
  6. public class VungleManaher : MonoBehaviour {
  7. string appID = "";
  8.  
  9. string windowsAppID = "5a031ad33affebb9040046cf";
  10. #if UNITY_WSA_10_0 || UNITY_WINRT_8_1 || UNITY_METRO || UNITY_5_5_3
  11. string placementID = "DEFAULT39144";
  12. #endif
  13. public Text texts;
  14. private void Awake()
  15. {
  16.  
  17. #if UNITY_WSA_10_0 || UNITY_WINRT_8_1 || UNITY_METRO || UNITY_5_5_3
  18. appID = windowsAppID;
  19. Dictionary<string, bool> placements = new Dictionary<string, bool>
  20. {
  21. { placementID, false }
  22.  
  23. };
  24. #endif
  25. string[] array = new string[placements.Keys.Count];
  26. placements.Keys.CopyTo(array, 0);
  27. Vungle.init(appID, array);
  28.  
  29. TextShow ();
  30. }
  31.  
  32. void Start()
  33. {
  34. StartCoroutine (WaitLoadAd());
  35. Debug.Log ("Ads load");
  36. }
  37.  
  38. IEnumerator WaitLoadAd()
  39. {
  40. yield return new WaitForSeconds (5f);
  41. Vungle.loadAd (placementID);
  42. }
  43.  
  44. public void TextShow()
  45. {
  46. texts.text = "Button Is Work!".ToString();
  47. Vungle.playAd (placementID);
  48. initializeEventHandlers ();
  49. }
  50.  
  51. void initializeEventHandlers() {
  52.  
  53. Vungle.onAdStartedEvent += (placementID) => {
  54. texts.text =("Ad " + placementID + " is starting! Pause your game animation or sound here.");
  55. };
  56.  
  57. Vungle.onAdFinishedEvent += (placementID, args) => {
  58. texts.text= ("Ad finished - placementID " + placementID + ", was call to action clicked:" + args.WasCallToActionClicked + ", is completed view:"
  59. + args.IsCompletedView);
  60. };
  61.  
  62. Vungle.adPlayableEvent += (placementID, adPlayable) => {
  63. texts.text =("Ad's playable state has been changed! placementID " + placementID + ". Now: " + adPlayable);
  64. };
  65.  
  66. Vungle.onLogEvent += (log) => {
  67. texts.text = ("Log: " + log);
  68. };
  69.  
  70. Vungle.onInitializeEvent += () => {
  71. //adInited = true;
  72. texts.text = ("SDK initialized");
  73. };
  74. }
  75. }
Add Comment
Please, Sign In to add comment