TimeTest.cs 803 Bytes
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class TimeTest : MonoBehaviour
{
    public Button btnStart;

    public Button btnStop;
    public Text txt_Time;

    public float time = 0;

    // Start is called before the first frame update
    void Start()
    {
        txt_Time.text = time.ToString();
        btnStart.onClick.AddListener(StartTime);
        btnStop.onClick.AddListener(StopTime);
    }

    // Update is called once per frame
    void Update()
    {
    }

    private void StartTime()
    {
        TimeControl.Instance.Schedule(1, () =>
        {
            time++;
            txt_Time.text = time.ToString();
        });
    }

    private void StopTime()
    {
        TimeControl.Instance.UnSchedule();
    }
}