{"id":21358842,"url":"https://github.com/gameframex/com.gameframex.unity.timer","last_synced_at":"2025-08-12T05:16:39.646Z","repository":{"id":232311759,"uuid":"784010735","full_name":"GameFrameX/com.gameframex.unity.timer","owner":"GameFrameX","description":null,"archived":false,"fork":false,"pushed_at":"2025-06-01T06:59:48.000Z","size":46,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-06-21T03:43:25.456Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/GameFrameX.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2024-04-09T02:21:20.000Z","updated_at":"2025-06-01T06:59:52.000Z","dependencies_parsed_at":"2024-07-23T09:45:29.175Z","dependency_job_id":"8a53a04f-a9fb-4b9b-b85a-c9f8995feb09","html_url":"https://github.com/GameFrameX/com.gameframex.unity.timer","commit_stats":null,"previous_names":["alianblank/com.alianblank.gameframex.timer","alianblank/com.alianblank.gameframex.unity.timer","gameframex/com.gameframex.unity.timer"],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/GameFrameX/com.gameframex.unity.timer","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GameFrameX%2Fcom.gameframex.unity.timer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GameFrameX%2Fcom.gameframex.unity.timer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GameFrameX%2Fcom.gameframex.unity.timer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GameFrameX%2Fcom.gameframex.unity.timer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/GameFrameX","download_url":"https://codeload.github.com/GameFrameX/com.gameframex.unity.timer/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GameFrameX%2Fcom.gameframex.unity.timer/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270005591,"owners_count":24510939,"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","status":"online","status_checked_at":"2025-08-12T02:00:09.011Z","response_time":80,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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-22T05:22:36.902Z","updated_at":"2025-08-12T05:16:39.620Z","avatar_url":"https://github.com/GameFrameX.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"﻿## HOMEPAGE\n\nGameFrameX 的 Timer 计时器组件\n\n**Timer 计时器组件 (Timer Request)** - 提供计时器相关的接口。\n\n# 使用文档(文档编写于GPT4)\n\n# TimerComponent 功能说明文档\n\n## 概述\n\n`TimerComponent` 是一个Unity组件，用于在Unity项目中管理和处理计时任务。它允许开发者添加各种定时执行的任务，比如定时触发事件、重复执行或者每帧更新执行的任务。\n\n## 方法说明\n\n### Add\n\n添加一个定时调用的任务。\n\n**参数：**\n\n- `float interval`：间隔时间，以毫秒为单位。\n- `int repeat`：重复次数，0 表示任务会无限重复。\n- `Action\u003cobject\u003e callback`：任务触发时执行的回调函数。\n- `object callbackParam`（可选）：回调函数的参数。\n\n**用法：**\n\n```csharp\nAdd(1000, 5, MyMethod);\n```\n\n### AddOnce\n\n添加一个只执行一次的定时任务。\n\n**参数：**\n\n- `float interval`：间隔时间，以毫秒为单位。\n- `Action\u003cobject\u003e callback`：任务触发时执行的回调函数。\n- `object callbackParam`（可选）：回调函数的参数。\n\n**用法：**\n\n```csharp\nAddOnce(5000, MyMethod);\n```\n\n### AddUpdate\n\n添加一个每帧更新执行的任务。\n\n**参数：**\n\n- `Action\u003cobject\u003e callback`：每帧执行的回调函数。\n- `object callbackParam`（可选）：回调函数的参数。\n\n**用法：**\n\n```csharp\nAddUpdate(MyMethod);\n```\n\n### Exists\n\n检查指定的任务是否存在。\n\n**参数：**\n\n- `Action\u003cobject\u003e callback`：要检查的回调函数。\n\n**返回：**\n\n- `bool`：存在返回 `true`，不存在返回 `false`。\n\n**用法：**\n\n```csharp\nbool doesExist = Exists(MyMethod);\n```\n\n### Remove\n\n移除指定的任务。\n\n**参数：**\n\n- `Action\u003cobject\u003e callback`：要移除的回调函数。\n\n**用法：**\n\n```csharp\nRemove(MyMethod);\n```\n\n## 使用案例\n\n要使用`TimerComponent`，需要先在您的Unity项目中将此组件添加到游戏对象上。以下是如何使用这个组件的一个简单示例：\n\n```csharp\n// 假设这是您要触发的方法\nvoid MyMethod(object param)\n{\n    Debug.Log(\"方法被触发\");\n}\n\n// 创建定时任务，每隔1秒执行MyMethod方法，共执行5次\nGetComponent\u003cTimerComponent\u003e().Add(1000, 5, MyMethod);\n\n// 创建定时任务，5秒后执行一次MyMethod方法\nGetComponent\u003cTimerComponent\u003e().AddOnce(5000, MyMethod);\n\n// 检查是否存在某个任务\nbool exists = GetComponent\u003cTimerComponent\u003e().Exists(MyMethod);\n\n// 移除特定的任务\nGetComponent\u003cTimerComponent\u003e().Remove(MyMethod);\n```\n\n## 注意事项\n\n- 在使用定时器前，请确保`TimerManager`已正确初始化并且已正确注入到`GameFrameworkEntry`模块中。\n- 尽量避免使用过小的间隔时间（例如小于帧时间），这可能会导致性能问题。\n\n# 使用方式(任选其一)\n\n1. 直接在 `manifest.json` 的文件中的 `dependencies` 节点下添加以下内容\n   ```json\n      {\"com.gameframex.unity.timer\": \"https://github.com/AlianBlank/com.gameframex.unity.timer.git\"}\n    ```\n2. 在Unity 的`Packages Manager` 中使用`Git URL` 的方式添加库,地址为：https://github.com/AlianBlank/com.gameframex.unity.timer.git\n\n3. 直接下载仓库放置到Unity 项目的`Packages` 目录下。会自动加载识别","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgameframex%2Fcom.gameframex.unity.timer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgameframex%2Fcom.gameframex.unity.timer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgameframex%2Fcom.gameframex.unity.timer/lists"}