Skip to content

Commit

Permalink
Merge branch 'release/1.0.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
Arvtesh committed Feb 23, 2019
2 parents d0dd048 + 8f74f68 commit 65c4f20
Show file tree
Hide file tree
Showing 141 changed files with 5,159 additions and 5,432 deletions.
4 changes: 3 additions & 1 deletion .appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ artifacts:
name: UnityFx.Async-netstandard2.0
- path: .\bin\AssetStore
name: UnityFx.Async.AssetStore
- path: .\bin\AssetStoreLegacy
name: UnityFx.Async.AssetStoreLegacy
- path: .\bin\*.nupkg

dotnet_csproj:
Expand All @@ -49,7 +51,7 @@ deploy:

- provider: NuGet
api_key:
secure: iJt9p5F/FKKj2Y+neRJ1SG7W2P6aUhZBU8Z6j1x+7rLD3PGe5gH7VEZ/drxrNIzc
secure: T9wqAaW7mXUp2iCjx98JTk8I9P7YPz45VNY3Fs40YnbJ26f/3QPCFZvg47h6ntUj
artifact: /.*\.nupkg/
on:
branch: /master|(release\/.+)|(hotfix\/.+)/
4 changes: 1 addition & 3 deletions BuildSandbox.bat
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
powershell .\src\Build.ps1 Release
rd unity\Sandbox\Assets\Plugins /S /Q
xcopy bin\AssetStore\netstandard2.0 unity\Sandbox /S
rd unity\Sandbox35\Assets\Plugins /S /Q
xcopy bin\AssetStore\net35 unity\Sandbox35 /S
xcopy bin\AssetStoreLegacy\netstandard2.0 unity\Sandbox /S
30 changes: 30 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,36 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](http://keepachangelog.com/); this project adheres to [Semantic Versioning](http://semver.org/).

-----------------------
## [1.0.0] - 2019.02.23

### Added
- Added more comments throughout the code.
- Added Unity 2018.3 support (esp. support all target .NET frameworks in a single Asset Store package).
- Added `await` support to `YieldInstruction` Unity class.
- Added coroutine helpers (`AsyncUtility.FromCoroutine`).
- Added helpers for loading assets from an `AssetBundle`.
- Added `AsyncUtility.FrameTime` await helper.

### Changed
- Added `DebuggerHidden` attribute to some properties/methods to make stack traces a bit more friendly.
- Renamed `AsyncContinuationContext` to `AsyncCallbackOptions`.
- Renamed web request helper methods (added `Async` postfix to their names).
- Moved Unity extension methods to `UnityFx.Async.Extensions` namespace (previously they were in namespace `UnityFx.Async`).

### Fixed
- Fixed web requests `null` result in cases when downloaded file failed to open.
- Fixed `AsyncUtility.AddCompletionCallback` exception when adding new callbacks from another callback.
- Fixed `AsyncUpdateSource` implementation to allow adding listeners from a callback.
- Fixed `AsyncCompletionSource.SetProgress` implementation to allow setting progress when the operation is not started.

### Removed
- Removed many specialized `IAsyncOperationCallbacks` methods to make the interface as minimalistic as possible (new extension methods are added to compensate).
- Removed `(Try)SetExceptions` methods/extensions and `FromExceptions` helpers.
- Removed extension methods of the `Animation` class.
- Removed `WaitAsync` extension methods of the `Animator` class.
- Dropped `MovieTexture` support.

-----------------------
## [0.9.8] - 2018.11.09

Expand Down
2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# MIT License

Copyright (c) 2017-2018 Alexander Bogarsukov.
Copyright (c) 2017-2019 Alexander Bogarsukov.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

Expand Down
61 changes: 58 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Channel | UnityFx.Async |
AppVeyor | [![Build status](https://ci.appveyor.com/api/projects/status/hfmq9vow53al7tpd/branch/master?svg=true)](https://ci.appveyor.com/project/Arvtesh/unityfx-async/branch/master) [![AppVeyor tests](https://img.shields.io/appveyor/tests/Arvtesh/unityFx-async.svg)](https://ci.appveyor.com/project/Arvtesh/unityfx-async/build/tests)
NuGet | [![NuGet](https://img.shields.io/nuget/v/UnityFx.Async.svg)](https://www.nuget.org/packages/UnityFx.Async)
Github | [![GitHub release](https://img.shields.io/github/release/Arvtesh/UnityFx.Async.svg?logo=github)](https://github.com/Arvtesh/UnityFx.Async/releases)
Unity Asset Store | [![Asynchronous operations for Unity](https://img.shields.io/badge/tools-v0.9.8-green.svg)](https://assetstore.unity.com/packages/tools/asynchronous-operations-for-unity-96696)
Unity Asset Store | [![Asynchronous operations for Unity](https://img.shields.io/badge/tools-v1.0.0-green.svg)](https://assetstore.unity.com/packages/tools/asynchronous-operations-for-unity-96696)

**Requires Unity 5.4 or higher.**

Expand Down Expand Up @@ -43,6 +43,8 @@ The table below summarizes differences berween *UnityFx.Async* and other popular
| Minimum operation data size for 32-bit systems (in bytes) | 32+ | 36+ | 40+ |
| Minimum number of allocations per continuation | ~1 | 5+ | 2+ |

**NOTE**: As the table states [ExecutionContext](https://docs.microsoft.com/en-us/dotnet/api/system.threading.executioncontext) flow is NOT supported. Please use [Tasks](https://docs.microsoft.com/en-us/dotnet/api/system.threading.tasks.task) if you need it.

## Getting Started
### Prerequisites
You may need the following software installed in order to build/use the library:
Expand Down Expand Up @@ -170,8 +172,9 @@ In fact the only notable difference from synchronous implementation is usage of
## Using the library
Reference the DLL and import the namespace:
```csharp
using UnityFx.Async;
using UnityFx.Async.Promises; // For promises-specific stuff.
using UnityFx.Async; // Library core.
using UnityFx.Async.Extensions; // BCL/Unity extension methods.
using UnityFx.Async.Promises; // Promise extensions.
```
Create an operation instance like this:
```csharp
Expand Down Expand Up @@ -222,6 +225,8 @@ private IEnumerator DownloadTextInternal(IAsyncCompletionSource<string> op, stri
}
```

Please note that all `SetXxx` methods throw `InvalidOperationException` if the operation is completed. Use corresponding `TrySetXxx` methods is this behaviour is not desired.

### Waiting for an operation to complete
The simpliest way to get notified of an operation completion is registering a completion handler to be invoked when the operation succeeds (the JS promise-like way):
```csharp
Expand Down Expand Up @@ -501,6 +506,56 @@ AsyncUtility.PostToMainThread(() => Debug.Log("On the main thread."));
// If calling thread is the main thread executes the delegate synchronously, otherwise posts it to the main thread. Returns an asynchronous operation that can be used to track the delegate execution.
AsyncUtility.InvokeOnMainThread(() => Debug.Log("On the main thread."));
```
Converting a coroutine to promise is very easy:
```csharp
// The coroutine body. The completion source can be used to return promise results or report an error.
private IEnumerator SomeCoroutine(IAsyncCompletionSource completionSource)
{
// Wait for 1 seconds before resolving the promise.
yield return new WaitForSeconds(1);

// This line is optional. The promise is automativally resolved when the corresponding coroutine completes.
completionSource.SetCompleted();
}

// Start the coroutine. Note that you do not require a MonoBehaviour instance to do this.
var op = AsyncUtility.FromCoroutine(SomeCoroutine);

// Stop coroutine execution if needed.
op.Cancel();
```

One can also load an asset from an asset bundle with just one line of code:
```csharp
// Load Texture2D from assetbundle loaded from the specified URL. Asset bundle is unloaded when the operation is complete.
var op = AsyncWww.GetAssetBundleAssetAsync<Texture2D>("http://asset.cdn.com/myasetbundle", "my_asset");
// Additively load a the first scene from assetbundle loaded from a web URL. Asset bundle is unloaded when the operation is complete.
var op = AsyncWww.GetAssetBundleSceneAsync("http://asset.cdn.com/mysceneasetbundle", null, LoadSceneMode.Additive);
```

*UnityFx.Async* adds many useful extensions to Unity API, for example possibility to await any yieldable entity:
```csharp
async Task Test()
{
await new WaitForSeconds(2);
await new UnityWebRequest("myurl.com");
await Resources.LoadAsync("myasset");
}
```
.. or a specific frame time:
```csharp
async Task FrameTimingsTest()
{
// Wait until the next Update() cycle.
await AsyncUtility.FrameUpdate();
// Wait until the next LateUpdate().
await AsyncUtility.FrameUpdate(FrameTiming.LateUpdate);
// Wait until the next FixedUpdate().
await AsyncUtility.FrameUpdate(FrameTiming.FixedUpdate);
// Wait until the end of frame (same as yield new WaitForEndOfFrame()).
await AsyncUtility.FrameUpdate(FrameTiming.EndOfFrame);
}
```

## Comparison to .NET Tasks
The comparison table below shows how *UnityFx.Async* entities relate to [Tasks](https://docs.microsoft.com/en-us/dotnet/api/system.threading.tasks.task):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>Enum AsyncContinuationContext
<title>Enum AsyncCallbackOptions
| Asynchronous Operations for Unity </title>
<meta name="viewport" content="width=device-width">
<meta name="title" content="Enum AsyncContinuationContext
<meta name="title" content="Enum AsyncCallbackOptions
| Asynchronous Operations for Unity ">
<meta name="generator" content="docfx 2.31.0.0">

Expand Down Expand Up @@ -68,19 +68,20 @@
</div>
<div class="article row grid-right">
<div class="col-md-10">
<article class="content wrap" id="_content" data-uid="UnityFx.Async.AsyncContinuationContext">
<article class="content wrap" id="_content" data-uid="UnityFx.Async.AsyncCallbackOptions">


<h1 id="UnityFx_Async_AsyncContinuationContext" data-uid="UnityFx.Async.AsyncContinuationContext" class="text-break">Enum AsyncContinuationContext
<h1 id="UnityFx_Async_AsyncCallbackOptions" data-uid="UnityFx.Async.AsyncCallbackOptions" class="text-break">Enum AsyncCallbackOptions
</h1>
<div class="markdown level0 summary"><p>Specifies the synchronization context to schedule continuation on.</p>
<div class="markdown level0 summary"><p>Specifies callback options.</p>
</div>
<div class="markdown level0 conceptual"></div>
<h6><strong>Namespace</strong>: <a class="xref" href="UnityFx.Async.html">UnityFx.Async</a></h6>
<h6><strong>Assembly</strong>: UnityFx.Async.dll</h6>
<h5 id="UnityFx_Async_AsyncContinuationContext_syntax">Syntax</h5>
<h5 id="UnityFx_Async_AsyncCallbackOptions_syntax">Syntax</h5>
<div class="codewrapper">
<pre><code class="lang-csharp hljs">public enum AsyncContinuationContext</code></pre>
<pre><code class="lang-csharp hljs">[Flags]
public enum AsyncCallbackOptions</code></pre>
</div>
<h3 id="fields">Fields
</h3>
Expand All @@ -93,27 +94,26 @@ <h3 id="fields">Fields
<thead>
<tbody>
<tr>
<td id="UnityFx_Async_AsyncContinuationContext_Current">Current</td>
<td><p>Specifies that the continuation should be executed on the same thread that scheduled it.
That is the default behaviour of all library continuations.</p>
<td id="UnityFx_Async_AsyncCallbackOptions_ExecuteOnDefaultContext">ExecuteOnDefaultContext</td>
<td><p>Specifies that the callback should be executed on the default thread. Please see
<a class="xref" href="UnityFx.Async.AsyncResult.html#UnityFx_Async_AsyncResult_DefaultSynchronizationContext">DefaultSynchronizationContext</a> for more information.</p>
</td>
</tr>
<tr>
<td id="UnityFx_Async_AsyncContinuationContext_Default">Default</td>
<td><p>Specifies that the continuation should be executed on the default thread. See
<a class="xref" href="UnityFx.Async.AsyncResult.html#UnityFx_Async_AsyncResult_DefaultSynchronizationContext">DefaultSynchronizationContext</a> for more information.</p>
<td id="UnityFx_Async_AsyncCallbackOptions_ExecuteSynchronously">ExecuteSynchronously</td>
<td><p>Specifies that the callback should be executed synchronously. With this option specified, the callback runs on
the same thread that causes the antecedent operation to transition into its final state.</p>
</td>
</tr>
<tr>
<td id="UnityFx_Async_AsyncContinuationContext_None">None</td>
<td><p>Specifies that the continuation should be executed synchronously. With this option specified,
the continuation runs on the same thread that causes the antecedent operation to transition
into its final state.</p>
<td id="UnityFx_Async_AsyncCallbackOptions_None">None</td>
<td><p>When no options specified, default behavior should be used when executing callbacks.
I.e. a callback is executed on the same thread that scheduled it.</p>
</td>
</tr>
</tbody>
</thead></thead></table>
<h5 id="UnityFx_Async_AsyncContinuationContext_seealso">See Also</h5>
<h5 id="UnityFx_Async_AsyncCallbackOptions_seealso">See Also</h5>
<div class="seealso">
<div><a class="xref" href="UnityFx.Async.AsyncContinuationOptions.html">AsyncContinuationOptions</a></div>
</div>
Expand All @@ -125,10 +125,10 @@ <h5 id="UnityFx_Async_AsyncContinuationContext_seealso">See Also</h5>
<div class="contribution">
<ul class="nav">
<li>
<a href="https://github.com/Arvtesh/UnityFx.Async/new/master/apiSpec/new?filename=UnityFx_Async_AsyncContinuationContext.md&amp;value=---%0Auid%3A%20UnityFx.Async.AsyncContinuationContext%0Asummary%3A%20'*You%20can%20override%20summary%20for%20the%20API%20here%20using%20*MARKDOWN*%20syntax'%0A---%0A%0A*Please%20type%20below%20more%20information%20about%20this%20API%3A*%0A%0A" class="contribution-link">Improve this Doc</a>
<a href="https://github.com/Arvtesh/UnityFx.Async/new/master/apiSpec/new?filename=UnityFx_Async_AsyncCallbackOptions.md&amp;value=---%0Auid%3A%20UnityFx.Async.AsyncCallbackOptions%0Asummary%3A%20'*You%20can%20override%20summary%20for%20the%20API%20here%20using%20*MARKDOWN*%20syntax'%0A---%0A%0A*Please%20type%20below%20more%20information%20about%20this%20API%3A*%0A%0A" class="contribution-link">Improve this Doc</a>
</li>
<li>
<a href="https://github.com/Arvtesh/UnityFx.Async/blob/master/src/UnityFx.Async/Api/AsyncContinuationContext.cs/#L12" class="contribution-link">View Source</a>
<a href="https://github.com/Arvtesh/UnityFx.Async/blob/master/src/UnityFx.Async/Api/AsyncCallbackOptions.cs/#L12" class="contribution-link">View Source</a>
</li>
</ul>
</div>
Expand Down
Loading

0 comments on commit 65c4f20

Please sign in to comment.