{"id":24688772,"url":"https://github.com/aio-game/unity.timer","last_synced_at":"2025-06-15T15:02:23.085Z","repository":{"id":243348716,"uuid":"812101425","full_name":"AIO-GAME/Unity.Timer","owner":"AIO-GAME","description":"✨ Unity High Efficiency Timer ✨","archived":false,"fork":false,"pushed_at":"2024-12-13T02:38:00.000Z","size":195,"stargazers_count":5,"open_issues_count":0,"forks_count":1,"subscribers_count":0,"default_branch":"main","last_synced_at":"2024-12-13T03:28:18.537Z","etag":null,"topics":["timer","unity"],"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/AIO-GAME.png","metadata":{"files":{"readme":".github/README.md","changelog":null,"contributing":".github/CONTRIBUTING","funding":null,"license":"LICENSE.md","code_of_conduct":".github/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":".github/SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-06-08T00:59:04.000Z","updated_at":"2024-12-13T02:37:43.000Z","dependencies_parsed_at":"2024-12-13T03:24:17.485Z","dependency_job_id":"e7b73b97-d44c-4806-b430-b5f731d4421e","html_url":"https://github.com/AIO-GAME/Unity.Timer","commit_stats":null,"previous_names":["aio-game/unity.timer"],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AIO-GAME%2FUnity.Timer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AIO-GAME%2FUnity.Timer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AIO-GAME%2FUnity.Timer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AIO-GAME%2FUnity.Timer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AIO-GAME","download_url":"https://codeload.github.com/AIO-GAME/Unity.Timer/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":235733808,"owners_count":19036964,"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":["timer","unity"],"created_at":"2025-01-26T17:18:33.951Z","updated_at":"2025-01-26T17:18:34.612Z","avatar_url":"https://github.com/AIO-GAME.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e \n\u003cimg src=\"RES/Logo.svg\" width=\"256\" height=\"256\" alt=\"https://github.com/AIO-GAME\"\u003e \n\u003c/p\u003e\n\u003cp align=\"center\" style=\"font-size: 24px;\"\u003e \n\u003cb\u003eUnity Timer\u003c/b\u003e\n\u003c/p\u003e\n\u003cp align=\"center\"\u003e\u003ca href=\"README_EN.md\"\u003eEnglish\u003c/a\u003e | 简体中文\u003c/p\u003e\n\u003cp align=\"center\"\u003e\n\u003ca href=\"https://github.com/AIO-GAME/Unity.Timer/security/policy\"\u003e \n\u003cimg alt=\"\" src=\"https://img.shields.io/github/package-json/unity/AIO-GAME/Unity.Timer\"\u003e \n\u003c/a\u003e\n\u003ca href=\"https://github.com/AIO-Game/Unity.Timer\"\u003e\n\u003cimg src=\"https://img.shields.io/github/license/AIO-Game/Unity.Timer\" alt=\"\"/\u003e\n\u003c/a\u003e\n\u003ca href=\"https://github.com/AIO-Game/Unity.Timer\"\u003e\n\u003cimg src=\"https://img.shields.io/github/languages/code-size/AIO-Game/Unity.Timer?label=size\" alt=\"\"/\u003e\n\u003c/a\u003e\n\u003ca href=\"https://openupm.com/packages/com.aio.timer/\"\u003e\n\u003cimg src=\"https://img.shields.io/npm/v/com.aio.timer?label=openupm\u0026amp;registry_uri=https://package.openupm.com\" alt=\"\"/\u003e\n\u003c/a\u003e\n\u003c/p\u003e\n\n## ⚙ 安装\n\n\u003cdetails\u003e\n\u003csummary\u003e\n\u003cspan style=\"color: deepskyblue; \"\u003e\u003cb\u003ePackages Manifest\u003c/b\u003e\u003c/span\u003e\n\u003c/summary\u003e\n\n````json\n{\n  \"dependencies\": {\n    \"com.aio.timer\": \"latest\"\n  },\n  \"scopedRegistries\": [\n    {\n      \"name\": \"package.openupm.com\",\n      \"url\": \"https://package.openupm.com\",\n      \"scopes\": [\n        \"com.aio.runner\",\n        \"com.aio.timer\"\n      ]\n    }\n  ]\n}\n````\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\n\u003cspan style=\"color: deepskyblue; \"\u003e\u003cb\u003eUnity PackageManager\u003c/b\u003e\u003c/span\u003e\n\u003c/summary\u003e\n\n\u003e open upm *中国版*\n\n~~~\nName: package.openupm.cn\nURL: https://package.openupm.cn\nScope(s): com.aio.timer\n~~~\n\n\u003e open upm *国际版*\n\n~~~\nName: package.openupm.com\nURL: https://package.openupm.com\nScope(s): com.aio.timer\n~~~\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\n\u003cspan style=\"color: deepskyblue; \"\u003e\u003cb\u003eCommand Line\u003c/b\u003e\u003c/span\u003e\n\u003c/summary\u003e\n\n\u003e open *upm-cli*\n\n~~~\nopenupm add com.aio.timer\n~~~\n\n\u003c/details\u003e\n\n## ⭐ 关于\n\n- **这是一个 高效时间轮 定时器工具类**\n- ✅ **支持 Unity 2019.4 LTS 或更高版本**\n- ✅ **支持 .NET 4.x 和 .NET Standard 2.0**\n- ✅ **支持 自定义定时次数**\n- ✅ **支持 子线程后台运行或主线程协程运行**\n- ✅ **支持 自定义时间精度单位**\n- ✅ **支持 自定义时间轮大小**\n- ✅ **支持 时间轮动态扩容**\n- ✅ **支持 同时添加1000000+ 定时任务**\n- ✅ **支持 `int` `string` `enum` `Guid` 作为 循环任务KEY**\n\n## 📚 使用\n\n\u003ch4\u003e初始化\u003c/h4\u003e\n\n```csharp \nTimerSystem.Initialize(\"updateLimit:long=10\",\"capacity:int=8196\");\n``` \n\n\u003ch4\u003e自定义时间轮精度\u003c/h4\u003e\n\n```csharp \nTimerSystemSettings.TimingUnitsEvent += Week;\n\npublic static void Week(ICollection\u003c(long, long, long)\u003e units)\n{\n    var DistanceUnit = 2; // ms\n    var MS_SECOND = 1000;\n    var MS_MIN = 1000 * 60;\n    var MS_HOUR = MS_MIN * 60;\n    var MS_DAY = MS_HOUR * 24;\n    var MS_WEEK = MS_DAY * 7;\n    units.Add((MS_SECOND, DistanceUnit, MS_SECOND / DistanceUnit));\n    units.Add((MS_MIN, MS_SECOND, 60));\n    units.Add((MS_HOUR, MS_MIN, 60));\n    units.Add((MS_DAY, MS_HOUR, 24));\n    units.Add((MS_WEEK, MS_DAY, 7));\n}\n``` \n\n\u003ch4\u003e添加定时任务\u003c/h4\u003e\n\n```csharp \n// 后台线程\nTimerSystem.Push(\"KEY\", 1, () =\u003e { Debug.Log(\"1ms\"); });            // 自定义次数 默认为1\nTimerSystem.PushOnce(\"KEY\", 2, () =\u003e { Debug.Log(\"2ms\"); });        // 一次\nTimerSystem.PushLoop(\"KEY\", 1000, () =\u003e { Debug.Log(\"2s\"); });      // 循环\n// 主线程\nTimerSystem.PushMain(\"KEY\", 1, () =\u003e { Debug.Log(\"1ms\"); }, 1);     // 自定义次数 默认为1\nTimerSystem.PushOnceMain(\"KEY\", 2, () =\u003e { Debug.Log(\"2ms\"); });    // 一次\nTimerSystem.PushLoopMain(\"KEY\", 1000, () =\u003e { Debug.Log(\"2s\"); });  // 循环\n``` \n\n\u003ch4\u003e移除循环定时任务\u003c/h4\u003e\n\n```csharp\nTimerSystem.Pop(tid);\n```  \n\n## ✨ 贡献者\n\n\u003c!-- readme: collaborators,contributors -start --\u003e\n\u003ctable\u003e\n\t\u003ctbody\u003e\n\t\t\u003ctr\u003e\n            \u003ctd align=\"center\"\u003e\n                \u003ca href=\"https://github.com/xinansky\"\u003e\n                    \u003cimg src=\"https://avatars.githubusercontent.com/u/45371089?v=4\" width=\"64;\" alt=\"xinansky\"/\u003e\n                    \u003cbr /\u003e\n                    \u003csub\u003e\u003cb\u003exinansky\u003c/b\u003e\u003c/sub\u003e\n                \u003c/a\u003e\n            \u003c/td\u003e\n            \u003ctd align=\"center\"\u003e\n                \u003ca href=\"https://github.com/Starkappa\"\u003e\n                    \u003cimg src=\"https://avatars.githubusercontent.com/u/155533864?v=4\" width=\"64;\" alt=\"Starkappa\"/\u003e\n                    \u003cbr /\u003e\n                    \u003csub\u003e\u003cb\u003eStarkappa\u003c/b\u003e\u003c/sub\u003e\n                \u003c/a\u003e\n            \u003c/td\u003e\n\t\t\u003c/tr\u003e\n\t\u003ctbody\u003e\n\u003c/table\u003e\n\u003c!-- readme: collaborators,contributors -end --\u003e\n\n## 📢 致谢\n\n- **谢谢您选择我们的扩展包。**\n- **如果此软件包对您有所帮助。**\n- **请考虑通过添加⭐来表示支持。**\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faio-game%2Funity.timer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faio-game%2Funity.timer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faio-game%2Funity.timer/lists"}