27 lines
615 B
C#
27 lines
615 B
C#
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class ScoreManager : MonoBehaviour
|
|
{
|
|
public Text scoreText;
|
|
public Text scoreTextGameover;
|
|
private float score;
|
|
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
|
void Start()
|
|
{
|
|
|
|
}
|
|
|
|
// Update is called once per frame
|
|
void Update()
|
|
{
|
|
if(GameObject.FindGameObjectWithTag("Player") != null)
|
|
{
|
|
score += 1 * Time.deltaTime;
|
|
scoreText.text = ((int)score).ToString();
|
|
scoreTextGameover.text = scoreText.text;
|
|
}
|
|
}
|
|
|
|
}
|