Пример #1
0
 public void Show(string placementId, BannerOptions showOptions)
 {
     m_BannerShowOptions = showOptions;
     if (m_BannerBundle != null && (string.IsNullOrEmpty(placementId) || m_BannerBundle.bannerPlacementId.Equals(placementId)))
     {
         m_CurrentActivity.Call("runOnUiThread", new AndroidJavaRunnable(() =>
         {
             var parent = m_BannerBundle.bannerView.Call <AndroidJavaObject>("getParent");
             if (parent == null)
             {
                 var layoutParams = m_BannerBundle.bannerView.Call <AndroidJavaObject>("getLayoutParams");
                 m_CurrentActivity.Call("addContentView", m_BannerBundle.bannerView, layoutParams);
             }
         }));
         m_Banner.UnityLifecycleManager.Post(() =>
         {
             showOptions?.showCallback();
         });
     }
     else
     {
         if (m_BannerBundle != null)
         {
             Hide(true);
             m_BannerBundle = null;
         }
         m_Banner.ShowAfterLoad = true;
         Load(placementId, null);
     }
 }
Пример #2
0
        public void Show(string placementId, BannerOptions showOptions)
        {
            m_BannerShowOptions = showOptions;
            if (!m_Banner.IsLoaded)
            {
                Load(placementId, null);
            }

            m_BannerPlaceholder.ShowBanner(m_CurrentBannerPosition, m_BannerShowOptions);
            m_Banner.UnityLifecycleManager.Post(() => {
                showOptions?.showCallback();
            });
        }
Пример #3
0
        private void onUnityBannerLoaded(String placementId, AndroidJavaObject view)
        {
            m_BannerBundle = new BannerBundle(placementId, view);
            view.Call("setBackgroundColor", UnityEngine.Advertisements.Utilities.Color.Transparent);
            if (m_Banner.ShowAfterLoad)
            {
                m_Banner.ShowAfterLoad = false;
                var layoutParams = view.Call <AndroidJavaObject>("getLayoutParams");
                m_CurrentActivity.Call("addContentView", view, layoutParams);
                m_Banner.UnityLifecycleManager.Post(() =>
                {
                    m_BannerShowOptions?.showCallback();
                });
            }

            m_Banner.UnityLifecycleManager.Post(() =>
            {
                m_BannerLoadOptions?.loadCallback();
            });
        }