https://github.com/comradevanti/totask.asyncoperation
A unity package for converting async-op objects to tasks
https://github.com/comradevanti/totask.asyncoperation
async task unity utility
Last synced: 8 months ago
JSON representation
A unity package for converting async-op objects to tasks
- Host: GitHub
- URL: https://github.com/comradevanti/totask.asyncoperation
- Owner: ComradeVanti
- Created: 2022-04-25T10:19:00.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2024-03-19T10:30:24.000Z (over 1 year ago)
- Last Synced: 2025-02-21T08:34:20.068Z (8 months ago)
- Topics: async, task, unity, utility
- Language: C#
- Homepage:
- Size: 6.84 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
README
# ToTask.AsyncOperation
[](https://openupm.com/packages/dev.comradevanti.totask.asyncoperation/)
Unity package for converting builtin `AsyncOperation` objects to .Net Tasks.
**⚠️ Development is paused ⚠️**
No new features will be added or bugs fixed unless requested through an issue.
If you wish to fork this repository and continue the work, you are very welcome
to do so.## Installation
Install via [OpenUPM](https://openupm.com) using
`openupm add dev.comradevanti.totask.asyncoperation`## Usage
Simply add `.ToTask()` to the operation object in order to await it. This
will create a value-less `Task`. If you want to add a result-value to the
task, you can call one of the overloads which allow you to specify one.```
// Example operation
var op = SceneManager.LoadSceneAsync("MyScene");// Simple value-less task
await op.ToTask();// Await the task with a specific result value
var v1 = await op.ToTask(5);// Await the task with the result being calculated by the given function
var v2 = await op.ToTask(() => "done");
```