Skip to content
프로젝트

adammyhre/Unity-Improved-Timers

GitHub에서 보기

소개

Improved Unity C# Timers that run as a Player Loop System

게임 및 에뮬레이션

이 수치를 측정하는 방법

측정된 스타 증가

in 24h
-1
in 7 days
-1
in 15 days
-1
in 1 month
기록 수집 중

서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.

README.md

Original

Improved Unity Timers

PlayerLoop2

An extensible Timer solution for Unity Game Development. Timers are self managing by injecting a Timer Manager class into Unity's Update loop.

Create your own Timers by extending the Timer abstract class!

Example Usage

CountdownTimer timer = new CountdownTimer(5f);

void Start() {
    timer.OnTimerStart += () => Debug.Log("Timer started");
    timer.OnTimerStop += () => Debug.Log("Timer stopped");
    timer.Start();
    
    timer.Pause();
    timer.Resume();
    
    timer.Reset();
    timer.Reset(10f);
    
    Debug.Log(timer.IsRunning ? "Timer is running" : "Timer is not running");
    Debug.Log(timer.IsFinished ? "Timer is finished" : "Timer is not finished");
    
    timer.Stop();
}

void Update() {
    Debug.Log(timer.CurrentTime);
    Debug.Log(timer.Progress);
}

void OnDestroy() {
    timer.Dispose();
}

Notes

Several Timers are already included, but you can create any kind of Timer you need that can be adjusted every frame. The included Timers are:

  • CountdownTimer: Counts down from a specified time to zero.
  • FrequencyTimer: Ticks N times per second.
  • StopwatchTimer: Counts up from zero to infinity.

Classes extending the Timer class must implement the Tick method to increment or decrement the Timer, and the IsFinished property which is a convenience for consumers.

Call Dispose when you don't need a Timer anymore to ensure proper garbage collection.

How to Install

Simply download the library into your Unity project and access the utilities across your scripts or import it in Unity with the Unity Package Manager using this URL:

https://github.com/adammyhre/Unity-Improved-Timers.git

Add to Manifest

Alternatively, you can add the following line to your project's manifest.json file.

"com.gitamend.improvedtimers": "https://github.com/adammyhre/Unity-Improved-Timers.git"

YouTube

You can also check out my YouTube channel for more Unity content.

관련 프로젝트 살펴보기

불러오는 중…