Skip to content

Instantly share code, notes, and snippets.

@luisartg
Created March 31, 2019 04:03
Show Gist options
  • Save luisartg/f4a89f684f9f988f1571ab63fe3ab2f8 to your computer and use it in GitHub Desktop.
Save luisartg/f4a89f684f9f988f1571ab63fe3ab2f8 to your computer and use it in GitHub Desktop.
Score Diplay loading all current sessions
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;
public class ScoreDisplay : MonoBehaviour
{
[SerializeField] TextMeshProUGUI scoreText = null;
[SerializeField] GameSession gameSession = null;
// Start is called before the first frame update
void Start()
{
scoreText = GetComponent<TextMeshProUGUI>();
var gameSessions = FindObjectsOfType<GameSession>();
Debug.Log("Found " + gameSessions.Length.ToString() + " sessions!");
gameSession = gameSessions[0];
}
// Update is called once per frame
void Update()
{
scoreText.text = gameSession.GetScore().ToString();
Debug.Log("Displaying " + gameSession.GetScore().ToString());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment