1

Не могу отправить результат в Таблицу Лидеров.

Пишет Невероятно! Рейтинг игроков для этой игры пуст.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using GooglePlayGames;
using GooglePlayGames.BasicApi;
using UnityEngine.SocialPlatforms;
using System;

public class Score : MonoBehaviour {

    private static string BestScoreKey = "BestScore";

    private int currentScore = 0;
    public int bestScore = 0;   //private int bestScore = 0;

    private Text scoreText;
    private Text bestScoreText;


    // Use this for initialization
    void Start () {
        GetMyComponents ();
        GetBestScore ();
        UpdateScore (0);

        PlayGamesPlatform.Activate();
        PlayGamesClientConfiguration config = new PlayGamesClientConfiguration.Builder().Build();
        PlayGamesPlatform.InitializeInstance(config);
        PlayGamesPlatform.Activate();

    //    SignIn();

    }

public void SignIn () { 

    Social.localUser.Authenticate((bool success) => { 

        if (success) { 

            Social.ReportScore(bestScore, "DyeUknhiqFmEHlDS", (bool success2) => { 
                //Handle Report Success 
            }); 
            //}); !!!

        } 

    }); // !!!

}

    // Update is called once per frame
    void Update () {
    }

    public void UpdateScore (int scoreNumber) {
        currentScore = currentScore + scoreNumber;

        if(currentScore > bestScore){
            bestScore = currentScore;
            StoreBestScore (bestScore);
        }

        scoreText.text = "" + currentScore;
        bestScoreText.text = "High Score: " + bestScore;
    }

    void GetBestScore(){
        bestScore = PlayerPrefs.GetInt(BestScoreKey);
    }

    void StoreBestScore(int bestScore){
        PlayerPrefs.SetInt (BestScoreKey, bestScore);
    }

    public void GetMyComponents(){
        scoreText = GameObject.FindGameObjectWithTag ("ScoreText").GetComponent<Text> ();
        bestScoreText = GameObject.FindGameObjectWithTag ("BestScoreText").GetComponent<Text> ();
    }


}

1 ответ 1

0

У Вас ничего никуда не отправляет этот скрипт, только в PlayerPrefs сохраняет, а это локальное хранилище.

Вероятно вызов закоммнетированного метода

//    SignIn();

это то, что вы ищите =)

5
  • @JonAlan и success true? 22 фев 2019 в 14:11
  • Пробывыал и так! public void ReportHighScore(int bestScore) { Social.localUser.Authenticate((bool success) => { if (success) { Social.ReportScore(bestScore, "CnyIgyminBaUteKR", (bool success2) => { //Handle Report Success }); //}); !!! } }); // !!! }
    – JonAlan
    22 фев 2019 в 14:11
  • @JonAlan и откуда взялись "CnyIgyminBaUteKR" и "DyeUknhiqFmEHlDS" 22 фев 2019 в 14:13
  • Это код Лидерборда из Понели админа Google
    – JonAlan
    22 фев 2019 в 14:14
  • @JonAlan у вас вызывается метод Social.ReportScore или нет в итоге?, если добавить Debug.Log("11") перед ним сообщение в консоли появляется? 22 фев 2019 в 14:17

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge you have read our privacy policy.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.