Compare commits

..

29 Commits
2.3.1 ... 2.3.2

Author SHA1 Message Date
github-actions[bot]
d2245bc38b feat: Update package.json to 2.3.2 2022-10-24 12:59:01 +00:00
neuecc
f092f6a112 Fix AwaitForAllAssets stackoverflow #394 2022-10-24 21:57:42 +09:00
neuecc
ed617a04a6 if UNITY_2022_2_OR_NEWER, use destroyCancellationToken 2022-10-24 21:56:03 +09:00
neuecc
340736795c UnityEvent.AsAsyncEnumerable handle cancel correctly #365 2022-10-24 21:51:23 +09:00
neuecc
dc804ffb13 breaking changes, UniTask.WaitForFixedUpdate wait at LastFixedUpdate #377 2022-10-24 21:18:36 +09:00
neuecc
a879989d1c Unity 2023.1.0a15, remove AsyncOperation.GetAwaiter to avoid conflict 2022-10-24 21:11:49 +09:00
Yoshifumi Kawai
ee54559532 Merge pull request #413 from battleroy/battleroy/observable-extension-cancellation-token-forwarding
Fix cancellation token forwarding
2022-10-12 10:53:30 +09:00
Evgeny Chasovitin
4a72ec2a1a Fix cancellation token forwarding at FirstValueToUniTaskObserver and ToUniTaskObserver; 2022-10-11 23:01:19 +04:00
Yoshifumi Kawai
e999268305 Merge pull request #395 from kroonhorstdino/diagnostics_helper_null_check
Diagnostics helper null check
2022-09-30 18:49:10 +09:00
Yoshifumi Kawai
8300c1b1e6 Merge pull request #399 from shiena/fix/prevent-nre
fix: prevent NullReferenceException in TimeoutController
2022-09-30 18:04:57 +09:00
KOGA Mitsuhiro
daa0c7b9a0 fix: prevent NullReferenceException in TimeoutController 2022-09-14 02:56:06 +09:00
KOGA Mitsuhiro
9b9a4ec76a fix: prevent NullReferenceException in TimeoutController 2022-09-08 15:12:05 +09:00
Christoph Hüter
3f8e43b83f Remove empty line with spaces 2022-08-31 03:00:22 +02:00
Christoph Hüter
cf6f0799e9 Remove spaces in empty line 2022-08-25 13:51:44 +02:00
Christoph Hüter
91ba4f003a Add null checks to diagnostics helper functions 2022-08-25 13:48:52 +02:00
Yoshifumi Kawai
f48cb4b03e Merge pull request #392 from Ryuu-64/master
Typo in TaskPool.cs annotation internaly -> internally
2022-08-23 10:38:44 +09:00
DESKTOP-FQ830JM\Ryuu
70a243d978 typo in TaskPool.cs internaly -> internally 2022-08-22 12:20:52 +08:00
Yoshifumi Kawai
9b95f3b9f6 Merge pull request #385 from fpagyu/support-addressablesCN
re-define UNITASK_ADDRESSABLE_SUPPORT for supporting Addressables.CN
2022-08-02 10:46:39 +09:00
yuzj
a25adb601b re-define UNITASK_ADDRESSABLE_SUPPORT for supporting Addressables.CN 2022-08-01 18:21:04 +08:00
Ikiru Yoshizaki
e6240879c4 chore: checkout@v3 2022-07-26 15:34:50 +09:00
Ikiru Yoshizaki
a94e8cceac Merge pull request #381 from Cysharp/feature/actions
feat: use Cysharp/Actions reusable workflows/actions
2022-07-26 13:59:46 +09:00
Ikiru Yoshizaki
0595a4182a feat: use Cysharp/Actions for release 2022-07-26 13:10:40 +09:00
Ikiru Yoshizaki
df96c119c1 chore: set timeout 2022-07-26 13:10:32 +09:00
Ikiru Yoshizaki
534f4a2588 chore: use Cysharp/Actions reusable workflow stale 2022-07-26 13:10:22 +09:00
Ikiru Yoshizaki
873485ad1a chore: IsPackable marking 2022-07-26 13:10:10 +09:00
Yoshifumi Kawai
78db78c7bd Merge pull request #369 from nolimet/bugfix/issue#368
Fix for issue #368 UnityWebRequestException extra line in exception message
2022-06-23 17:46:29 +09:00
Jesse Stam
226e272787 Added simple check to see if there is text.
Add this so we don't add a new line we don't need.
2022-06-23 09:31:05 +02:00
neuecc
9e2163616b Merge remote-tracking branch 'origin/master' 2022-03-03 08:14:22 +09:00
neuecc
52df6fbf3f t 2022-03-03 08:14:18 +09:00
19 changed files with 164 additions and 164 deletions

View File

@@ -4,8 +4,6 @@ on:
push: push:
branches: branches:
- "master" - "master"
tags:
- "!*" # not a tag push
pull_request: pull_request:
branches: branches:
- "master" - "master"
@@ -13,13 +11,16 @@ on:
jobs: jobs:
build-dotnet: build-dotnet:
runs-on: ubuntu-latest runs-on: ubuntu-latest
env: timeout-minutes: 10
DOTNET_CLI_TELEMETRY_OPTOUT: 1
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1
NUGET_XMLDOC_MODE: skip
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v3
- run: dotnet test -c Debug ./src/UniTask.NetCoreTests/UniTask.NetCoreTests.csproj - uses: Cysharp/Actions/.github/actions/setup-dotnet@main
with:
dotnet-version: |
3.1.x
6.0.x
- run: dotnet build -c Debug
- run: dotnet test -c Debug
build-unity: build-unity:
if: "((github.event_name == 'push' && github.repository_owner == 'Cysharp') || startsWith(github.event.pull_request.head.label, 'Cysharp:'))" if: "((github.event_name == 'push' && github.repository_owner == 'Cysharp') || startsWith(github.event.pull_request.head.label, 'Cysharp:'))"
@@ -34,12 +35,13 @@ jobs:
- unity: 2020.1.12f1 - unity: 2020.1.12f1
license: UNITY_LICENSE_2020 license: UNITY_LICENSE_2020
runs-on: ubuntu-latest runs-on: ubuntu-latest
timeout-minutes: 15
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v3
# Execute scripts: RuntimeUnitTestToolkit # Execute scripts: RuntimeUnitTestToolkit
# /opt/Unity/Editor/Unity -quit -batchmode -nographics -silent-crashes -logFile -projectPath . -executeMethod UnitTestBuilder.BuildUnitTest /headless /ScriptBackend mono /BuildTarget StandaloneLinux64 # /opt/Unity/Editor/Unity -quit -batchmode -nographics -silent-crashes -logFile -projectPath . -executeMethod UnitTestBuilder.BuildUnitTest /headless /ScriptBackend mono /BuildTarget StandaloneLinux64
- name: Build UnitTest(Linux64, mono) - name: Build UnitTest(Linux64, mono)
uses: game-ci/unity-builder@v2.0-alpha-6 uses: game-ci/unity-builder@v2
env: env:
UNITY_LICENSE: ${{ secrets[matrix.license] }} UNITY_LICENSE: ${{ secrets[matrix.license] }}
with: with:
@@ -55,7 +57,7 @@ jobs:
# Execute scripts: Export Package # Execute scripts: Export Package
# /opt/Unity/Editor/Unity -quit -batchmode -nographics -silent-crashes -logFile -projectPath . -executeMethod PackageExporter.Export # /opt/Unity/Editor/Unity -quit -batchmode -nographics -silent-crashes -logFile -projectPath . -executeMethod PackageExporter.Export
- name: Export unitypackage - name: Export unitypackage
uses: game-ci/unity-builder@v2.0-alpha-6 uses: game-ci/unity-builder@v2
env: env:
UNITY_LICENSE: ${{ secrets[matrix.license] }} UNITY_LICENSE: ${{ secrets[matrix.license] }}
with: with:
@@ -65,15 +67,9 @@ jobs:
buildMethod: PackageExporter.Export buildMethod: PackageExporter.Export
versioning: None versioning: None
- name: check all .meta is commited - uses: Cysharp/Actions/.github/actions/check-metas@main # check meta files
run: | with:
if git ls-files --others --exclude-standard -t | grep --regexp='[.]meta$'; then directory: src/UniTask
echo "Detected .meta file generated. Do you forgot commit a .meta file?"
exit 1
else
echo "Great, all .meta files are commited."
fi
working-directory: src/UniTask
# Store artifacts. # Store artifacts.
- uses: actions/upload-artifact@v2 - uses: actions/upload-artifact@v2

View File

@@ -9,9 +9,10 @@ on:
jobs: jobs:
run-docfx: run-docfx:
runs-on: ubuntu-latest runs-on: ubuntu-latest
timeout-minutes: 10
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v3
- uses: actions/checkout@v2 - uses: actions/checkout@v3
with: with:
repository: Cysharp/DocfxTemplate repository: Cysharp/DocfxTemplate
path: docs/_DocfxTemplate path: docs/_DocfxTemplate

View File

@@ -6,90 +6,44 @@ on:
tag: tag:
description: "tag: git tag you want create. (sample 1.0.0)" description: "tag: git tag you want create. (sample 1.0.0)"
required: true required: true
dry_run: dry-run:
description: "dry_run: true will never create relase/nuget." description: "dry-run: true will never create relase/nuget."
required: true required: true
default: "false" default: false
type: boolean
env: env:
GIT_TAG: ${{ github.event.inputs.tag }} GIT_TAG: ${{ github.event.inputs.tag }}
DRY_RUN: ${{ github.event.inputs.dry_run }} DRY_RUN: ${{ github.event.inputs.dry-run }}
DRY_RUN_BRANCH_PREFIX: "test_release"
jobs: jobs:
update-packagejson: update-packagejson:
runs-on: ubuntu-latest uses: Cysharp/Actions/.github/workflows/update-packagejson.yaml@main
env: with:
TARGET_FILE: ./src/UniTask/Assets/Plugins/UniTask/package.json file-path: ./src/UniTask/Assets/Plugins/UniTask/package.json
outputs: tag: ${{ github.event.inputs.tag }}
sha: ${{ steps.commit.outputs.sha }} dry-run: ${{ fromJson(github.event.inputs.dry-run) }}
steps:
- uses: actions/checkout@v2
- name: Output package.json (Before)
run: cat ${{ env.TARGET_FILE}}
- name: Update package.json to version ${{ env.GIT_TAG }}
run: sed -i -e "s/\(\"version\":\) \"\(.*\)\",/\1 \"${{ env.GIT_TAG }}\",/" ${{ env.TARGET_FILE }}
- name: Check update
id: check_update
run: |
cat ${{ env.TARGET_FILE}}
git diff --exit-code || echo "::set-output name=changed::1"
- name: Commit files
id: commit
if: steps.check_update.outputs.changed == '1'
run: |
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git commit -m "feat: Update package.json to ${{ env.GIT_TAG }}" -a
echo "::set-output name=sha::$(git rev-parse HEAD)"
- name: Check sha
run: echo "SHA ${SHA}"
env:
SHA: ${{ steps.commit.outputs.sha }}
- name: Create Tag
if: steps.check_update.outputs.changed == '1'
run: git tag ${{ env.GIT_TAG }}
- name: Push changes
if: env.DRY_RUN == 'false' && steps.check_update.outputs.changed == '1'
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: ${{ github.ref }}
tags: true
- name: Push changes (dry_run)
if: env.DRY_RUN == 'true' && steps.check_update.outputs.changed == '1'
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: ${{ env.DRY_RUN_BRANCH_PREFIX }}-${{ env.GIT_TAG }}
tags: false
build-dotnet: build-dotnet:
needs: [update-packagejson] needs: [update-packagejson]
runs-on: ubuntu-latest runs-on: ubuntu-latest
timeout-minutes: 10 timeout-minutes: 10
env:
DOTNET_CLI_TELEMETRY_OPTOUT: 1
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1
NUGET_XMLDOC_MODE: skip
steps: steps:
- run: echo ${{ needs.update-packagejson.outputs.sha }} - run: echo ${{ needs.update-packagejson.outputs.sha }}
- uses: actions/checkout@v2 - uses: actions/checkout@v3
with: with:
ref: ${{ needs.update-packagejson.outputs.sha }} ref: ${{ needs.update-packagejson.outputs.sha }}
- uses: Cysharp/Actions/.github/actions/setup-dotnet@main
with:
dotnet-version: |
3.1.x
6.0.x
# build and pack # build and pack
- run: dotnet build -c Release -p:Version=${{ env.GIT_TAG }} - run: dotnet build -c Release -p:Version=${{ env.GIT_TAG }}
- run: dotnet test -c Release --no-build - run: dotnet test -c Release --no-build
- run: dotnet pack ./src/UniTask.NetCore/UniTask.NetCore.csproj -c Release --no-build -p:Version=${{ env.GIT_TAG }} -o ./publish - run: dotnet pack ./src/UniTask.NetCore/UniTask.NetCore.csproj -c Release --no-build -p:Version=${{ env.GIT_TAG }} -o ./publish
# Store artifacts. # Store artifacts.
- uses: actions/upload-artifact@v1 - uses: actions/upload-artifact@v2
with: with:
name: nuget name: nuget
path: ./publish/ path: ./publish/
@@ -106,13 +60,13 @@ jobs:
timeout-minutes: 15 timeout-minutes: 15
steps: steps:
- run: echo ${{ needs.update-packagejson.outputs.sha }} - run: echo ${{ needs.update-packagejson.outputs.sha }}
- uses: actions/checkout@v2 - uses: actions/checkout@v3
with: with:
ref: ${{ needs.update-packagejson.outputs.sha }} ref: ${{ needs.update-packagejson.outputs.sha }}
# Execute scripts: Export Package # Execute scripts: Export Package
# /opt/Unity/Editor/Unity -quit -batchmode -nographics -silent-crashes -logFile -projectPath . -executeMethod PackageExporter.Export # /opt/Unity/Editor/Unity -quit -batchmode -nographics -silent-crashes -logFile -projectPath . -executeMethod PackageExporter.Export
- name: Export unitypackage - name: Export unitypackage
uses: game-ci/unity-builder@v2.0-alpha-6 uses: game-ci/unity-builder@v2
env: env:
UNITY_LICENSE: ${{ secrets[matrix.license] }} UNITY_LICENSE: ${{ secrets[matrix.license] }}
with: with:
@@ -122,15 +76,9 @@ jobs:
buildMethod: PackageExporter.Export buildMethod: PackageExporter.Export
versioning: None versioning: None
- name: check all .meta is commited - uses: Cysharp/Actions/.github/actions/check-metas@main # check meta files
run: | with:
if git ls-files --others --exclude-standard -t | grep --regexp='[.]meta$'; then directory: src/UniTask
echo "Detected .meta file generated. Do you forgot commit a .meta file?"
exit 1
else
echo "Great, all .meta files are commited."
fi
working-directory: src/UniTask
# Store artifacts. # Store artifacts.
- uses: actions/upload-artifact@v2 - uses: actions/upload-artifact@v2
@@ -139,14 +87,12 @@ jobs:
path: ./src/UniTask/UniTask.${{ env.GIT_TAG }}.unitypackage path: ./src/UniTask/UniTask.${{ env.GIT_TAG }}.unitypackage
create-release: create-release:
if: github.event.inputs.dry_run == 'false' if: github.event.inputs.dry-run == 'false'
needs: [update-packagejson, build-dotnet, build-unity] needs: [update-packagejson, build-dotnet, build-unity]
runs-on: ubuntu-latest runs-on: ubuntu-latest
env: timeout-minutes: 10
DOTNET_CLI_TELEMETRY_OPTOUT: 1
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1
NUGET_XMLDOC_MODE: skip
steps: steps:
- uses: Cysharp/Actions/.github/actions/setup-dotnet@main
# Create Releases # Create Releases
- uses: actions/create-release@v1 - uses: actions/create-release@v1
id: create_release id: create_release
@@ -173,12 +119,8 @@ jobs:
asset_content_type: application/octet-stream asset_content_type: application/octet-stream
cleanup: cleanup:
if: github.event.inputs.dry_run == 'true' if: needs.update-packagejson.outputs.is-branch-created == 'true'
needs: [build-dotnet, build-unity] needs: [update-packagejson, build-dotnet, build-unity]
runs-on: ubuntu-latest uses: Cysharp/Actions/.github/workflows/clean-packagejson-branch.yaml@main
steps: with:
- name: Delete branch branch: ${{ needs.update-packagejson.outputs.branch-name }}
uses: dawidd6/action-delete-branch@v3
with:
github_token: ${{ github.token }}
branches: ${{ env.DRY_RUN_BRANCH_PREFIX }}-${{ env.GIT_TAG }}

View File

@@ -1,24 +1,10 @@
name: "Close stale issues" name: "Close stale issues"
on: on:
workflow_dispatch:
schedule: schedule:
- cron: "0 0 * * *" - cron: "0 0 * * *"
jobs: jobs:
stale: stale:
runs-on: ubuntu-latest uses: Cysharp/Actions/.github/workflows/stale-issue.yaml@main
steps:
- uses: actions/stale@v3
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
# enable issue
stale-issue-message: "This issue is stale because it has been open 90 days with no activity. Remove stale label or comment or this will be closed in 7 days."
stale-issue-label: "stale"
# enable pr
stale-pr-message: "This PR is stale because it has been open 90 days with no activity. Remove stale label or comment or this will be closed in 7 days."
stale-pr-label: "stale"
days-before-stale: 90
days-before-close: 7
exempt-issue-labels: "wip"
exempt-pr-labels: "wip"
remove-stale-when-updated: true

View File

@@ -23,6 +23,7 @@
<PackageIcon>Icon.png</PackageIcon> <PackageIcon>Icon.png</PackageIcon>
<SignAssembly>true</SignAssembly> <SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>opensource.snk</AssemblyOriginatorKeyFile> <AssemblyOriginatorKeyFile>opensource.snk</AssemblyOriginatorKeyFile>
<IsPackable>true</IsPackable>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>

View File

@@ -4,6 +4,7 @@
<OutputType>Exe</OutputType> <OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework> <TargetFramework>netcoreapp3.1</TargetFramework>
<RootNamespace>NetCoreSandbox</RootNamespace> <RootNamespace>NetCoreSandbox</RootNamespace>
<IsPackable>false</IsPackable>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>

View File

@@ -16,7 +16,12 @@
"name": "com.unity.addressables", "name": "com.unity.addressables",
"expression": "", "expression": "",
"define": "UNITASK_ADDRESSABLE_SUPPORT" "define": "UNITASK_ADDRESSABLE_SUPPORT"
},
{
"name": "com.unity.addressables.cn",
"expression": "",
"define": "UNITASK_ADDRESSABLE_SUPPORT"
} }
], ],
"noEngineReferences": false "noEngineReferences": false
} }

View File

@@ -524,6 +524,14 @@ namespace Cysharp.Threading.Tasks
{ {
sb.AppendFormat("------{0}------", header.type.Name); sb.AppendFormat("------{0}------", header.type.Name);
sb.AppendLine(); sb.AppendLine();
if (header.subSystemList is null)
{
sb.AppendFormat("{0} has no subsystems!", header.ToString());
sb.AppendLine();
continue;
}
foreach (var subSystem in header.subSystemList) foreach (var subSystem in header.subSystemList)
{ {
sb.AppendFormat("{0}", subSystem.type.Name); sb.AppendFormat("{0}", subSystem.type.Name);
@@ -545,6 +553,11 @@ namespace Cysharp.Threading.Tasks
foreach (var header in playerLoop.subSystemList) foreach (var header in playerLoop.subSystemList)
{ {
if (header.subSystemList is null)
{
continue;
}
foreach (var subSystem in header.subSystemList) foreach (var subSystem in header.subSystemList)
{ {
if (subSystem.type == typeof(UniTaskLoopRunners.UniTaskLoopRunnerInitialization)) if (subSystem.type == typeof(UniTaskLoopRunners.UniTaskLoopRunnerInitialization))

View File

@@ -7,7 +7,7 @@ using System.Threading;
namespace Cysharp.Threading.Tasks namespace Cysharp.Threading.Tasks
{ {
// internaly used but public, allow to user create custom operator with pooling. // internally used but public, allow to user create custom operator with pooling.
public static class TaskPool public static class TaskPool
{ {

View File

@@ -99,7 +99,7 @@ namespace Cysharp.Threading.Tasks
public void Reset() public void Reset()
{ {
timer.Stop(); timer?.Stop();
} }
public void Dispose() public void Dispose()
@@ -109,7 +109,7 @@ namespace Cysharp.Threading.Tasks
try try
{ {
// stop timer. // stop timer.
timer.Dispose(); timer?.Dispose();
// cancel and dispose. // cancel and dispose.
timeoutSource.Cancel(); timeoutSource.Cancel();

View File

@@ -8,6 +8,16 @@ namespace Cysharp.Threading.Tasks
{ {
public static class UniTaskCancellationExtensions public static class UniTaskCancellationExtensions
{ {
#if UNITY_2022_2_OR_NEWER
/// <summary>This CancellationToken is canceled when the MonoBehaviour will be destroyed.</summary>
public static CancellationToken GetCancellationTokenOnDestroy(this MonoBehaviour monoBehaviour)
{
return monoBehaviour.destroyCancellationToken;
}
#endif
/// <summary>This CancellationToken is canceled when the MonoBehaviour will be destroyed.</summary> /// <summary>This CancellationToken is canceled when the MonoBehaviour will be destroyed.</summary>
public static CancellationToken GetCancellationTokenOnDestroy(this GameObject gameObject) public static CancellationToken GetCancellationTokenOnDestroy(this GameObject gameObject)
{ {
@@ -17,6 +27,13 @@ namespace Cysharp.Threading.Tasks
/// <summary>This CancellationToken is canceled when the MonoBehaviour will be destroyed.</summary> /// <summary>This CancellationToken is canceled when the MonoBehaviour will be destroyed.</summary>
public static CancellationToken GetCancellationTokenOnDestroy(this Component component) public static CancellationToken GetCancellationTokenOnDestroy(this Component component)
{ {
#if UNITY_2022_2_OR_NEWER
if (component is MonoBehaviour mb)
{
return mb.destroyCancellationToken;
}
#endif
return component.GetAsyncDestroyTrigger().CancellationToken; return component.GetAsyncDestroyTrigger().CancellationToken;
} }
} }

View File

@@ -94,19 +94,21 @@ namespace Cysharp.Threading.Tasks
} }
/// <summary> /// <summary>
/// Same as UniTask.Yield(PlayerLoopTiming.FixedUpdate). /// Same as UniTask.Yield(PlayerLoopTiming.LastFixedUpdate).
/// </summary> /// </summary>
public static YieldAwaitable WaitForFixedUpdate() public static YieldAwaitable WaitForFixedUpdate()
{ {
return UniTask.Yield(PlayerLoopTiming.FixedUpdate); // use LastFixedUpdate instead of FixedUpdate
// https://github.com/Cysharp/UniTask/issues/377
return UniTask.Yield(PlayerLoopTiming.LastFixedUpdate);
} }
/// <summary> /// <summary>
/// Same as UniTask.Yield(PlayerLoopTiming.FixedUpdate, cancellationToken). /// Same as UniTask.Yield(PlayerLoopTiming.LastFixedUpdate, cancellationToken).
/// </summary> /// </summary>
public static UniTask WaitForFixedUpdate(CancellationToken cancellationToken) public static UniTask WaitForFixedUpdate(CancellationToken cancellationToken)
{ {
return UniTask.Yield(PlayerLoopTiming.FixedUpdate, cancellationToken); return UniTask.Yield(PlayerLoopTiming.LastFixedUpdate, cancellationToken);
} }
public static UniTask DelayFrame(int delayFrameCount, PlayerLoopTiming delayTiming = PlayerLoopTiming.Update, CancellationToken cancellationToken = default(CancellationToken)) public static UniTask DelayFrame(int delayFrameCount, PlayerLoopTiming delayTiming = PlayerLoopTiming.Update, CancellationToken cancellationToken = default(CancellationToken))

View File

@@ -133,7 +133,7 @@ namespace Cysharp.Threading.Tasks
{ {
var self = (ToUniTaskObserver<T>)state; var self = (ToUniTaskObserver<T>)state;
self.disposable.Dispose(); self.disposable.Dispose();
self.promise.TrySetCanceled(); self.promise.TrySetCanceled(self.cancellationToken);
} }
public void OnNext(T value) public void OnNext(T value)
@@ -203,7 +203,7 @@ namespace Cysharp.Threading.Tasks
{ {
var self = (FirstValueToUniTaskObserver<T>)state; var self = (FirstValueToUniTaskObserver<T>)state;
self.disposable.Dispose(); self.disposable.Dispose();
self.promise.TrySetCanceled(); self.promise.TrySetCanceled(self.cancellationToken);
} }
public void OnNext(T value) public void OnNext(T value)

View File

@@ -21,7 +21,7 @@ namespace Cysharp.Threading.Tasks
public static UniTask<UnityEngine.Object[]> AwaitForAllAssets(this AssetBundleRequest asyncOperation, CancellationToken cancellationToken) public static UniTask<UnityEngine.Object[]> AwaitForAllAssets(this AssetBundleRequest asyncOperation, CancellationToken cancellationToken)
{ {
return AwaitForAllAssets(asyncOperation, cancellationToken: cancellationToken); return AwaitForAllAssets(asyncOperation, null, PlayerLoopTiming.Update, cancellationToken: cancellationToken);
} }
public static UniTask<UnityEngine.Object[]> AwaitForAllAssets(this AssetBundleRequest asyncOperation, IProgress<float> progress = null, PlayerLoopTiming timing = PlayerLoopTiming.Update, CancellationToken cancellationToken = default(CancellationToken)) public static UniTask<UnityEngine.Object[]> AwaitForAllAssets(this AssetBundleRequest asyncOperation, IProgress<float> progress = null, PlayerLoopTiming timing = PlayerLoopTiming.Update, CancellationToken cancellationToken = default(CancellationToken))

View File

@@ -15,11 +15,15 @@ namespace Cysharp.Threading.Tasks
{ {
#region AsyncOperation #region AsyncOperation
#if !UNITY_2023_1_OR_NEWER
// from Unity2023.1.0a15, AsyncOperationAwaitableExtensions.GetAwaiter is defined in UnityEngine.
public static AsyncOperationAwaiter GetAwaiter(this AsyncOperation asyncOperation) public static AsyncOperationAwaiter GetAwaiter(this AsyncOperation asyncOperation)
{ {
Error.ThrowArgumentNullException(asyncOperation, nameof(asyncOperation)); Error.ThrowArgumentNullException(asyncOperation, nameof(asyncOperation));
return new AsyncOperationAwaiter(asyncOperation); return new AsyncOperationAwaiter(asyncOperation);
} }
#endif
public static UniTask WithCancellation(this AsyncOperation asyncOperation, CancellationToken cancellationToken) public static UniTask WithCancellation(this AsyncOperation asyncOperation, CancellationToken cancellationToken)
{ {

View File

@@ -688,13 +688,27 @@ namespace Cysharp.Threading.Tasks
static void OnCanceled1(object state) static void OnCanceled1(object state)
{ {
var self = (UnityEventHandlerAsyncEnumerator)state; var self = (UnityEventHandlerAsyncEnumerator)state;
self.DisposeAsync().Forget(); try
{
self.completionSource.TrySetCanceled(self.cancellationToken1);
}
finally
{
self.DisposeAsync().Forget();
}
} }
static void OnCanceled2(object state) static void OnCanceled2(object state)
{ {
var self = (UnityEventHandlerAsyncEnumerator)state; var self = (UnityEventHandlerAsyncEnumerator)state;
self.DisposeAsync().Forget(); try
{
self.completionSource.TrySetCanceled(self.cancellationToken2);
}
finally
{
self.DisposeAsync().Forget();
}
} }
public UniTask DisposeAsync() public UniTask DisposeAsync()
@@ -706,6 +720,8 @@ namespace Cysharp.Threading.Tasks
registration1.Dispose(); registration1.Dispose();
registration2.Dispose(); registration2.Dispose();
unityEvent.RemoveListener(unityAction); unityEvent.RemoveListener(unityAction);
completionSource.TrySetCanceled();
} }
return default; return default;
@@ -793,13 +809,27 @@ namespace Cysharp.Threading.Tasks
static void OnCanceled1(object state) static void OnCanceled1(object state)
{ {
var self = (UnityEventHandlerAsyncEnumerator)state; var self = (UnityEventHandlerAsyncEnumerator)state;
self.DisposeAsync().Forget(); try
{
self.completionSource.TrySetCanceled(self.cancellationToken1);
}
finally
{
self.DisposeAsync().Forget();
}
} }
static void OnCanceled2(object state) static void OnCanceled2(object state)
{ {
var self = (UnityEventHandlerAsyncEnumerator)state; var self = (UnityEventHandlerAsyncEnumerator)state;
self.DisposeAsync().Forget(); try
{
self.completionSource.TrySetCanceled(self.cancellationToken2);
}
finally
{
self.DisposeAsync().Forget();
}
} }
public UniTask DisposeAsync() public UniTask DisposeAsync()
@@ -815,6 +845,8 @@ namespace Cysharp.Threading.Tasks
disp.Dispose(); disp.Dispose();
} }
unityEvent.RemoveListener(unityAction); unityEvent.RemoveListener(unityAction);
completionSource.TrySetCanceled();
} }
return default; return default;

View File

@@ -1,4 +1,4 @@
#if ENABLE_UNITYWEBREQUEST && (!UNITY_2019_1_OR_NEWER || UNITASK_WEBREQUEST_SUPPORT) #if ENABLE_UNITYWEBREQUEST && (!UNITY_2019_1_OR_NEWER || UNITASK_WEBREQUEST_SUPPORT)
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@@ -49,7 +49,7 @@ namespace Cysharp.Threading.Tasks
{ {
if (msg == null) if (msg == null)
{ {
if (Text != null) if(!string.IsNullOrWhiteSpace(Text))
{ {
msg = Error + Environment.NewLine + Text; msg = Error + Environment.NewLine + Text;
} }

View File

@@ -2,7 +2,7 @@
"name": "com.cysharp.unitask", "name": "com.cysharp.unitask",
"displayName": "UniTask", "displayName": "UniTask",
"author": { "name": "Cysharp, Inc.", "url": "https://cysharp.co.jp/en/" }, "author": { "name": "Cysharp, Inc.", "url": "https://cysharp.co.jp/en/" },
"version": "2.3.1", "version": "2.3.2",
"unity": "2018.4", "unity": "2018.4",
"description": "Provides an efficient async/await integration to Unity.", "description": "Provides an efficient async/await integration to Unity.",
"keywords": [ "async/await", "async", "Task", "UniTask" ], "keywords": [ "async/await", "async", "Task", "UniTask" ],

View File

@@ -310,33 +310,33 @@ namespace Cysharp.Threading.TasksTests
yield return null; yield return null;
} }
[UnityTest] //[UnityTest]
public IEnumerator ExceptionUnobserved1() => UniTask.ToCoroutine(async () => //public IEnumerator ExceptionUnobserved1() => UniTask.ToCoroutine(async () =>
{ //{
bool calledEx = false; // bool calledEx = false;
Action<Exception> action = exx => // Action<Exception> action = exx =>
{ // {
calledEx = true; // calledEx = true;
exx.Message.Should().Be("MyException"); // exx.Message.Should().Be("MyException");
}; // };
UniTaskScheduler.UnobservedTaskException += action; // UniTaskScheduler.UnobservedTaskException += action;
var ex = InException1(); // var ex = InException1();
ex = default(UniTask); // ex = default(UniTask);
await UniTask.DelayFrame(3); // await UniTask.DelayFrame(3);
GC.Collect(); // GC.Collect();
GC.WaitForPendingFinalizers(); // GC.WaitForPendingFinalizers();
GC.Collect(); // GC.Collect();
await UniTask.DelayFrame(1); // await UniTask.DelayFrame(1);
calledEx.Should().BeTrue(); // calledEx.Should().BeTrue();
UniTaskScheduler.UnobservedTaskException -= action; // UniTaskScheduler.UnobservedTaskException -= action;
}); //});
[UnityTest] [UnityTest]
public IEnumerator ExceptionUnobserved2() => UniTask.ToCoroutine(async () => public IEnumerator ExceptionUnobserved2() => UniTask.ToCoroutine(async () =>