gpt4 book ai didi

c# - GooglePlayGame 服务在 Unity 中无法正常工作

转载 作者:行者123 更新时间:2023-11-30 20:15:54 25 4
gpt4 key购买 nike

我导入了 Google Play 游戏服务插件

然后使用一些教程来实现它

但是

仍然无法计算成就排行榜未显示

正常登录

但我不明白为什么这些不起作用

using System.Collections;
using System.Collections.Generic;
using Google;
using GooglePlayGames;
using GooglePlayGames.BasicApi;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.SocialPlatforms;

public class LeaderBoardController : MonoBehaviour
{
public static LeaderBoardController instance;

public const string leaderBoardId = "CgkIlY-bvcoNEAIQAQ";

// Achievements ID
public const string score5 = "CgkIlY-bvcoNEAIQAg";
public const string passTheScore30 = "CgkIlY-bvcoNEAIQAw";
public const string unlockTheGreenBird = "CgkIlY-bvcoNEAIQBQ";
public const string unlockTheDawnLevel = "CgkIlY-bvcoNEAIQBg";
public const string becomeAcenturian = "CgkIlY-bvcoNEAIQBw";
public const string unlockTheRedBird = "CgkIlY-bvcoNEAIQCA";
public const string unlockTheMountainsLevel = "CgkIlY-bvcoNEAIQCQ";
public const string unlockTheLakeLevel = "CgkIlY-bvcoNEAIQCg";
public const string unlockTheSpringLevel = "CgkIlY-bvcoNEAIQCw";
public const string unlockTheFarmLevel = "CgkIlY-bvcoNEAIQDA";
public const string unlockTheWinterLevel = "CgkIlY-bvcoNEAIQDQ";
public const string unlockTheEveningLevel = "CgkIlY-bvcoNEAIQDg";
public const string unlockTheDarkLevel = "CgkIlY-bvcoNEAIQDw";
public const string unlockTheRainyLevel = "CgkIlY-bvcoNEAIQEA";
public const string becomeTheUltimateFlappy = "CgkIlY-bvcoNEAIQEQ";

void Awake ()
{
MakeSingleton ();
}

// Use this for initialization
void Start ()
{
PlayGamesPlatform.Activate ();

}

void OnEnable ()
{
SceneManager.sceneLoaded += this.OnLoadCallBack;
}

void OnLoadCallBack (Scene scene, LoadSceneMode sceneMode)
{
ReportScoreLocal (GameController.instance.GetHighScore ());
ReportProgressLocal (GameController.instance.GetHighScore ());
}

void OnDisable ()
{
SceneManager.sceneLoaded -= this.OnLoadCallBack;
}

// making C# script singleton
void MakeSingleton ()
{
if (instance != null)
{
Destroy (gameObject);
}
else
{
instance = this;
DontDestroyOnLoad (gameObject);
}
}

public void ConnectGooglePlayGames ()
{
if (Social.localUser.authenticated)
{
PlayGamesPlatform.Instance.ShowAchievementsUI ();
}
else
{
Social.localUser.Authenticate ((bool success) =>
{

});
}
}

public void OpenLeaderBoard ()
{
if (Social.localUser.authenticated)
{
PlayGamesPlatform.Instance.ShowLeaderboardUI (leaderBoardId);
}
}

void ReportScoreLocal (int score)
{
if (Social.localUser.authenticated)
{
Social.ReportScore (score, leaderBoardId, (bool success) =>
{

});
}
}

void ReportProgressLocal (int score)
{
if (Social.localUser.authenticated)
{
if (score >= 5 && score < 30)
{
Social.ReportProgress (score5, (double) score, (bool success) =>
{

});
}

}
}
}

最佳答案

添加成就后是否更新 Android 设置?还是重新发布 Google Play 服务仪表板中的更改?

还有,改变

PlayGamesPlatform.Instance.ShowAchievementsUI ();

Social.ShowAchievementsUI ();

和改变

PlayGamesPlatform.Instance.ShowLeaderboardUI (leaderBoardId);

Social.ShowLeaderboardUI();

有关详细信息,请参阅以下链接:

Google Play Games Services Tutorial (Unity) #1 - ACHIEVEMENTS and LEADERBOARDS

Achievements & Leaderboard - Google Play Services - Subway Skater - 23

希望对你有帮助:)

关于c# - GooglePlayGame 服务在 Unity 中无法正常工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51868677/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com