mirror of
https://github.com/celisej567/forest.git
synced 2026-09-17 20:08:53 +03:00
1
This commit is contained in:
29
Assets/scripts/Timer.cs
Normal file
29
Assets/scripts/Timer.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class Timer : MonoBehaviour
|
||||
{
|
||||
// Start is called before the first frame update
|
||||
|
||||
public float StartFromTime = 0;
|
||||
public bool IsCountdown = false;
|
||||
public float Speed = 1;
|
||||
|
||||
float currentTime;
|
||||
void Start()
|
||||
{
|
||||
if (StartFromTime != 0)
|
||||
currentTime = StartFromTime;
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
currentTime += IsCountdown ? -Time.deltaTime : Time.deltaTime;
|
||||
currentTime = (float)System.Math.Round(currentTime, 2);
|
||||
GetComponent<Text>().text = currentTime.ToString();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user