{"id":27013405,"url":"https://github.com/villevli/unitysimplecoroutines","last_synced_at":"2025-07-14T08:32:36.827Z","repository":{"id":280348964,"uuid":"295211877","full_name":"villevli/UnitySimpleCoroutines","owner":"villevli","description":"An alternative to Unity's Coroutines with no delay when yielding","archived":false,"fork":false,"pushed_at":"2025-03-26T20:17:43.000Z","size":5,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-04T12:34:26.367Z","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":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/villevli.png","metadata":{"files":{"readme":"README.md","changelog":null,"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":"2020-09-13T18:25:03.000Z","updated_at":"2025-03-26T20:17:47.000Z","dependencies_parsed_at":"2025-04-04T12:40:14.848Z","dependency_job_id":null,"html_url":"https://github.com/villevli/UnitySimpleCoroutines","commit_stats":null,"previous_names":["villevli/unitysimplecoroutines"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/villevli/UnitySimpleCoroutines","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/villevli%2FUnitySimpleCoroutines","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/villevli%2FUnitySimpleCoroutines/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/villevli%2FUnitySimpleCoroutines/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/villevli%2FUnitySimpleCoroutines/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/villevli","download_url":"https://codeload.github.com/villevli/UnitySimpleCoroutines/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/villevli%2FUnitySimpleCoroutines/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265262600,"owners_count":23736427,"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":[],"created_at":"2025-04-04T12:29:27.376Z","updated_at":"2025-07-14T08:32:36.797Z","avatar_url":"https://github.com/villevli.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Unity Simple Coroutines\nAn alternative to Unity's Coroutines with no delay when yielding\n\nThis has most of the features that Unity's coroutines have but unlike normal coroutines it does not have any frame delays when you yield return a nested IEnumerator.\n\nUnfortunately this does not yet support Unity's yield instructions that do not inherit from IEnumerator like WaitForSeconds, WaitForEndOfFrame and AsyncOperation.\n\n## Installation\nThere are two ways to install this plugin\n1. Copy the contents of this repository or only the *Scripts* folder to your *Assets* folder. Preferably place it in a folder called *SimpleCoroutines*\n2. *(via Package Manager)* add the following line to *Packages/manifest.json*:\n    - `\"com.villevli.simplecoroutines\": \"https://github.com/villevli/UnitySimpleCoroutines.git\",`\n\n## How To\nCreate a `SCoroutineRunner` instance and call the following functions on it:\n- `StartCoroutine(IEnumerator ie)`: Start executing the given `IEnumerator` like a normal coroutine. This will execute the coroutine and nested IEnumerators until it ends or yield returns `null`\n- `Update()`: Continue executing each started coroutine and nested IEnumerators until it ends or yield returns `null`. Usually you want to call this once per frame\n\nYield return any of the following in the `IEnumerator`:\n- `yield return null`: Code after the yield will resume in the next frame\n- `yield break`: Stop execution of current method. This will never cause the calling method to wait an extra frame unlike when this is used in normal coroutines\n- Any `IEnumerator`: Can be used to execute a nested function. Wait until `MoveNext()` returns false\n- Any `CustomYieldInstruction`: Works just like in normal coroutines. For example `new WaitForSecondsRealtime(float time)` or `new WaitUntil(Func\u003cbool\u003e predicate)`\n- `new SWaitForSeconds(float time)`: Wait for seconds using scaled time. You must use this instead of Unity's `new WaitForSeconds(float seconds)`. See [Current Limitations](#current-limitations)\n- Yield returning anything else will just make the method wait a frame like `yield return null`\n\n## Example Code\n```cs\nusing System.Collections;\nusing UnityEngine;\nusing SimpleCoroutines;\n\npublic class MyMonoBehaviour : MonoBehaviour\n{\n    private SCoroutineRunner _runner = new SCoroutineRunner();\n\n    private void Start()\n    {\n        _runner.StartCoroutine(MyRoutine());\n    }\n\n    private void Update()\n    {\n        _runner.Update();\n    }\n\n    private IEnumerator MyRoutine()\n    {\n        yield return MyNestedRoutine();\n        // Here we are still in the same frame unlike when using normal coroutines\n\n        yield return null;\n        // Now it's the next frame\n\n        yield return new SWaitForSeconds(2.5f);\n        // Now 2.5 seconds have elapsed in game time\n    }\n\n    private IEnumerator MyNestedRoutine()\n    {\n        // Return without waiting to next frame\n        yield break;\n    }\n}\n```\n\n## Current Limitations\n- SCoroutine does not support Unity's `YieldInstruction`s that do not inherit from `IEnumerator`, like `WaitForSeconds`, `WaitForEndOfFrame` and `AsyncOperation`. This means that yield returning for example `UnityWebRequest.SendWebRequest()` or `SceneManager.LoadSceneAsync()` will not actually wait for it to complete\n- There is no `StopCoroutine()` function\n- You have to declare `SCoroutineRunner` and call `Update()` on it which might add clutter to your code\n\n## TODO\n- Support Unity's `YieldInstruction`s in SCoroutines\n- Add `StopCoroutine()` function\n- Add an extension method to `MonoBehaviour` so you can use SCoroutines without `SCoroutineRunner` like normal coroutines just by calling `this.StartSCoroutine(IEnumerator ie)` in your MonoBehaviour script\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvillevli%2Funitysimplecoroutines","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvillevli%2Funitysimplecoroutines","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvillevli%2Funitysimplecoroutines/lists"}