// Start is called before the first frame update void Start() { jugador = FindObjectOfType <puntuacionFinal>(); score = jugador.puntos; puntosJugador.GetComponent <TextMeshProUGUI>().text = $" {score} puntos"; textRepe.SetActive(false); db = FirebaseFirestore.GetInstance(FirebaseApp.Create()); CollectionReference jugadoresRef = db.Collection("jugadores"); Query query = jugadoresRef.OrderByDescending("puntos").Limit(5); ListenerRegistration listener = query.Listen(snapshot => { string top5 = "TOP 5 \n\n"; var cont = 1; foreach (DocumentSnapshot documentSnapshot in snapshot.Documents) { Dictionary <string, object> jugador = documentSnapshot.ToDictionary(); top5 += $"{cont}-{documentSnapshot.Id}..........{jugador["puntos"]}\n"; cont += 1; nicks.Add(documentSnapshot.Id.ToString()); } marcador.GetComponent <TextMeshProUGUI>().text = top5; }); }
void Awake() { if (punto == null) { punto = this; DontDestroyOnLoad(gameObject); } else { Destroy(gameObject); } }