6.x 升级指南: Unity

为使用  Chartboost Unity SDK (v6.0+),此更新向导会帮助您更新游戏。

如果您想找的是从头开始指导集成的基础向导,请见此页


要求

注: Chartboost 支持 Android 2.3+ 和 iOS 6.0+,请确保您在 Unity 项目中正确设置相应 OS 最低版本要求。


关键区别

  1. 由 SDK 处理初始化
    • 简化集成过程,减少发布后可能出现的问题
  2. Chartboost 菜单项
    • AppID/AppSignature 配对的设置和控制更简单
  3. namespace Chartboost 重命名为 namespace ChartboostSDK
    • 在 C# 中,不建议命名空间和类取名一致 (类 Chartboost 提供公开 API 函数)
  4. 不再接受 null() 作为位置 – 您可以填入 CBLocation.Default 替代
    • 尽管我们有默认位置,但是我们鼓励您通过 CBLocation 类使用更具描述性的位置名称,用以提供更富意义的数据分析
  5. 所有位置现在都通过 CBLocation 类进行传输
    • CBLocation 类有若干常见的位置预设值可供使用
    • 自定义位置字符串现可通过 CBLocation 类 locationFromName(string) 方法传输
  6. “更多应用”调用如今使用位置 public static void showMoreApps(CBLocation location)
    • 更精确地控制“更多应用” (存在于原生 SDK)
  7. Chartboost SDK 事件名称和方法签名已进行大幅更新和改善
    • 让 API 和功能与原生 SDK 更加匹配
    • 如需进一步了解可用的事件功能 (无论新旧),请参阅 README.md 文件或 Chartboost 帮助网站 (https://answers.chartboost.com/hc/zh-cn/articles/200780379)
  8. CBBinding.cs 实质上由 Chartboost.cs 替代。  如果您曾经调用 CBBinding.isImpressionVisible(),那么您现在可调用 Chartboost.isAnyViewVisible() — 查看 Chartboost.cs 了解所有可用方法。

升级至 6.x

    1. 删除旧插件文件夹:
      • PluginsAndroid //Android SDK 文件
      • PluginsiOS //iOS SDK 文件
      • PluginsChartboost //示例项目
    2. 导入新 SDK 程序包:
      • 素材 > 导入程序包 > 自定义程序包
      • 前往您从 Chartboost 下载的 .unitypackage 文件并使用
      • 选择导入以完成操作 (默认情况下,所有数据包素材都有导入标记)
    3. 将 Chartboost 预制从 /素材/Chartboost/Chartboost 拖拽至您的游戏场景
    4. 选择菜单项 Chartboost > 编辑设置:
      • 在 Inspector 窗口的 ChartboostSettings 选择设置 Android SDK 按钮
      • 使用您每个平台的当前值,编辑 AppID 和 AppSignature 设置
    5. 将全部 using Chartboost; 的行重命名为 using ChartboostSDK;
    6. CBManager.CBImpressionError 的全部引用重命名为 CBImpressionError
    7. 删除在 OnEnable() 中的下列 chartboost init 代码:
    8. void OnEnable() {
      // 初始化 Chartboost 插件
      #if UNITY_ANDROID
      // 替换这些内容为来自 Chartboost 网页门户的 Android 应用 ID 和签名
       CBBinding.init("CB_APP_ID_ANDROID", "CB_APP_SIG_ANDROID");
      #elif UNITY_IPHONE
      // 替换这些内容为来自 Chartboost 网页门户的 iOS 应用 ID 和签名
       CBBinding.init("CB_APP_ID_IOS", "CB_APP_SIG_IOS");
      #endif
      }
      
    9. 删除任何 Android 专用的 Chartboost 生命周期代码 (后退按钮处理、暂停、销毁等),可在下列 Unity 函数中找到:
    10. #if UNITY_ANDROID
      public void Update() {
       if (Input.GetKeyUp(KeyCode.Escape)) {
       if (CBBinding.onBackPressed())
       return;
       else
       Application.Quit();
       }
      }
      
      void OnApplicationPause(bool paused) {
      // 管理 Chartboost 插件生命周期
       CBBinding.pause(paused);
      }
      
      void OnDisable() {
      // 关闭 Chartboost 插件
       CBBinding.destroy();
      }
      #endif
      
    11. 将旧 Chartboost 调用从 CBBinding.showInterstitial(YOURLOCATIONHERE); 编辑成 Chartboost.showInterstitial(YOURLOCATIONHERE);
      • CBBinding 重命名为 Chartboost
      • 将所有 null() 的空位置转为使用 CBLocation.Default
      • 考虑使用 CBLocation 多个预设值的其中之一,例如 CBLocation.Startup, CBLocation.LevelCompleteCBLocation.MainMenu
      • 如果仍在使用自定义位置字符串,将它们通过 CBLocation 传输: CBBinding.showInterstitial("customLocation"); 变为 Chartboost.showInterstitial(CBLocation.locationFromName("customLocation"));
    12. 如果您正在专门检查已缓存的广告,方法名称有所更改:
      • 将您的调用从 CBBinding.hasCachedInterstitial(YOURLOCATIONHERE) 编辑成 Chartboost.hasInterstitial(YOURLOCATIONHERE)
    13. 如果您在侦听 Chartboost 事件,这些事件使用 Chartboost 而非 CBManager,并且名称最后不再有“Event”:
      • 例如,CBManager.didDismissInterstitialEvent += didDismissInterstitialEvent; 变为 Chartboost.didDismissInterstitial += didDismissInterstitial;
    14. 如果您在侦听 Chartboost 事件,有两个事件会出现重要的名称变更,需要您更新:
      • didShowInterstitialEvent 应被 didDisplayInterstitial 替换
      • didShowMoreAppsEvent 应被 didDisplayMoreApps 替换
    15. 如果您在侦听 Chartboost 事件,“更多应用”相关方法现接受附加的字符串位置参数,这会影响到:
      • didFailToLoadMoreApps
      • didDismissMoreApps
      • didCloseMoreApps
      • didClickMoreApps
      • didCacheMoreApps
      • 例如,void didFailToLoadMoreAppsEvent(CBManager.CBImpressionError error) 应被 void didFailToLoadMoreApps(string location, CBImpressionError error) 替换

安装后数据分析

如果您将在游戏中提供游戏内购买,不妨考虑集成安装后数据分析: 您可以解锁重要信息 — 收益、ARPU、保持数、等级及其他 — 以优化 UA 广告活动或生成自定义用户组群用于用户回访和分群。

Last Updated on 6月 13, 2017