using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;
using TMPro;
using Dan.Main;
using System.Runtime.CompilerServices;
using JetBrains.Annotations;
public class Leaderboard : MonoBehaviour
{
[SerializeField] PlayerMovement playermovement_script;
[SerializeField] private List<TextMeshProUGUI> names;
[SerializeField] private List<TextMeshProUGUI> scores;
private string[] badWords = new string[] { "Hurensohn", "Wixer"};
private string publicLeaderboardKey = "89ba609eb052086681e456ec870985cb8f14a460da720298cded4a337e9ded2b";
//Scoremanager
[SerializeField] private TextMeshProUGUI inputScore;
[SerializeField] private TMP_InputField inputName;
public UnityEvent<string, int> submitScoreEvent;
private void Start()
{
GetLeaderboard();
}
public void GetLeaderboard()
{
LeaderboardCreator.GetLeaderboard(publicLeaderboardKey, ((msg) =>
{
int loopLength = (msg.Length < names.Count) ? msg.Length : names.Count;
for (int i = 0; i < loopLength; ++i)
{
names[i].text = msg[i].Username;
scores[i].text = msg[i].Score.ToString();
}
}));
}
public void SetLeaderboardEntry(string username, int score)
{
LeaderboardCreator.UploadNewEntry(publicLeaderboardKey, username, score, ((msg) =>
{
if (System.Array.IndexOf(badWords, name) != -1) return;
GetLeaderboard();
}));
}
public void SubmitScore()
{
submitScoreEvent.Invoke(inputName.text, System.Convert.ToInt32(timer_script.lastScore));
}
}
Thats my current script. I am very confused with the extra data. Can you help me with it?