示例#1
0
 /// <summary>
 /// Displays a banner ad.
 ///
 /// If the display was successful, the event `BannerCompletedDisplayedEvent` will be called.
 /// Otherwise, the event `BannerFailedDisplayedEvent` will be called.
 /// </summary>
 /// <param name="tag">The game tag from where the ad will be displayed (like menu or store).</param>
 /// <param name="bannerSize">The bannerSize of the Ad.</param>
 /// <param name="bannerPosition">The bannerPosition where the ad will be displayed.</param>
 public void ShowBanner(string tag, BannerSize bannerSize, BannerPosition bannerPosition)
 {
     RunIfInitialized(() =>
     {
         AdsLogger.LogWithFormat("{0} | Show banner at tag {1}", _label, tag);
         _adsBinding.ShowBanner(tag, bannerSize, bannerPosition);
     });
 }
        private static void ResizeAndPositionBannerCanvas(BannerSize bannerSize, BannerPosition bannerPosition,
                                                          RectTransform bannerCanvas)
        {
            var editorPosition = bannerPosition.toEditorPosition();

            bannerCanvas.sizeDelta = new Vector2(bannerSize.Width, bannerSize.Height);
            bannerCanvas.anchorMin = editorPosition.AnchorMin;
            bannerCanvas.anchorMax = editorPosition.AnchorMax;
            bannerCanvas.pivot     = editorPosition.Pivot;
        }
        public void ShowBanner(string tag, BannerSize bannerSize, BannerPosition bannerPosition)
        {
            Debug.Log("Banner shown at " + tag);
#if UNITY_2018_4_OR_NEWER
            if (_banner == null)
            {
                _scaleMonkAds.CompletedBannerDisplay(tag);
                _banner = CreateBannerMockAdInstance(bannerSize, bannerPosition);
            }
#endif
        }
        public MockBannerAd CreateBannerMockAdInstance(BannerSize bannerSize, BannerPosition bannerPosition)
        {
            MockBannerAd mockAdInstance;
            MockBannerAd mockAdPrefab;

            var mockAdPrefabName = isPortrait() ? "Prefabs/MockAd_banner_portrait" : "Prefabs/MockAd_banner_landscape";

            mockAdPrefab = Resources.Load <MockBannerAd>(mockAdPrefabName);

            mockAdInstance = GameObject.Instantiate(mockAdPrefab);

            var bannerCanvas = (RectTransform)mockAdInstance.transform.Find("Canvas/BgColor");

            // Remove title from Rectangle banners because it's too small to show it.
            if (bannerSize == BannerSize.Rectangle)
            {
                var textChild = bannerCanvas.transform.Find("Title");
                textChild.parent = null;
            }

            ResizeAndPositionBannerCanvas(bannerSize, bannerPosition, bannerCanvas);

            return(mockAdInstance);
        }
示例#5
0
 /// <summary>
 /// Displays a banner ad.
 ///
 /// If the display was successful, the event `BannerCompletedDisplayedEvent` will be called.
 /// Otherwise, the event `BannerFailedDisplayedEvent` will be called.
 /// </summary>
 /// <param name="bannerSize">The bannerSize of the Ad.</param>
 /// <param name="bannerPosition">The bannerPosition where the ad will be displayed.</param>
 public void ShowBanner(BannerSize bannerSize, BannerPosition bannerPosition)
 {
     ShowBanner(DEFAULT_TAG, bannerSize, bannerPosition);
 }