You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.MD
+7-8Lines changed: 7 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -182,7 +182,7 @@ async Task WaitForMouse()
182
182
Built-in:
183
183
*`WaitForFrames`
184
184
*`WaitForSeconds`
185
-
*`WaitForUnscaledSeconds`
185
+
*`WaitForSecondsRealtime`
186
186
*`WaitUntil`<sup>1</sup>
187
187
*`WaitWhile`<sup>1</sup>
188
188
@@ -197,9 +197,9 @@ Others:
197
197
*`Task<>`
198
198
* …anything that implements `GetAwaiter()`
199
199
200
-
<sup>1</sup>May cause a delegate closure.
200
+
<sup>1</sup>Use the generic variants to pass a state object and avoid closures.
201
201
202
-
<sup>2</sup>Will spin up a Unity `Coroutine`, causing allocations.
202
+
<sup>2</sup>Will spin up a Unity `Coroutine`, causing allocations. Note, `CustomYieldInstruction` implements `IEnumerator`.
203
203
204
204
<sup>3</sup>Very small delegate allocation.
205
205
@@ -212,9 +212,9 @@ public interface IAwaitInstruction
212
212
boolIsCompleted();
213
213
}
214
214
```
215
-
It's dead simple, just place your behaviour in IsCompleted and return `true` when your criteria are met. `IsCompleted` will be evaluated every frame (depending on the `FrameScheduler`). Use a struct to avoid unnecessary allocations.
215
+
It's dead simple, just place your behaviour in `IsCompleted` and return `true` when your criteria are met. `IsCompleted` will be evaluated every frame (depending on the `FrameScheduler`). Use a struct to avoid unnecessary allocations.
216
216
217
-
One more thing to note; you will want to implement `GetAwaiter()` so that the instruction can encapsulate itself in a `Continuation` when awaited. It is the `Continuation` which actually ends up being awaited - as a kind of decoration to make custom await instructions more straight-forward to implement (the alternative is inheritance which causes heap allocations).
217
+
One more thing to note; `GetAwaiter()`is already provided through an extension method so that the instruction can encapsulate itself in an `AwaitInstructionAwaiter` when awaited. It is this struct which actually ends up being awaited - as a kind of decoration to make custom await instructions more straight-forward to implement (the alternative is inheritance which causes heap allocations).
218
218
219
219
```c#
220
220
usingUnityAsync;
@@ -227,9 +227,8 @@ public struct WaitForTimeSpan : IAwaitInstruction
227
227
228
228
publicWaitForFrames(TimeSpantimeSpan)
229
229
{
230
+
// we use AsyncManager.currentTime here (and above) because it's slightly more efficient vs Time.time
0 commit comments