I have this game I am making and I want an input name field panel to pop up on the GameOver screen only when the player achieves a higher score than the previous uploaded score. Of course if there is no personal entry uploaded previously I just want the score to be uploaded. I tried doing it this way to enable the input username panel:
public class UIGameOver : MonoBehaviour { [SerializeField] TextMeshProUGUI scoreText; [SerializeField] GameObject inputPlayerPanel; ScoreKeeper scoreKeeper; private void Awake() { scoreKeeper = FindObjectOfType<ScoreKeeper>(); } private void Start() { scoreText.text = "You Scored:\n" + scoreKeeper.GetScore(); Leaderboards.Laser_Defender.GetPersonalEntry(HighScoreEntry); } void HighScoreEntry(Entry entry) { int score = scoreKeeper.GetScore(); if (score > entry.Score) { inputPlayerPanel.SetActive(true); } } }
And here is the submit score code:
public void SubmitScore() { SetLeaderboardEntry(inputPlayerName.text, scoreKeeper.GetScore() ); Debug.Log("Player name: " + inputPlayerName.text); Debug.Log("Score: " + scoreKeeper.GetScore()); }
After clearing PlayerPrefs, I tried this code got a Bad Web Request:Should I have used local variables in my code before the Personal Entry was defined or something else?
Should I have used the Leaderboard Search query instead?