yandexmobile / yandex-ads-unity-plugin

Yandex Mobile Ads Unity Plugin
Other
52 stars 9 forks source link

Проблема с баннером #90

Closed RocksteadyDog closed 7 months ago

RocksteadyDog commented 8 months ago

Здравствуйте!

Я добавил на сцену скрипт из примеров "YandexMobileAdsBannerDemoScript.cs" для работы с баннером и я его немного изменил. Я закомментировал вызов "this.banner.Show()" в HandleAdLoaded, но, после вызова "RequestBanner" где происходит загрузка баннера "this.banner.LoadAd(this.CreateAdRequest())", баннер все равно показывается. И собственно вопрос. Метод "banner.LoadAd" вызывает показ рекламы? Так и должно быть?

Заранее спасибо!

YandexMobileAdsBannerDemoScript.cs ```c# /* * This file is a part of the Yandex Advertising Network * * Version for Android (C) 2023 YANDEX * * You may not use this file except in compliance with the License. * You may obtain a copy of the License at https://legal.yandex.com/partner_ch/ */ using System; using System.Collections; using System.Collections.Generic; using UnityEngine; using YandexMobileAds; using YandexMobileAds.Base; using UnityEngine.UI; using TMPro; public class YandexMobileAdsBannerDemoScript : MonoBehaviour { private String message = ""; private Banner banner; public void OnGUI() { var fontSize = (int)(0.05f * Math.Min(Screen.width, Screen.height)); var labelStyle = GUI.skin.GetStyle("label"); labelStyle.fontSize = fontSize; var buttonStyle = GUI.skin.GetStyle("button"); buttonStyle.fontSize = fontSize; #if UNITY_EDITOR this.message = "Mobile ads SDK is not available in editor. Only Android and iOS environments are supported"; #else if (GUILayout.Button("Request Banner", buttonStyle, GUILayout.Width(Screen.width), GUILayout.Height(Screen.height / 8))) { this.RequestBanner(); } if (GUILayout.Button("Show Banner", buttonStyle, GUILayout.Width(Screen.width), GUILayout.Height(Screen.height / 8))) { this.banner.Show(); } if (GUILayout.Button("Hide Banner", buttonStyle, GUILayout.Width(Screen.width), GUILayout.Height(Screen.height / 8))) { this.banner.Hide(); } if (GUILayout.Button("Destroy Banner", buttonStyle, GUILayout.Width(Screen.width), GUILayout.Height(Screen.height / 8))) { this.banner.Destroy(); } #endif GUILayout.Label(this.message, labelStyle); } private void RequestBanner() { //Sets COPPA restriction for user age under 13 MobileAds.SetAgeRestrictedUser(true); // Replace demo Unit ID 'demo-banner-yandex' with actual Ad Unit ID string adUnitId = "demo-banner-yandex"; if (this.banner != null) { this.banner.Destroy(); } // Set sticky banner width // BannerAdSize bannerSize = BannerAdSize.StickySize(GetScreenWidthDp()); // Or set inline banner maximum width and height BannerAdSize bannerSize = BannerAdSize.InlineSize(GetScreenWidthDp(), 50); this.banner = new Banner(adUnitId, bannerSize, AdPosition.BottomCenter); this.banner.OnAdLoaded += this.HandleAdLoaded; this.banner.OnAdFailedToLoad += this.HandleAdFailedToLoad; this.banner.OnReturnedToApplication += this.HandleReturnedToApplication; this.banner.OnLeftApplication += this.HandleLeftApplication; this.banner.OnAdClicked += this.HandleAdClicked; this.banner.OnImpression += this.HandleImpression; this.banner.LoadAd(this.CreateAdRequest()); this.DisplayMessage("Banner is requested"); } // Example how to get screen width for request private int GetScreenWidthDp() { int screenWidth = (int)Screen.safeArea.width; return ScreenUtils.ConvertPixelsToDp(screenWidth); } private AdRequest CreateAdRequest() { return new AdRequest.Builder() .Build(); } private void DisplayMessage(String message) { this.message = message + (this.message.Length == 0 ? "" : "\n--------\n" + this.message); MonoBehaviour.print(message); } #region Banner callback handlers public void HandleAdLoaded(object sender, EventArgs args) { this.DisplayMessage("HandleAdLoaded event received"); // this.banner.Show(); } public void HandleAdFailedToLoad(object sender, AdFailureEventArgs args) { this.DisplayMessage("HandleAdFailedToLoad event received with message: " + args.Message); } public void HandleLeftApplication(object sender, EventArgs args) { this.DisplayMessage("HandleLeftApplication event received"); } public void HandleReturnedToApplication(object sender, EventArgs args) { this.DisplayMessage("HandleReturnedToApplication event received"); } public void HandleAdLeftApplication(object sender, EventArgs args) { this.DisplayMessage("HandleAdLeftApplication event received"); } public void HandleAdClicked(object sender, EventArgs args) { this.DisplayMessage("HandleAdClicked event received"); } public void HandleImpression(object sender, ImpressionData impressionData) { var data = impressionData == null ? "null" : impressionData.rawData; this.DisplayMessage("HandleImpression event received with data: " + data); } #endregion } ```
mobile-ads-github commented 8 months ago

Спасибо за Ваше обращение, для разбора создана задача с номером PCODESUP-2828. Мы ознакомимся и вернемся с ответом в течение 2 дней, возможно запросим дополнительную информацию.

Thank you for your message, a task with the number PCODESUP-2828 has been created for analysis. We will get acquainted and return with the answer within 2 days, we may request additional information.

mobile-ads-github commented 7 months ago

Добрый день! Извиняемся за долгий ответ. Да, это ожидаемое поведение.

RocksteadyDog commented 7 months ago

Странное поведение