(https://play.google.com/store/apps/deta ... .Golkepper)
Código: Selecionar todos
using GooglePlayGames;
using GooglePlayGames.BasicApi;
using UnityEngine;
using UnityEngine.SocialPlatforms;
public class PlayGamesScript : MonoBehaviour {
PlayGamesClientConfiguration config = new PlayGamesClientConfiguration.Builder()
.Build();
private void Start()
{
SignIn();
}
void Activate()
{
PlayGamesPlatform.InitializeInstance(config);
PlayGamesPlatform.DebugLogEnabled = true;
PlayGamesPlatform.Activate();
}
public void SignIn()
{
if (PlayGamesPlatform.Instance.localUser.authenticated == false)
{
Activate();
Social.localUser.Authenticate((bool success) =>
{
if (success)
{
((GooglePlayGames.PlayGamesPlatform)Social.Active).SetGravityForPopups(Gravity.BOTTOM);
}
});
}
}
public void ActivateButton(GameObject button)
{
if (PlayGamesPlatform.Instance.localUser.authenticated == false)
button.SetActive(false);
else if (PlayGamesPlatform.Instance.localUser.authenticated)
button.SetActive(true);
}
#region Achievements
public static void UnlockAchievement(string id)
{
if (PlayGamesPlatform.Instance.localUser.authenticated)
Social.ReportProgress(id, 100, success => { });
}
public static void IncrementAchievement(string id, int stepsToIncrement)
{
if (PlayGamesPlatform.Instance.localUser.authenticated)
PlayGamesPlatform.Instance.IncrementAchievement(id, stepsToIncrement, success => { });
}
public static void ShowAchievementsUI()
{
if (PlayGamesPlatform.Instance.localUser.authenticated)
{
PlayGamesPlatform.Instance.ShowAchievementsUI();
}
}
#endregion /Achievements
#region Leaderboards
public static void AddScoreToLeaderboard(string leaderboardId, long score)
{
if (PlayGamesPlatform.Instance.localUser.authenticated)
Social.ReportScore(score, leaderboardId, success => { });
}
public static void ShowLeaderboardsUI()
{
if (PlayGamesPlatform.Instance.localUser.authenticated)
Social.ShowLeaderboardUI();
}
#endregion /Leaderboards
}