WooTimer
ForkForked from OnClick9927/WooTimer
WooTimer provides a versatile timer system for Unity with fluent API design, supporting both runtime and editor functionality. Features include delayed execution, repeated ticks, conditional waiting, and sequential/parallel timer composition. Built-in lifecycle callbacks (OnBegin, OnTick, OnComplete, OnCancel), async/await support, time scaling, and timer lifecycle management enable flexible time-based gameplay mechanics. Includes an editor inspector window for monitoring active timers.
Unity Project
Built with Unity 2021.3.33f1c1 · download the source from GitHub
Dependencies (35)
Unity UI 1.0.0VS Code Editor 1.2.5AI 1.0.0UI 1.0.0VR 1.0.0XR 1.0.0Wind 1.0.0Audio 1.0.0Cloth 1.0.0IMGUI 1.0.0Umbra 1.0.0Video 1.0.0Test Framework 1.1.33Physics 1.0.0Terrain 1.0.0Tilemap 1.0.0Visual Studio Editor 2.0.23Director 1.0.0Vehicles 1.0.0Animation 1.0.0Physics 2D 1.0.0com.unity.modules.androidjni 1.0.0UI Elements 1.0.0Asset Bundle 1.0.0JSON Serialize 1.0.0Screen Capture 1.0.0Particle System 1.0.0Terrain Physics 1.0.0Unity Analytics 1.0.0Image Conversion 1.0.0Unity Web Request 1.0.0Unity Web Request WWW 1.0.0Unity Web Request Audio 1.0.0Unity Web Request Texture 1.0.0Unity Web Request Asset Bundle 1.0.0
README
WooTimer
好用的计时器 运行时+编辑器
upm https://github.com/OnClick9927/WooTimer.git#upm
API 介绍 更多用法
//延时+API
var delay = TimeEx.Delay(1, (time, delta) => { Debug.Log("Do Sth"); })
.OnBegin((context) => { Debug.Log("OnBegin"); })
.OnCancel((context) => { Debug.Log("OnCancel"); })
.OnComplete((context) => { Debug.Log("OnComplete"); })
.OnTick((time, delta) => { Debug.Log("OnTick"); })
.SetTimeScale(2f)
.SetId("Test_ID")
.AddTo(this);
delay.Pause();
delay.UnPause();
delay.Stop();
delay.Cancel();
// 多次调用+await 支持
await TimeEx.Tick(1, 10, (time, delta) => { Debug.Log("Do Sth"); }).AddTo(this);
Debug.Log("Do Sth");
// 条件等待
await TimeEx.While((time, delta) => { return Time.time < 5; }, 1f).AddTo(this);
// 串行 计时器
await TimeEx.Sequence()
.NewContext(() => TimeEx.Delay(1, (time, delta) => { Debug.Log("Do Sth"); }))
.NewContext(() => TimeEx.Delay(1, (time, delta) => { Debug.Log("Do Sth"); }))
.AddTo(this);
//并行 计时器
await TimeEx.Parallel()
.NewContext(() => TimeEx.Delay(1, (time, delta) => { Debug.Log("Do Sth"); }))
.NewContext(() => TimeEx.Delay(1, (time, delta) => { Debug.Log("Do Sth"); }))
.AddTo(this);
// 杀掉 所有 用 AddTo 绑定到 this 的计时器
this.KillTimers();
编辑器监视窗口
Comments
No comments yet. Be the first!
Sign in to join the conversation
Sign In