【问题标题】:unity ads, who controls how often they will be shown, me or Advertisement plugin?统一广告,谁控制它们的展示频率,我还是广告插件?
【发布时间】:2016-06-21 15:54:38
【问题描述】:

我已经实施了 Unity 广告并且拥有:

void Start()
{
    Advertisement.Show();
}

在连接到我的统一广告 GameObject 的脚本中。

当我测试我的游戏时,在场景加载时会显示一个广告(它是一个显示游戏会话结果的场景),这就是我想要的,但我认为每次都显示一个广告并不好这个场景加载,因为它会经常加载。后台是否有某种算法决定是否应该展示广告?

我认为在 x 时间内可以显示多少广告应该有某种限制,不仅仅是统一的,而是一般的广告,这就是为什么我认为它可能已经内置了。

所以,我的问题是,我应该这样保留它,让广告插件来工作,还是应该添加某种随机化器,例如:

int number = Random.Range(1, 2);
    if (number == 1) {
        Advertisement.Show();
    }

大约 50% 的时间展示广告?

完全公开,我前几天在unity论坛上也问过这个,还没有被批准(所以没有发布),可能会删除那个。

【问题讨论】:

  • 我没有回答你的问题,但有一个评论。您发布的 Random 示例 50% 的时间都不会展示广告。每次屏幕启动时它有 50% 的机会显示,但不保证它只会显示 50% 的时间:)
  • @NahuelIanni 不,我明白了,这只是一个尝试证明我的想法的例子:),问题是,我认为当这个场景加载时是广告的最佳时机,但我不希望我的用户被垃圾邮件.. 需要找到一些中间立场

标签: unity5


【解决方案1】:

免责声明:我对 Unity 广告没有任何经验 框架。

基于 Unity 团队制作的blog post,我想说一个简单的解决方案是检查场景是否在上次加载时显示广告,并根据情况显示新广告或什么都不做完全没有。

我们可以分两步做到这一点:

  1. 创建一个静态类来跟踪广告的展示时间。
  2. 根据静态类的值,在您的场景中确定是否满足显示新的条件,并更新它。

例如:

public static class AdvertisementTracker
{
    /// Create a property or method to store and retrieve whether
    /// an advertisement was shown at a given time. 
    /// You can use a bool, datetime, IList<DateTime> or whatever property that you need.

    public static bool AdShown = false;
    public static DateTime LastTimeShown;
    public static IList<DateTime> TimesShown = new List<DateTime>();

    /// You can even have a method that takes the elapsed time between calls and check
    /// if they meet the criteria you wish to show your ads.
    public static bool ElapsedTimeConditionMet(float elapsedTime)
    {
        // For example, the elapsed time exceeds 40 seconds, so a new add can be shown.
        return elapsedTime >= 40.0f;
    }
}

然后,在您的场景中,将以下脚本附加到您的广告对象:

using UnityEngine;
using UnityEngine.Advertisements;
using System.Collections; 

public class SimpleAdScript : MonoBehaviour
{
    void Start()
    {
        Advertisement.Initialize("<the ad ID>", true);     
        StartCoroutine(ShowAdWhenReady());
    }

    IEnumerator ShowAdWhenReady()
    {
        while (!Advertisement.isReady())
            yield return null;

        if(!AdvertisementTracker.AdShown)
        {
            Advertisement.Show();
        }

        AdvertisementTracker.AdShown = !AdvertisementTracker.AdShown;
    }
}

脚本的目的是检查广告是否可以从 Unity 框架中准备好。 如果是,则检查上次是否显示了广告。如果不是这种情况,则显示它,否则静态类将更新为下一次迭代做好准备。

【讨论】:

  • 非常感谢!所以,我必须自己跟踪这一切,尽管它看起来并不复杂。这将在场景加载时每隔一次显示广告,然后我可以使用 dateTime 值进行额外检查(比如场景是否在一分钟内加载两次)
  • 这正是重点。该示例非常简单,但是通过使用日期时间,您可以跟踪显示它的频率(比如每 20 分钟一次),并且布尔值允许您显示 50% 的时间。
  • 我回家后会测试这个(现在在工作,unity 是一个私人项目)我确信它可以完美运行,但我会一直保持打开状态,直到它被测试(做了那个之前的错误,标记错误:p)
  • 用静态类中的方法更新了答案,以保持逻辑更清晰。也检查一下(特别是如果您打算使用 DateTime 值来跟踪)。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-04-23
  • 1970-01-01
相关资源
最近更新 更多