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 5056a3b
Show file tree
Hide file tree
Showing 121 changed files with 3,176 additions and 1,819 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
25 changes: 24 additions & 1 deletion src/Build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ $configuration = $args[0]
$packagesPath = Join-Path $scriptPath "..\temp\BuildTools"
$binPath = Join-Path $scriptPath "..\bin"
$assetStorePath = Join-Path $binPath "AssetStore"
$assetStorePath2 = Join-Path $binPath "AssetStoreLegacy"
$msbuildPath = "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\MsBuild.exe"
$nugetPath = Join-Path $packagesPath "nuget.exe"
$gitversionPath = Join-Path $packagesPath "gitversion.commandline\tools\gitversion.exe"
Expand All @@ -28,6 +29,16 @@ else
New-Item $assetStorePath -ItemType Directory
}

if (Test-Path $assetStorePath2)
{
Remove-Item $assetStorePath2 -Force -Recurse
New-Item $assetStorePath2 -ItemType Directory
}
else
{
New-Item $assetStorePath2 -ItemType Directory
}

# download nuget.exe if not present
if (!(Test-Path $nugetPath))
{
Expand Down Expand Up @@ -71,7 +82,7 @@ function _PublishAssetStorePackage
$changelogPath = (Join-Path $scriptPath "..\CHANGELOG.md")
$filesToPublish = (Join-Path $scriptPath "UnityFx.Async.AssetStore\Assets\*")
$binToPublish =(Join-Path $binPath (Join-Path $targetFramework "\*"))
$publishPath = (Join-Path $assetStorePath (Join-Path $targetFramework "Assets"))
$publishPath = (Join-Path $assetStorePath2 (Join-Path $targetFramework "Assets"))
$publishPath2 = (Join-Path $publishPath "Plugins\UnityFx.Async")
$publishBinPath = (Join-Path $publishPath "Plugins\UnityFx.Async\Bin")

Expand All @@ -84,3 +95,15 @@ function _PublishAssetStorePackage
_PublishAssetStorePackage "net35"
_PublishAssetStorePackage "net46"
_PublishAssetStorePackage "netstandard2.0"

# for Unity 2018.3+ can include all targets
$changelogPath = (Join-Path $scriptPath "..\CHANGELOG.md")
$srcToPublish = (Join-Path $scriptPath "UnityFx.Async.AssetStore\Assets")
$changelogPublishPath = (Join-Path $assetStorePath "Assets\Plugins\UnityFx.Async")
$publishBinPath = (Join-Path $assetStorePath "Assets\Plugins\UnityFx.Async\Bin")
$nugetFilePath = (Join-Path $publishBinPath "*.nupkg")
New-Item $publishBinPath -ItemType Directory
Copy-Item -Path $srcToPublish -Destination $assetStorePath -Force -Recurse
Copy-Item -Path $changelogPath -Destination $changelogPublishPath -Force
Copy-Item -Path $filesToPublish -Destination $publishBinPath -Force -Recurse
Remove-Item $nugetFilePath -Force
Loading

0 comments on commit 5056a3b

Please sign in to comment.