简体   繁体   中英

Unity 3D Can the achievement be unlocked using the level number?

I would need help with the script I'm trying to implement google play achievements for that I use easy mobile pro.
I would like them to unlock after reaching the level.

The problem is that the game has random generated levels and goes to infinity.

统一形象

but a new number will be added to when the level is completed to text field

this secures this script:

脚本图像

achievement unlock script:

// 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);

Can the achievement be unlocked using the level number?

For example at level 5 would the achievement be unlocked?

It seems like in the API you're using it needs those constants to be generated from google play data so they will all need to be known and generated in advance and you can't have an infinite amount of them. See documentation here: https://www.easymobile.sglibgames.com/docs/pro/chapters/game-services/module-configuration.html#constants-generation

It seems like you need a bit of code that is just like:

if(GameManager.Instance.level == 5)
{
  GameServices.UnlockAchievement(EM_GameServicesConstants.Achievement_Level_5)
}
else
{
  // deal with other levels
}

or as another kind of workaround it looks like you could get every achievement by name https://www.easymobile.sglibgames.com/docs/pro/chapters/game-services/scripting.html#achievements

Loop through all achievements by name, see if that matches a level name and give it that way.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM