Пример #1
0
 public void Init()
 {
     // MobileAds.Initialize("ca-app-pub-7178055090700599~1990908832");
     MobileAds.Initialize(status => { Debug.Log($"Status Of Ads {status}"); });
     m_rewardBasedVideo = MobileAds.GetClientFactory().BuildRewardBasedVideoAdClient();
     m_rewardBasedVideo.CreateRewardBasedVideoAd();
     m_adLoaded.ObserveOnMainThread().Subscribe(delegate(bool l)
     {
         adReady.Value = l;
         Loading.Value = false;
     });
     m_adFinished.ObserveOnMainThread().Subscribe(delegate(bool finished) { m_adFinishedMain.OnNext(finished); });
     m_adOpened.ObserveOnMainThread().Subscribe(delegate { AudioListener.pause = true; });
     (from fin in m_adFinishedMain
      where !fin
      select fin).Subscribe(delegate
     {
         adReady.Value       = false;
         AudioListener.pause = false;
     });
     m_rewardBasedVideo.OnAdLoaded       += delegate { m_adLoaded.OnNext(value: true); };
     m_rewardBasedVideo.OnAdClosed       += delegate { m_adFinished.OnNext(value: false); };
     m_rewardBasedVideo.OnAdFailedToLoad += delegate { m_adLoaded.OnNext(value: false); };
     m_rewardBasedVideo.OnAdRewarded     += delegate { m_adFinished.OnNext(value: true); };
     m_rewardBasedVideo.OnAdOpening      += delegate { m_adOpened.OnNext(value: true); };
 }