39 lines
1.2 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using ZXKFramework;
public class TestTimeCounter : MonoBehaviour
{
Text showText;
Button startBtn;
Button stopBtn;
Button clearBtn;
TimeCounterManager timeCounterManager;
private void Awake()
{
timeCounterManager = GetComponentInChildren<TimeCounterManager>();
showText = transform.FindFirst<Text>("TimeText");
startBtn = transform.FindFirst<Button>("StartBtn");
stopBtn = transform.FindFirst<Button>("StopBtn");
clearBtn = transform.FindFirst<Button>("ClearBtn");
}
private void Start()
{
startBtn.onClick.AddListener(()=> {
timeCounterManager.StartTimeCounter((str)=> {
showText.text = str;
});
});
stopBtn.onClick.AddListener(() =>{
timeCounterManager.StopTimeCounter();
});
clearBtn.onClick.AddListener(()=> {
timeCounterManager.StopTimeCounter();
timeCounterManager.ClearTimeCounter();
showText.text = timeCounterManager.GetTime();
});
}
}