https://github.com/gameframex/com.gameframex.unity.coroutine
https://github.com/gameframex/com.gameframex.unity.coroutine
Last synced: 21 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/gameframex/com.gameframex.unity.coroutine
- Owner: GameFrameX
- License: apache-2.0
- Created: 2024-04-09T11:09:13.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-07-23T10:19:10.000Z (almost 2 years ago)
- Last Synced: 2025-01-22T18:51:08.232Z (over 1 year ago)
- Language: C#
- Size: 15.6 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README

# Game Frame X Coroutine
[](https://github.com/GameFrameX/com.gameframex.unity.coroutine/releases)
[](https://github.com/GameFrameX/com.gameframex.unity.coroutine/blob/main/LICENSE.md)
[](https://gameframex.doc.alianblank.com)
**All-in-One Solution for Indie Game Development · Empowering Indie Developers' Dreams**
[Documentation](https://gameframex.doc.alianblank.com) · [Quick Start](#quick-start) · [QQ Group](https://qm.qq.com/q/5s5e1e6e6e)
**Language**: **English** | [简体中文](README.zh-CN.md) | [繁體中文](README.zh-TW.md) | [日本語](README.ja.md) | [한국어](README.ko.md)
---
## Project Overview
Game Frame X Coroutine is a Unity coroutine management package based on the GameFrameX framework, extending Unity's built-in coroutine management functionality.
**Coroutine Component** - Provides interfaces that extend Unity's built-in coroutine management capabilities.
## Features
1. **Start Coroutine**: Use `StartCoroutine(IEnumerator enumerator)` to start a coroutine. Iterators and Unity coroutine objects are stored in a concurrent dictionary for easy access and management.
2. **Stop Coroutine**: Stop individual coroutines via `StopCoroutine(IEnumerator enumerator)` or `StopCoroutine(UnityEngine.Coroutine coroutine)`. These methods ensure coroutines are removed from both Unity and the internal dictionary, preventing memory leaks.
3. **Stop All Coroutines**: Stop all running coroutines via `StopAllCoroutines()`. This method ensures clean stopping of all coroutines and clears the internal tracking dictionary.
4. **End of Frame Callback**: The `WaitForEndOfFrameFinish(System.Action callback)` method allows executing a callback after the current frame's rendering is complete.
## Quick Start
### System Requirements
- Unity 2017.1 or higher
### Installation
Choose one of the following methods:
1. Add the following to the `dependencies` section in your project's `manifest.json`:
```json
{"com.gameframex.unity.coroutine": "https://github.com/AlianBlank/com.gameframex.unity.coroutine.git"}
```
2. Use `Git URL` in Unity's Package Manager:
```
https://github.com/AlianBlank/com.gameframex.unity.coroutine.git
```
3. Download the repository and place it in your Unity project's `Packages` directory. It will be loaded automatically.
## Usage Examples
### Start a Coroutine
```csharp
IEnumerator YourCoroutine()
{
// Coroutine execution content
yield return null;
}
CoroutineComponent coroutineComponent = gameObject.AddComponent();
coroutineComponent.StartCoroutine(YourCoroutine());
```
### Stop a Coroutine
```csharp
IEnumerator yourCoroutine = YourCoroutine();
coroutineComponent.StopCoroutine(yourCoroutine);
```
### Stop All Coroutines
```csharp
coroutineComponent.StopAllCoroutines();
```
### End of Frame Callback
```csharp
void YourCallback()
{
// Callback execution content
}
coroutineComponent.WaitForEndOfFrameFinish(YourCallback);
```
Note: When adding `CoroutineComponent` to a GameObject, ensure there are no other components of the same type in your scene, as the class uses the `[DisallowMultipleComponent]` attribute.
## Documentation & Resources
- Documentation: https://gameframex.doc.alianblank.com
- Repository: https://github.com/GameFrameX/com.gameframex.unity.coroutine
- Issues: https://github.com/GameFrameX/com.gameframex.unity.coroutine/issues
## License
See [LICENSE](LICENSE.md) for details.