【发布时间】:2019-01-22 22:04:21
【问题描述】:
我导入了 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) =>
{
});
}
}
}
}
【问题讨论】:
-
另一个了解成就和排行榜如何运作的好方法是关注official documentation 和Type A Number github sample。通过在您的应用和 Google Play 商店中提供正确的应用程序 ID 和包名称,确保将 GPGS 集成到您的应用中。
标签: c# unity3d google-play-games