AgainTheGame/timerText.cs
2022-05-15 00:03:31 +01:00

38 lines
738 B
C#

using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using UnityEngine;
using TMPro;
using UnityEngine.SceneManagement;
public class timerText : MonoBehaviour
{
TextMeshProUGUI textBox;
public float time = 0;
protected float Timer;
public int delayAmount = 1;
void Start()
{
textBox = GetComponent<TextMeshProUGUI>();
textBox.SetText("0");
}
void Update()
{
if (SceneManager.GetActiveScene().name == "game")
{
Timer += Time.deltaTime;
if (Timer >= delayAmount)
{
Timer = 0f;
time++;
textBox.SetText("{0}s", time);
PlayerPrefs.SetFloat("timeScore",time);
}
}
}
}