{"id":23015972,"url":"https://github.com/s-rayleigh/coroutineex","last_synced_at":"2025-06-12T06:11:15.291Z","repository":{"id":88187739,"uuid":"585676556","full_name":"s-rayleigh/CoroutineEx","owner":"s-rayleigh","description":"An abstraction over Unity coroutines that behaves similarly to Tasks in C#.","archived":false,"fork":false,"pushed_at":"2024-06-21T00:54:29.000Z","size":41,"stargazers_count":11,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-02T14:51:34.708Z","etag":null,"topics":["coroutines","library","unity","unity-package","unity3d"],"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/s-rayleigh.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}},"created_at":"2023-01-05T19:34:38.000Z","updated_at":"2024-06-24T05:29:25.000Z","dependencies_parsed_at":"2024-06-21T00:04:45.241Z","dependency_job_id":"847ed199-069d-430f-83c1-aebc33043267","html_url":"https://github.com/s-rayleigh/CoroutineEx","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/s-rayleigh/CoroutineEx","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/s-rayleigh%2FCoroutineEx","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/s-rayleigh%2FCoroutineEx/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/s-rayleigh%2FCoroutineEx/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/s-rayleigh%2FCoroutineEx/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/s-rayleigh","download_url":"https://codeload.github.com/s-rayleigh/CoroutineEx/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/s-rayleigh%2FCoroutineEx/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259410149,"owners_count":22852970,"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":["coroutines","library","unity","unity-package","unity3d"],"created_at":"2024-12-15T11:14:07.828Z","updated_at":"2025-06-12T06:11:15.274Z","avatar_url":"https://github.com/s-rayleigh.png","language":"C#","readme":"# CoroutineEx\n[![openupm](https://img.shields.io/npm/v/com.rayleigh.coroutineex?label=openupm\u0026registry_uri=https://package.openupm.com)](https://openupm.com/packages/com.rayleigh.coroutineex/)\n\nThis library aims to provide a more convenient and feature rich abstraction for coroutine-based asynchronous \noperations in Unity 3D and also attempts to replicate the TAP design pattern and `Task` class from .NET.\n\n# Features\n- Allows for precise control over the execution sequence.\n- Offers multiple task states.\n- Provides a way to return a value from the task.\n- Works in Editor scripts.\n- Replicates some features from the TAP.\n\n# Installation\nFollow the guide by [this link](https://openupm.com/packages/com.rayleigh.coroutineex/#modal-manualinstallation) to\ninstall the package using OpenUPM (recommended).\n\nOr you can add the package to your project via [UPM](https://docs.unity3d.com/Manual/upm-ui-giturl.html) using\nthis Git URL: https://github.com/s-rayleigh/CoroutineEx.git\n\n# System.Threading.Task vs CoroutineTask\n\n| **Task**                 | **CoroutineTask**                 |\n|--------------------------|-----------------------------------|\n| `Task.Run`               | `CoroutineTask.Run`               |\n| `Task.Delay`             | `CoroutineTask.Delay`             |\n| `Task.CompletedTask`     | `CoroutineTask.CompletedTask`     |\n| `Task.FromCancelled`     | `CoroutineTask.FromCancelled`     |\n| `Task.FromCancelled\u003c\u003e`   | `CoroutineTask.FromCancelled\u003c\u003e`   |\n| `Task.FromException`     | `CoroutineTask.FromException`     |\n| `Task.FromException\u003c\u003e`   | `CoroutineTask.FromException\u003c\u003e`   |\n| `Task.FromResult`        | `CoroutineTask.FromResult`        |\n| `Task.Exception`         | `CoroutineTask.Exception`         |\n| `Task.Status`            | `CoroutineTask.State`             |\n| `Task.WhenAll`           | `CoroutineTask.WhenAll`           |\n| `Task.WhenAny`           | `CoroutineTask.WhenAny`           |\n| `await`                  | `yield return`                    |\n| `lock` or `AsyncLock`    | `CoroutineLock`                   |\n| `TaskCompletionSource`   | `CoroutineTaskCompletionSource`   |\n| `TaskCompletionSource\u003c\u003e` | `CoroutineTaskCompletionSource\u003c\u003e` |\n\n# Examples\n\nWait 5 seconds and print \"Hello world!\":\n```csharp\nCoroutineTask.Run(ctl =\u003e \n{\n    return Internal();\n\n    IEnumerator Internal()\n    {\n        yield return CoroutineTask.Delay(TimeSpan.FromSeconds(5));\n        Debug.Log(\"Hello world!\");\n        ctl.Finish();\n        yield return null;\n        Debug.Log(\"This message will never be printed.\");\n    }\n});\n```\n\nReturn result from the `CoroutineTask`:\n```csharp\nvar task = CoroutineTask\u003cint\u003e.Run(ctl =\u003e\n{\n    return Internal();\n\n    IEnumerator Internal()\n    {\n        yield return null;\n        ctl.SetResult(42);\n    }\n});\n\nyield return task;\nDebug.Log(task.Result);\n```","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fs-rayleigh%2Fcoroutineex","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fs-rayleigh%2Fcoroutineex","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fs-rayleigh%2Fcoroutineex/lists"}