mirror of https://github.com/Cysharp/UniTask
Update README.md
parent
08d5183e7e
commit
c99d3eb3c3
25
README.md
25
README.md
|
@ -154,22 +154,19 @@ UniTask provides three pattern of extension methods.
|
||||||
The type of `UniTask` can use utility like `UniTask.WhenAll`, `UniTask.WhenAny`. It is like Task.WhenAll/WhenAny but return type is more useful, returns value tuple so can deconsrtuct each result and pass multiple type.
|
The type of `UniTask` can use utility like `UniTask.WhenAll`, `UniTask.WhenAny`. It is like Task.WhenAll/WhenAny but return type is more useful, returns value tuple so can deconsrtuct each result and pass multiple type.
|
||||||
|
|
||||||
```csharp
|
```csharp
|
||||||
public class SceneAssets
|
public async UniTaskVoid LoadManyAsync()
|
||||||
{
|
{
|
||||||
public SceneAssets()
|
// parallel load.
|
||||||
{
|
var (a, b, c) = await UniTask.WhenAll(
|
||||||
// parallel load.
|
LoadAsSprite("foo"),
|
||||||
var (a, b, c) = await UniTask.WhenAll(
|
LoadAsSprite("bar"),
|
||||||
LoadAsSprite("foo"),
|
LoadAsSprite("baz"));
|
||||||
LoadAsSprite("bar"),
|
}
|
||||||
LoadAsSprite("baz"));
|
|
||||||
}
|
|
||||||
|
|
||||||
async UniTask<Sprite> LoadAsSprite(string path)
|
async UniTask<Sprite> LoadAsSprite(string path)
|
||||||
{
|
{
|
||||||
var resource = await Resources.LoadAsync<Sprite>(path);
|
var resource = await Resources.LoadAsync<Sprite>(path);
|
||||||
return (resource as Sprite);
|
return (resource as Sprite);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue