Question by
morian35 · Jun 23, 2020 at 12:56 PM ·
c#scripting problemscript.google play
can i get help please
hi iam using cloudonce to submit my game highscore to google play leaderboard but when i test the game in the phone i just get a pupout when i click in the leaderboard btn and even if i openit manualy i dont see the score there please i need your help
this is my script
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using CloudOnce;
public class CloudOnceServices : MonoBehaviour
{
public static CloudOnceServices instance;
private void Awake()
{
TestSingleton();
}
private void TestSingleton()
{
if (instance != null) { Destroy(gameObject); return; }
instance = this;
DontDestroyOnLoad(gameObject);
}
public void SubmitScoreToLeaderboard(int TopScore)
{
Leaderboards.HighScore.SubmitScore(TopScore);
}
}
GameplayManager script
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class GameplayManager : MonoBehaviour
{
public Text scoreText;
public Text highScore;
private int currentScore;
private void Start()
{
PlayerPrefs.SetInt("Points", 0);
PlayerPrefs.GetInt("HighScore", 0);
}
public void UpdateScore(int score)
{
currentScore += score;
scoreText.text = "" + currentScore.ToString();
PlayerPrefs.SetInt("Points", currentScore);
if (currentScore > PlayerPrefs.GetInt("HighScore", 0))
{
PlayerPrefs.SetInt("HighScore", currentScore);
PlayerPrefs.Save();
}
}
}
highscore
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class highscore : MonoBehaviour
{
private int TopScore;
public Text bestScore;
// Start is called before the first frame update
void Awake()
{
TopScore = PlayerPrefs.GetInt("HighScore");
bestScore.text = "" + TopScore.ToString();
CloudOnceServices.instance.SubmitScoreToLeaderboard(TopScore);
}
}
Comment