首页 > 解决方案 > 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 级时会解锁成就吗?

标签: c#unity3d

解决方案


似乎在您使用的 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

按名称遍历所有成就,查看是否与关卡名称匹配并以这种方式命名。


推荐阅读