Skip to content

Commit 5056a3b

Browse files
committed
Merge branch 'release/1.0.0'
2 parents d0dd048 + 8f74f68 commit 5056a3b

121 files changed

Lines changed: 3176 additions & 1819 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.appveyor.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ artifacts:
2727
name: UnityFx.Async-netstandard2.0
2828
- path: .\bin\AssetStore
2929
name: UnityFx.Async.AssetStore
30+
- path: .\bin\AssetStoreLegacy
31+
name: UnityFx.Async.AssetStoreLegacy
3032
- path: .\bin\*.nupkg
3133

3234
dotnet_csproj:
@@ -49,7 +51,7 @@ deploy:
4951

5052
- provider: NuGet
5153
api_key:
52-
secure: iJt9p5F/FKKj2Y+neRJ1SG7W2P6aUhZBU8Z6j1x+7rLD3PGe5gH7VEZ/drxrNIzc
54+
secure: T9wqAaW7mXUp2iCjx98JTk8I9P7YPz45VNY3Fs40YnbJ26f/3QPCFZvg47h6ntUj
5355
artifact: /.*\.nupkg/
5456
on:
5557
branch: /master|(release\/.+)|(hotfix\/.+)/

BuildSandbox.bat

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
11
powershell .\src\Build.ps1 Release
22
rd unity\Sandbox\Assets\Plugins /S /Q
3-
xcopy bin\AssetStore\netstandard2.0 unity\Sandbox /S
4-
rd unity\Sandbox35\Assets\Plugins /S /Q
5-
xcopy bin\AssetStore\net35 unity\Sandbox35 /S
3+
xcopy bin\AssetStoreLegacy\netstandard2.0 unity\Sandbox /S

CHANGELOG.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,36 @@ All notable changes to this project will be documented in this file.
33

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

6+
-----------------------
7+
## [1.0.0] - 2019.02.23
8+
9+
### Added
10+
- Added more comments throughout the code.
11+
- Added Unity 2018.3 support (esp. support all target .NET frameworks in a single Asset Store package).
12+
- Added `await` support to `YieldInstruction` Unity class.
13+
- Added coroutine helpers (`AsyncUtility.FromCoroutine`).
14+
- Added helpers for loading assets from an `AssetBundle`.
15+
- Added `AsyncUtility.FrameTime` await helper.
16+
17+
### Changed
18+
- Added `DebuggerHidden` attribute to some properties/methods to make stack traces a bit more friendly.
19+
- Renamed `AsyncContinuationContext` to `AsyncCallbackOptions`.
20+
- Renamed web request helper methods (added `Async` postfix to their names).
21+
- Moved Unity extension methods to `UnityFx.Async.Extensions` namespace (previously they were in namespace `UnityFx.Async`).
22+
23+
### Fixed
24+
- Fixed web requests `null` result in cases when downloaded file failed to open.
25+
- Fixed `AsyncUtility.AddCompletionCallback` exception when adding new callbacks from another callback.
26+
- Fixed `AsyncUpdateSource` implementation to allow adding listeners from a callback.
27+
- Fixed `AsyncCompletionSource.SetProgress` implementation to allow setting progress when the operation is not started.
28+
29+
### Removed
30+
- Removed many specialized `IAsyncOperationCallbacks` methods to make the interface as minimalistic as possible (new extension methods are added to compensate).
31+
- Removed `(Try)SetExceptions` methods/extensions and `FromExceptions` helpers.
32+
- Removed extension methods of the `Animation` class.
33+
- Removed `WaitAsync` extension methods of the `Animator` class.
34+
- Dropped `MovieTexture` support.
35+
636
-----------------------
737
## [0.9.8] - 2018.11.09
838

LICENSE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# MIT License
22

3-
Copyright (c) 2017-2018 Alexander Bogarsukov.
3+
Copyright (c) 2017-2019 Alexander Bogarsukov.
44

55
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:
66

README.md

Lines changed: 58 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Channel | UnityFx.Async |
55
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)
66
NuGet | [![NuGet](https://img.shields.io/nuget/v/UnityFx.Async.svg)](https://www.nuget.org/packages/UnityFx.Async)
77
Github | [![GitHub release](https://img.shields.io/github/release/Arvtesh/UnityFx.Async.svg?logo=github)](https://github.com/Arvtesh/UnityFx.Async/releases)
8-
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)
8+
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)
99

1010
**Requires Unity 5.4 or higher.**
1111

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

46+
**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.
47+
4648
## Getting Started
4749
### Prerequisites
4850
You may need the following software installed in order to build/use the library:
@@ -170,8 +172,9 @@ In fact the only notable difference from synchronous implementation is usage of
170172
## Using the library
171173
Reference the DLL and import the namespace:
172174
```csharp
173-
using UnityFx.Async;
174-
using UnityFx.Async.Promises; // For promises-specific stuff.
175+
using UnityFx.Async; // Library core.
176+
using UnityFx.Async.Extensions; // BCL/Unity extension methods.
177+
using UnityFx.Async.Promises; // Promise extensions.
175178
```
176179
Create an operation instance like this:
177180
```csharp
@@ -222,6 +225,8 @@ private IEnumerator DownloadTextInternal(IAsyncCompletionSource<string> op, stri
222225
}
223226
```
224227

228+
Please note that all `SetXxx` methods throw `InvalidOperationException` if the operation is completed. Use corresponding `TrySetXxx` methods is this behaviour is not desired.
229+
225230
### Waiting for an operation to complete
226231
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):
227232
```csharp
@@ -501,6 +506,56 @@ AsyncUtility.PostToMainThread(() => Debug.Log("On the main thread."));
501506
// 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.
502507
AsyncUtility.InvokeOnMainThread(() => Debug.Log("On the main thread."));
503508
```
509+
Converting a coroutine to promise is very easy:
510+
```csharp
511+
// The coroutine body. The completion source can be used to return promise results or report an error.
512+
private IEnumerator SomeCoroutine(IAsyncCompletionSource completionSource)
513+
{
514+
// Wait for 1 seconds before resolving the promise.
515+
yield return new WaitForSeconds(1);
516+
517+
// This line is optional. The promise is automativally resolved when the corresponding coroutine completes.
518+
completionSource.SetCompleted();
519+
}
520+
521+
// Start the coroutine. Note that you do not require a MonoBehaviour instance to do this.
522+
var op = AsyncUtility.FromCoroutine(SomeCoroutine);
523+
524+
// Stop coroutine execution if needed.
525+
op.Cancel();
526+
```
527+
528+
One can also load an asset from an asset bundle with just one line of code:
529+
```csharp
530+
// Load Texture2D from assetbundle loaded from the specified URL. Asset bundle is unloaded when the operation is complete.
531+
var op = AsyncWww.GetAssetBundleAssetAsync<Texture2D>("http://asset.cdn.com/myasetbundle", "my_asset");
532+
// Additively load a the first scene from assetbundle loaded from a web URL. Asset bundle is unloaded when the operation is complete.
533+
var op = AsyncWww.GetAssetBundleSceneAsync("http://asset.cdn.com/mysceneasetbundle", null, LoadSceneMode.Additive);
534+
```
535+
536+
*UnityFx.Async* adds many useful extensions to Unity API, for example possibility to await any yieldable entity:
537+
```csharp
538+
async Task Test()
539+
{
540+
await new WaitForSeconds(2);
541+
await new UnityWebRequest("myurl.com");
542+
await Resources.LoadAsync("myasset");
543+
}
544+
```
545+
.. or a specific frame time:
546+
```csharp
547+
async Task FrameTimingsTest()
548+
{
549+
// Wait until the next Update() cycle.
550+
await AsyncUtility.FrameUpdate();
551+
// Wait until the next LateUpdate().
552+
await AsyncUtility.FrameUpdate(FrameTiming.LateUpdate);
553+
// Wait until the next FixedUpdate().
554+
await AsyncUtility.FrameUpdate(FrameTiming.FixedUpdate);
555+
// Wait until the end of frame (same as yield new WaitForEndOfFrame()).
556+
await AsyncUtility.FrameUpdate(FrameTiming.EndOfFrame);
557+
}
558+
```
504559

505560
## Comparison to .NET Tasks
506561
The comparison table below shows how *UnityFx.Async* entities relate to [Tasks](https://docs.microsoft.com/en-us/dotnet/api/system.threading.tasks.task):

src/Build.ps1

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ $configuration = $args[0]
44
$packagesPath = Join-Path $scriptPath "..\temp\BuildTools"
55
$binPath = Join-Path $scriptPath "..\bin"
66
$assetStorePath = Join-Path $binPath "AssetStore"
7+
$assetStorePath2 = Join-Path $binPath "AssetStoreLegacy"
78
$msbuildPath = "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\MsBuild.exe"
89
$nugetPath = Join-Path $packagesPath "nuget.exe"
910
$gitversionPath = Join-Path $packagesPath "gitversion.commandline\tools\gitversion.exe"
@@ -28,6 +29,16 @@ else
2829
New-Item $assetStorePath -ItemType Directory
2930
}
3031

32+
if (Test-Path $assetStorePath2)
33+
{
34+
Remove-Item $assetStorePath2 -Force -Recurse
35+
New-Item $assetStorePath2 -ItemType Directory
36+
}
37+
else
38+
{
39+
New-Item $assetStorePath2 -ItemType Directory
40+
}
41+
3142
# download nuget.exe if not present
3243
if (!(Test-Path $nugetPath))
3344
{
@@ -71,7 +82,7 @@ function _PublishAssetStorePackage
7182
$changelogPath = (Join-Path $scriptPath "..\CHANGELOG.md")
7283
$filesToPublish = (Join-Path $scriptPath "UnityFx.Async.AssetStore\Assets\*")
7384
$binToPublish =(Join-Path $binPath (Join-Path $targetFramework "\*"))
74-
$publishPath = (Join-Path $assetStorePath (Join-Path $targetFramework "Assets"))
85+
$publishPath = (Join-Path $assetStorePath2 (Join-Path $targetFramework "Assets"))
7586
$publishPath2 = (Join-Path $publishPath "Plugins\UnityFx.Async")
7687
$publishBinPath = (Join-Path $publishPath "Plugins\UnityFx.Async\Bin")
7788

@@ -84,3 +95,15 @@ function _PublishAssetStorePackage
8495
_PublishAssetStorePackage "net35"
8596
_PublishAssetStorePackage "net46"
8697
_PublishAssetStorePackage "netstandard2.0"
98+
99+
# for Unity 2018.3+ can include all targets
100+
$changelogPath = (Join-Path $scriptPath "..\CHANGELOG.md")
101+
$srcToPublish = (Join-Path $scriptPath "UnityFx.Async.AssetStore\Assets")
102+
$changelogPublishPath = (Join-Path $assetStorePath "Assets\Plugins\UnityFx.Async")
103+
$publishBinPath = (Join-Path $assetStorePath "Assets\Plugins\UnityFx.Async\Bin")
104+
$nugetFilePath = (Join-Path $publishBinPath "*.nupkg")
105+
New-Item $publishBinPath -ItemType Directory
106+
Copy-Item -Path $srcToPublish -Destination $assetStorePath -Force -Recurse
107+
Copy-Item -Path $changelogPath -Destination $changelogPublishPath -Force
108+
Copy-Item -Path $filesToPublish -Destination $publishBinPath -Force -Recurse
109+
Remove-Item $nugetFilePath -Force

0 commit comments

Comments
 (0)