CanvasAddEditor.cs 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. #if UNITY_EDITOR
  2. using Eiko.YaSDK;
  3. using System.Collections;
  4. using UnityEngine;
  5. using UnityEngine.UI;
  6. namespace Eiko.YaSDK.Editor
  7. {
  8. public class CanvasAddEditor : MonoBehaviour
  9. {
  10. public GameObject baner;
  11. public GameObject fullScreen;
  12. public GameObject revarded;
  13. public GameObject Review;
  14. public Text time;
  15. private int placement;
  16. public bool keepWaiting = false;
  17. private static bool IsReviewed;
  18. public void Awake()
  19. {
  20. DontDestroyOnLoad(gameObject);
  21. }
  22. public void CloseFullScreen()
  23. {
  24. fullScreen.SetActive(false);
  25. YandexSDK.instance.OnInterstitialShown();
  26. }
  27. public void CloseReward()
  28. {
  29. revarded.SetActive(false);
  30. if (keepWaiting)
  31. YandexSDK.instance.OnRewardedClose(placement);
  32. else
  33. YandexSDK.instance.OnRewarded(placement);
  34. }
  35. public void OpenFullScreen()
  36. {
  37. fullScreen.SetActive(true);
  38. }
  39. public void OpenReward(int i)
  40. {
  41. this.placement = i;
  42. revarded.SetActive(true);
  43. StopAllCoroutines();
  44. StartCoroutine(WaitReward());
  45. }
  46. public IEnumerator WaitReward()
  47. {
  48. keepWaiting = true;
  49. for (int i = 5; i > 0; i--)
  50. {
  51. time.text = "Seconds " + i;
  52. yield return new WaitForSecondsRealtime(1);
  53. }
  54. time.text = "Award received";
  55. keepWaiting = false;
  56. }
  57. public void ShowReview()
  58. {
  59. Review.SetActive(true);
  60. }
  61. public void ReviewClosed()
  62. {
  63. Review.SetActive(false);
  64. string Json;
  65. Json = JsonUtility.ToJson(
  66. new ReviewCallback()
  67. {
  68. CanReview = !IsReviewed,
  69. FeedbackSent = !IsReviewed,
  70. Reason = IsReviewed? "GAME_RATED" : "Success"
  71. });
  72. IsReviewed = true;
  73. YandexSDK.instance.OnReview(Json);
  74. }
  75. }
  76. }
  77. #endif