{"id":21429008,"url":"https://github.com/samethope/timerutility","last_synced_at":"2025-03-16T21:42:42.723Z","repository":{"id":186243451,"uuid":"674876622","full_name":"SametHope/TimerUtility","owner":"SametHope","description":"Timer with many callbacks and utilities, can even work as a tweener.","archived":false,"fork":false,"pushed_at":"2023-08-08T20:58:31.000Z","size":11,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-23T08:16:23.187Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/SametHope.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2023-08-05T03:28:44.000Z","updated_at":"2023-08-05T03:38:09.000Z","dependencies_parsed_at":null,"dependency_job_id":"d6e3538b-b7db-4667-8a40-a8ada2d90541","html_url":"https://github.com/SametHope/TimerUtility","commit_stats":null,"previous_names":["samethope/timerutility"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SametHope%2FTimerUtility","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SametHope%2FTimerUtility/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SametHope%2FTimerUtility/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SametHope%2FTimerUtility/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SametHope","download_url":"https://codeload.github.com/SametHope/TimerUtility/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243940062,"owners_count":20372044,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-22T22:15:30.855Z","updated_at":"2025-03-16T21:42:42.692Z","avatar_url":"https://github.com/SametHope.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Timer Utility\n\nTimer Utility revolves around the `Timer` class which primarly functions as a timer and can also be used to lerp values if you want to. It utilizes the observer pattern intensively for easily managing behaviours.\n\n## Features\n\n- **Flexible Update Types:** Choose between Update, FixedUpdate, LateUpdate, and even custom time intervals for your timers' update methods with Manual updates.\n- **Event System:** Set up event callbacks for `OnStart`, `OnUpdate`, `OnComplete`, `OnStop`, `OnKill`, `OnPause`, and `OnUnpause`.\n- **Filtering:** Access and filter through all your timers easily with the `TimerRunner.AliveTimers` list and `Name` property on the timers.\n- **Tweening:** You can tween/lerp values with provided methods in the `TimerUtilities.EasingFunctions` class.\n- **Efficient:** The utility is designed with performance and memory in mind; it does not use coroutines internally.\n- **Fully Documented:** All code you can access is XML documented clearly and accurately.\n- **Open Source:** The code is open source.\n\n## Setup\n\n1. Get the scripts inside your project, ideally to the `Assets/Plugins/SametHope/TimerUtility` folder.\n2. Done.\n\n## Usage\n\nHere are some example code snippets:\n\n```csharp\n// Create\nTimer timer = new Timer();\n\n// Setup\ntimer.Name = \"MyTimer\";\ntimer.UpdateMethod = TimerUpdateMethod.FixedUpdate; // Default is TimerUpdateMethod.NormalUpdate\ntimer.CompleteTime = 10f; // If not set, the timer will run forever until it is manually completed/stopped/killed\n\n// Subscribe to events you need\ntimer.OnStart += () =\u003e Debug.Log(\"Started.\");\ntimer.OnUpdate += () =\u003e Debug.Log(\"Elapsed.\");\ntimer.OnComplete += () =\u003e Debug.Log(\"Completed.\");\ntimer.OnStop += () =\u003e Debug.Log(\"Stopped.\");\ntimer.OnKill += () =\u003e Debug.Log(\"Killed.\");\ntimer.OnPause += () =\u003e Debug.Log(\"Paused.\");\ntimer.OnUnpause += () =\u003e Debug.Log(\"Unpaused.\");\n\n// Start\ntimer.Start();\n\n// Access globally\nbool isTimerPaused = TimerRunner.AliveTimers.Find(t =\u003e t.Name == \"MyTimer\")?.IsPaused ?? false;\n\n// Pause and unpause\ntimer.Pause();\ntimer.Unpause();\n\n// Complete manually\ntimer.Complete(updateElapsedTime: false);\n\n// Stop manually\ntimer.Stop();\n\n// Kill manually\ntimer.Kill();\n\n// Tween\nVector3 startPosition = transform.position;\nVector3 endPosition = transform.position + Vector3.up;\nfloat easeValue = TimerUtilities.EasingFunctions.InOutSine(timer.GetNormalizedTime()); // Use an easing function to get an interpolated value based on the normalized time\nVector3 interpolatedPosition = Vector3.Lerp(startPosition, endPosition, easeValue);\n\n// Utility\nbool notStartedYet1 = timer.IsAliveAndNotNull(); // Extension call for ease of use. Normal IsAlive property is obviously not accessible on null instances unlike this method\n\n// Furthermore\n[SerializeField] private Timer _myTimer; // Serialize a timer to show it in the inspector, really useful for debugging. You can also just make it public too, of course.\n```\n\n## Future Plans\n- **Looping Support:** Timers will be able to loop instead of mostly being one time usables.\n- **Editor Support:** Timers will also be able to run on outside of play mode.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsamethope%2Ftimerutility","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsamethope%2Ftimerutility","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsamethope%2Ftimerutility/lists"}