# com.gameframex.unity.coroutine
**Repository Path**: gameframex/com.gameframex.unity.coroutine
## Basic Information
- **Project Name**: com.gameframex.unity.coroutine
- **Description**: GameFrameX Unity Coroutine component providing enhanced coroutine management with pooling and lifecycle control
- **Primary Language**: Unknown
- **License**: Apache-2.0
- **Default Branch**: main
- **Homepage**: https://gameframex.doc.alianblank.com
- **GVP Project**: No
## Statistics
- **Stars**: 0
- **Forks**: 0
- **Created**: 2024-07-23
- **Last Updated**: 2026-07-03
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README

# Game Frame X Coroutine
[](https://github.com/GameFrameX/com.gameframex.unity.coroutine/blob/main/LICENSE.md)
[](https://github.com/GameFrameX/com.gameframex.unity.coroutine/releases)
[](https://unity.com/)
[](https://gameframex.doc.alianblank.com)
独立游戏前后端一体化解决方案 · 独立游戏开发者的圆梦大使
[文档](https://gameframex.doc.alianblank.com) · [快速开始](#快速开始) · QQ群: 467608841 / 233840761
[English](README.md) | **简体中文** | [繁體中文](README.zh-TW.md) | [日本語](README.ja.md) | [한국어](README.ko.md)
## 项目简介
Game Frame X Coroutine 是一个基于 GameFrameX 框架的 Unity 协程管理包,扩展了 Unity 的内建协程管理功能。
**Coroutine 协程组件 (Coroutine Component)** - 提供扩展了 Unity 的内建协程管理功能的接口。
## 功能特性
1. **启动协程**: 使用 `StartCoroutine(IEnumerator enumerator)` 方法来启动一个协程。迭代器和 Unity 的协程对象存储在并发字典中,确保可以随时访问和管理。
2. **停止协程**: 通过 `StopCoroutine(IEnumerator enumerator)` 或 `StopCoroutine(UnityEngine.Coroutine coroutine)` 方法停止单个协程。同时从 Unity 和内部字典中移除协程,防止内存泄漏。
3. **停止所有协程**: 通过 `StopAllCoroutines()` 方法停止所有正在运行的协程,确保干净停止并清空内部跟踪字典。
4. **帧结束时回调**: `WaitForEndOfFrameFinish(System.Action callback)` 方法允许在当前帧渲染结束后执行回调。
## 快速开始
### 系统要求
- Unity 2017.1 或更高版本
### 安装
选择以下任一方式:
1. 编辑 Unity 项目的 `Packages/manifest.json`,添加 `scopedRegistries` 部分:
```json
{
"scopedRegistries": [
{
"name": "GameFrameX",
"url": "https://gameframex.upm.alianblank.uk",
"scopes": [
"com.gameframex"
]
}
],
"dependencies": {
"com.gameframex.unity.coroutine": "1.0.3"
}
}
```
`scopes` 控制哪些包通过此注册表解析。只有以 `com.gameframex` 开头的包才会从这个注册表获取。
2. 直接在 `manifest.json` 的 `dependencies` 节点下添加以下内容:
```json
{
"com.gameframex.unity.coroutine": "https://github.com/gameframex/com.gameframex.unity.coroutine.git"
}
```
3. 在 Unity 的 `Package Manager` 中使用 `Git URL` 的方式添加库,地址为:`https://github.com/gameframex/com.gameframex.unity.coroutine.git`
4. 直接下载仓库放置到 Unity 项目的 `Packages` 目录下,会自动加载识别。
## 使用示例
### 启动一个协程
```csharp
IEnumerator YourCoroutine()
{
// 协程执行的内容
yield return null;
}
CoroutineComponent coroutineComponent = gameObject.AddComponent