c# - Unity 3D 可以使用关卡号解锁成就吗?
问题描述
我需要有关我正在尝试实现 google play 成就的脚本的帮助,因为我使用的是 easy mobile pro。
我希望他们在达到关卡后解锁。
问题是游戏具有随机生成的关卡并进入无穷大。
但是当关卡完成到文本字段时,将添加一个新数字
这可以保护这个脚本:
成就解锁脚本:
// Unlock an achievement
// EM_GameServicesConstants.Sample_Achievement is the generated name constant
// of an achievement named "Sample Achievement"
GameServices.UnlockAchievement(EM_GameServicesConstants.Achievement_Level 5);
成就可以用等级号解锁吗?
例如,在第 5 级时会解锁成就吗?
解决方案
似乎在您使用的 API 中,它需要从 google play 数据生成这些常量,因此它们都需要提前知道和生成,并且您不能拥有无限数量的它们。请参阅此处的文档:https ://www.easymobile.sglibgames.com/docs/pro/chapters/game-services/module-configuration.html#constants-generation
似乎您需要一些代码,就像:
if(GameManager.Instance.level == 5)
{
GameServices.UnlockAchievement(EM_GameServicesConstants.Achievement_Level_5)
}
else
{
// deal with other levels
}
或者作为另一种解决方法,您似乎可以通过名称获得每项成就https://www.easymobile.sglibgames.com/docs/pro/chapters/game-services/scripting.html#achievements
按名称遍历所有成就,查看是否与关卡名称匹配并以这种方式命名。
推荐阅读
- javascript - 从对象中过滤属性的更简洁方法
- python-3.x - 打开之前在 Tkinker 中被破坏的窗口
- c# - 将powershell脚本的输出绑定到asp.net c#中的gridview
- java - GCP:无法从 Java 尝试 Cloud Billing Account API
- javascript - 我想在javascript NODE.js中以同步方式检查URL是否存在
- javascript - 如何摆脱 JSON 中的 '[' 和 ']',如下所示在 NodeJS 中
- php - Wordpress:如何使用 ACF 和自定义帖子类型制作唯一字段
- ruby - nginx 重写路由以将所有 .com/en 页面重定向到 .com 版本
- c - 如何在 Microchip PIC24 中使用 Modbus
- android - 适配器没有解析我发送给它的数组列表