This commit is contained in:
JA
2026-06-20 19:34:23 +08:00
parent e5031c0068
commit d442805c3f
4136 changed files with 514641 additions and 0 deletions

View File

@@ -0,0 +1,39 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Timer : MonoBehaviour
{
private float timer;
private Action action;
private bool timeIsDone;
private void Update()
{
if (timer > 0 && !timeIsDone)
{
timer -= Time.deltaTime;
if (timer <= 0)
{
action?.Invoke();
timeIsDone = true;
ManagersMode.Poll.UnSpwan("Timer","timer",this.gameObject);
}
}
}
/// <summary>
/// 创建计时器
/// </summary>
/// <param name="timer">计时时间</param>
/// <param name="cllBackAction">回调函数</param>
public void CreateTime(float timer,Action cllBackAction, bool timeIsDone = false)
{
this.timer = timer;
this.action = cllBackAction;
this.timeIsDone = timeIsDone;
}
}