首页 > 解决方案 > PlayerStats.Valid 不返回 true

问题描述

我正在尝试通过 google play 服务获取用户状态,以便为我的游戏制作每日奖励系统,但我没有将价值恢复为真实,我的游戏连接到 google play 但我无法获取用户的数据。这是下面的代码片段

private string gameId = "3140248";
private bool testMode = true;

public List<Upgrades> upgrades = new List<Upgrades>();
public List<Area> areas = new List<Area>();

public Text Loading;
public GameObject ErrorGoogle;
public PlayerStats PlayerStats;

public void Start()
{
    StartCoroutine("Connection");
}

IEnumerator Connection()
{
    yield return new WaitForSeconds(2f);
    PlayGamesClientConfiguration config = new PlayGamesClientConfiguration.Builder().Build();
    PlayGamesPlatform.DebugLogEnabled = true;
    PlayGamesPlatform.InitializeInstance(config);
    PlayGamesPlatform.Activate();
    PlayerStats = new PlayerStats();

    Social.localUser.Authenticate((bool success) =>
    {
        if (success == false)
        {
            ErrorGoogle.SetActive(true);
        }

        else if (PlayerStats.Valid)
        {
            Database();
        }
    });
}

标签: c#unity3dgoogle-play-servicesgoogle-play-games

解决方案


推荐阅读