Не выводиться таблица лидеров Google Play Games, Unity
При добавлении таблицы лидеров Google Play, не хочет выводиться при нажатии на кнопку. А в консоли вот такая ошибка:
UnityEngine.Social:ShowLeaderboardUI ()
GameCntrl1x1:ShowLeaderBoard () (at Assets/Scripts/1x1/GameCntrl1x1.cs:99)
UnityEngine.EventSystems.EventSystem:Update () (at C:/Program Files/Unity/Hub/Editor/2019.4.23f1/Editor/Data/Resources/PackageManager/BuiltInPackages/com.unity.ugui/Runtime/EventSystem/EventSystem.cs:377)
При этом на телефоне загрузка сервисов есть, но вот тут не задача. Я поставил метод "Handheld.Vibrate" если оно загрузиться, но вибрации нету(Я поставил авторизацию и т.д. в другом скрипте чтобы она была при запуске приложения а не в отдельной сцене). Вот скрипт выводящий таблицу лидеров(самое нужно там в самом низу):
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
using GooglePlayGames;
using GooglePlayGames.BasicApi;
using UnityEngine.SocialPlatforms;
public class GameCntrl1x1 : MonoBehaviour {
public GameObject colBlock;
public GameObject AudioSrc;
[HideInInspector] private const string leaderBoard = "CgkIirbigpIIEAIQAQ";
public GameObject CanVas;
public Vector3 [] positions;
private GameObject block;
private GameObject [] blocks = new GameObject[4];
private int rand, count;
private float rCol, gCol, bCol;
public Text score;
private static Color aColor;
private static int advCount = 0;
[HideInInspector]
public bool next, lose;
void Start () {
Vibration.Init();
count = 0;
next = false;
lose = false;
rand = Random.Range (0, positions.Length);
for (int i = 0; i < positions.Length; i++) {
blocks [i] = Instantiate (colBlock, positions[i], Quaternion.identity) as GameObject;
if (rand == i)
block = blocks [i];
}
block.GetComponent <RandCol> ().right = true;
}
void Update () {
if (lose)
playerLose ();
if (next && !lose)
nextColors ();
}
void nextColors () {
Vibration.Vibrate(50);
GetComponent <AudioSource> ().Play ();
count++;
score.text = count.ToString ();
aColor = new Vector4 (Random.Range (0.1f, 1f), Random.Range (0.1f, 1f), Random.Range (0.1f, 1f), 1);
GetComponent <Renderer> ().material.color = aColor;
next = false;
if (count < 3) {
rCol = 0.2f;
gCol = 0.2f;
bCol = 0.2f;
} else if (count >= 3 && count < 5) {
rCol = 0.1f;
gCol = 0.1f;
bCol = 0f;
} else if (count >= 5) {
rCol = 0f;
gCol = 0f;
bCol = 0.05f;
}
// New colors for blocks
rand = Random.Range (0, positions.Length);
for (int i = 0; i < positions.Length; i++) {
if (i == rand)
blocks [i].GetComponent <Renderer> ().material.color = aColor;
else {
float r = aColor.r + Random.Range (0.1f, rCol) > 1f ? 1f : aColor.r + Random.Range (0.1f, rCol);
float g = aColor.g + Random.Range (0.1f, gCol) > 1f ? 1f : aColor.g + Random.Range (0.1f, gCol);
float b = aColor.b + Random.Range (0.1f, bCol) > 1f ? 1f : aColor.b + Random.Range (0.1f, bCol);
blocks [i].GetComponent <Renderer> ().material.color = new Vector4 (r, g, b, aColor.a);
}
}
}
void playerLose () {
if (PlayerPrefs.GetInt("Score1x1") < count)
{
PlayerPrefs.SetInt("Score1x1", count);
Social.ReportScore(count, leaderBoard, (bool success) => { } );
}
CanVas.SetActive (true);
AudioSrc.SetActive (true);
}
public void ShowLeaderBoard()
{
Social.ShowLeaderboardUI();
}
}
А вот скрипт который грузит всё необходимое:
using System.Collections;
using System.Collections.Generic;
using GooglePlayGames;
using GooglePlayGames.BasicApi;
using UnityEngine.SocialPlatforms;
using UnityEngine;
public class GoogleGamesInit : MonoBehaviour
{
void Start()
{
PlayGamesPlatform.DebugLogEnabled = true;
PlayGamesPlatform.Activate();
Social.localUser.Authenticate(success =>
{
if (success)
{
Handheld.Vibrate();
}
else
{
}
});
}
}
Также я пробовал например использовать всё это в одном скрипте(который сверху) Но всё равно выдавало одно и тоже. Буду благодарен за помощь?!