浼樺寲
Some checks failed
Sync Github To Image / sync-gitlink (push) Has been cancelled
Sync Github To Image / sync-gitlab (push) Has been cancelled
Sync Github To Image / sync-gitee (push) Has been cancelled
Sync Github To Image / sync-atomgit (push) Has been cancelled
Sync Github To Image / sync-gitcode (push) Has been cancelled
Sync Github To Image / sync-framagit (push) Has been cancelled
Some checks failed
Sync Github To Image / sync-gitlink (push) Has been cancelled
Sync Github To Image / sync-gitlab (push) Has been cancelled
Sync Github To Image / sync-gitee (push) Has been cancelled
Sync Github To Image / sync-atomgit (push) Has been cancelled
Sync Github To Image / sync-gitcode (push) Has been cancelled
Sync Github To Image / sync-framagit (push) Has been cancelled
This commit is contained in:
parent
5149abba24
commit
5d93024115
8
Runtime/External/YooAsset.meta
vendored
Normal file
8
Runtime/External/YooAsset.meta
vendored
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 8a55ef7d1bba14cc982b478d482c4461
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
145
Runtime/External/YooAsset/AsyncOperationBaseExtensions.cs
vendored
Normal file
145
Runtime/External/YooAsset/AsyncOperationBaseExtensions.cs
vendored
Normal file
@ -0,0 +1,145 @@
|
|||||||
|
using System;
|
||||||
|
using YooAsset;
|
||||||
|
using static Cysharp.Threading.Tasks.Internal.Error;
|
||||||
|
|
||||||
|
namespace Cysharp.Threading.Tasks
|
||||||
|
{
|
||||||
|
public static class AsyncOperationBaseExtensions
|
||||||
|
{
|
||||||
|
public static UniTask.Awaiter GetAwaiter(this AsyncOperationBase handle)
|
||||||
|
{
|
||||||
|
return ToUniTask(handle).GetAwaiter();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static UniTask ToUniTask(this AsyncOperationBase handle,
|
||||||
|
IProgress<float> progress = null,
|
||||||
|
PlayerLoopTiming timing = PlayerLoopTiming.Update)
|
||||||
|
{
|
||||||
|
ThrowArgumentNullException(handle, nameof(handle));
|
||||||
|
|
||||||
|
if(handle.IsDone)
|
||||||
|
{
|
||||||
|
return UniTask.CompletedTask;
|
||||||
|
}
|
||||||
|
|
||||||
|
return new UniTask(
|
||||||
|
AsyncOperationBaserConfiguredSource.Create(
|
||||||
|
handle,
|
||||||
|
timing,
|
||||||
|
progress,
|
||||||
|
out var token
|
||||||
|
),
|
||||||
|
token
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
sealed class AsyncOperationBaserConfiguredSource : IUniTaskSource,
|
||||||
|
IPlayerLoopItem,
|
||||||
|
ITaskPoolNode<AsyncOperationBaserConfiguredSource>
|
||||||
|
{
|
||||||
|
private static TaskPool<AsyncOperationBaserConfiguredSource> pool;
|
||||||
|
|
||||||
|
private AsyncOperationBaserConfiguredSource nextNode;
|
||||||
|
|
||||||
|
public ref AsyncOperationBaserConfiguredSource NextNode => ref nextNode;
|
||||||
|
|
||||||
|
static AsyncOperationBaserConfiguredSource()
|
||||||
|
{
|
||||||
|
TaskPool.RegisterSizeGetter(typeof(AsyncOperationBaserConfiguredSource), () => pool.Size);
|
||||||
|
}
|
||||||
|
|
||||||
|
private readonly Action<AsyncOperationBase> continuationAction;
|
||||||
|
private AsyncOperationBase handle;
|
||||||
|
private IProgress<float> progress;
|
||||||
|
private bool completed;
|
||||||
|
private UniTaskCompletionSourceCore<AsyncUnit> core;
|
||||||
|
|
||||||
|
AsyncOperationBaserConfiguredSource() { continuationAction = Continuation; }
|
||||||
|
|
||||||
|
public static IUniTaskSource Create(AsyncOperationBase handle,
|
||||||
|
PlayerLoopTiming timing,
|
||||||
|
IProgress<float> progress,
|
||||||
|
out short token)
|
||||||
|
{
|
||||||
|
if(!pool.TryPop(out var result))
|
||||||
|
{
|
||||||
|
result = new AsyncOperationBaserConfiguredSource();
|
||||||
|
}
|
||||||
|
|
||||||
|
result.handle = handle;
|
||||||
|
result.progress = progress;
|
||||||
|
result.completed = false;
|
||||||
|
TaskTracker.TrackActiveTask(result, 3);
|
||||||
|
|
||||||
|
if(progress != null)
|
||||||
|
{
|
||||||
|
PlayerLoopHelper.AddAction(timing, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
handle.Completed += result.continuationAction;
|
||||||
|
|
||||||
|
token = result.core.Version;
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Continuation(AsyncOperationBase _)
|
||||||
|
{
|
||||||
|
handle.Completed -= continuationAction;
|
||||||
|
|
||||||
|
if(completed)
|
||||||
|
{
|
||||||
|
TryReturn();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
completed = true;
|
||||||
|
if(handle.Status == EOperationStatus.Failed)
|
||||||
|
{
|
||||||
|
core.TrySetException(new Exception(handle.Error));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
core.TrySetResult(AsyncUnit.Default);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool TryReturn()
|
||||||
|
{
|
||||||
|
TaskTracker.RemoveTracking(this);
|
||||||
|
core.Reset();
|
||||||
|
handle = default;
|
||||||
|
progress = default;
|
||||||
|
return pool.TryPush(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public UniTaskStatus GetStatus(short token) => core.GetStatus(token);
|
||||||
|
|
||||||
|
public void OnCompleted(Action<object> continuation, object state, short token)
|
||||||
|
{
|
||||||
|
core.OnCompleted(continuation, state, token);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void GetResult(short token) { core.GetResult(token); }
|
||||||
|
|
||||||
|
public UniTaskStatus UnsafeGetStatus() => core.UnsafeGetStatus();
|
||||||
|
|
||||||
|
public bool MoveNext()
|
||||||
|
{
|
||||||
|
if(completed)
|
||||||
|
{
|
||||||
|
TryReturn();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!handle.IsDone)
|
||||||
|
{
|
||||||
|
progress?.Report(handle.Progress);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
3
Runtime/External/YooAsset/AsyncOperationBaseExtensions.cs.meta
vendored
Normal file
3
Runtime/External/YooAsset/AsyncOperationBaseExtensions.cs.meta
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 2cceff5ec1f84bd0a6a9b4ed7719527c
|
||||||
|
timeCreated: 1651978895
|
245
Runtime/External/YooAsset/OperationHandleBaseExtensions.cs
vendored
Normal file
245
Runtime/External/YooAsset/OperationHandleBaseExtensions.cs
vendored
Normal file
@ -0,0 +1,245 @@
|
|||||||
|
#if UNITY_2020_1_OR_NEWER && ! UNITY_2021
|
||||||
|
#define UNITY_2020_BUG
|
||||||
|
#endif
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
|
using YooAsset;
|
||||||
|
using static Cysharp.Threading.Tasks.Internal.Error;
|
||||||
|
|
||||||
|
|
||||||
|
namespace Cysharp.Threading.Tasks
|
||||||
|
{
|
||||||
|
public static class OperationHandleBaseExtensions
|
||||||
|
{
|
||||||
|
public static UniTask.Awaiter GetAwaiter(this HandleBase handle)
|
||||||
|
{
|
||||||
|
return ToUniTask(handle).GetAwaiter();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static UniTask ToUniTask(this HandleBase handle,
|
||||||
|
IProgress<float> progress = null,
|
||||||
|
PlayerLoopTiming timing = PlayerLoopTiming.Update)
|
||||||
|
{
|
||||||
|
ThrowArgumentNullException(handle, nameof(handle));
|
||||||
|
|
||||||
|
if(!handle.IsValid)
|
||||||
|
{
|
||||||
|
return UniTask.CompletedTask;
|
||||||
|
}
|
||||||
|
|
||||||
|
return new UniTask(
|
||||||
|
OperationHandleBaserConfiguredSource.Create(
|
||||||
|
handle,
|
||||||
|
timing,
|
||||||
|
progress,
|
||||||
|
out var token
|
||||||
|
),
|
||||||
|
token
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
sealed class OperationHandleBaserConfiguredSource : IUniTaskSource,
|
||||||
|
IPlayerLoopItem,
|
||||||
|
ITaskPoolNode<OperationHandleBaserConfiguredSource>
|
||||||
|
{
|
||||||
|
private static TaskPool<OperationHandleBaserConfiguredSource> pool;
|
||||||
|
|
||||||
|
private OperationHandleBaserConfiguredSource nextNode;
|
||||||
|
|
||||||
|
public ref OperationHandleBaserConfiguredSource NextNode => ref nextNode;
|
||||||
|
|
||||||
|
static OperationHandleBaserConfiguredSource()
|
||||||
|
{
|
||||||
|
TaskPool.RegisterSizeGetter(typeof(OperationHandleBaserConfiguredSource), () => pool.Size);
|
||||||
|
}
|
||||||
|
|
||||||
|
private readonly Action<HandleBase> continuationAction;
|
||||||
|
private HandleBase handle;
|
||||||
|
private IProgress<float> progress;
|
||||||
|
private bool completed;
|
||||||
|
private UniTaskCompletionSourceCore<AsyncUnit> core;
|
||||||
|
|
||||||
|
OperationHandleBaserConfiguredSource() { continuationAction = Continuation; }
|
||||||
|
|
||||||
|
public static IUniTaskSource Create(HandleBase handle,
|
||||||
|
PlayerLoopTiming timing,
|
||||||
|
IProgress<float> progress,
|
||||||
|
out short token)
|
||||||
|
{
|
||||||
|
if(!pool.TryPop(out var result))
|
||||||
|
{
|
||||||
|
result = new OperationHandleBaserConfiguredSource();
|
||||||
|
}
|
||||||
|
|
||||||
|
result.handle = handle;
|
||||||
|
result.progress = progress;
|
||||||
|
result.completed = false;
|
||||||
|
TaskTracker.TrackActiveTask(result, 3);
|
||||||
|
|
||||||
|
if(progress != null)
|
||||||
|
{
|
||||||
|
PlayerLoopHelper.AddAction(timing, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
// BUG 在 Unity 2020.3.36 版本测试中, IL2Cpp 会报 如下错误
|
||||||
|
// BUG ArgumentException: Incompatible Delegate Types. First is System.Action`1[[YooAsset.AssetHandle, YooAsset, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null]] second is System.Action`1[[YooAsset.OperationHandleBase, YooAsset, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null]]
|
||||||
|
// BUG 也可能报的是 Action '1' Action '1' 的 InvalidCastException
|
||||||
|
// BUG 此处不得不这么修改, 如果后续 Unity 修复了这个问题, 可以恢复之前的写法
|
||||||
|
#if UNITY_2020_BUG
|
||||||
|
switch(handle)
|
||||||
|
{
|
||||||
|
case AssetHandle asset_handle:
|
||||||
|
asset_handle.Completed += result.AssetContinuation;
|
||||||
|
break;
|
||||||
|
case SceneHandle scene_handle:
|
||||||
|
scene_handle.Completed += result.SceneContinuation;
|
||||||
|
break;
|
||||||
|
case SubAssetsHandle sub_asset_handle:
|
||||||
|
sub_asset_handle.Completed += result.SubContinuation;
|
||||||
|
break;
|
||||||
|
case RawFileHandle raw_file_handle:
|
||||||
|
raw_file_handle.Completed += result.RawFileContinuation;
|
||||||
|
break;
|
||||||
|
case AllAssetsHandle all_assets_handle:
|
||||||
|
all_assets_handle.Completed += result.AllAssetsContinuation;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
switch (handle)
|
||||||
|
{
|
||||||
|
case AssetHandle asset_handle:
|
||||||
|
asset_handle.Completed += result.continuationAction;
|
||||||
|
break;
|
||||||
|
case SceneHandle scene_handle:
|
||||||
|
scene_handle.Completed += result.continuationAction;
|
||||||
|
break;
|
||||||
|
case SubAssetsHandle sub_asset_handle:
|
||||||
|
sub_asset_handle.Completed += result.continuationAction;
|
||||||
|
break;
|
||||||
|
case RawFileHandle raw_file_handle:
|
||||||
|
raw_file_handle.Completed += result.continuationAction;
|
||||||
|
break;
|
||||||
|
case AllAssetsHandle all_assets_handle:
|
||||||
|
all_assets_handle.Completed += result.continuationAction;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
token = result.core.Version;
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
#if UNITY_2020_BUG
|
||||||
|
private void AssetContinuation(AssetHandle handle)
|
||||||
|
{
|
||||||
|
handle.Completed -= AssetContinuation;
|
||||||
|
BaseContinuation();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SceneContinuation(SceneHandle handle)
|
||||||
|
{
|
||||||
|
handle.Completed -= SceneContinuation;
|
||||||
|
BaseContinuation();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SubContinuation(SubAssetsHandle handle)
|
||||||
|
{
|
||||||
|
handle.Completed -= SubContinuation;
|
||||||
|
BaseContinuation();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void RawFileContinuation(RawFileHandle handle)
|
||||||
|
{
|
||||||
|
handle.Completed -= RawFileContinuation;
|
||||||
|
BaseContinuation();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void AllAssetsContinuation(AllAssetsHandle handle)
|
||||||
|
{
|
||||||
|
handle.Completed -= AllAssetsContinuation;
|
||||||
|
BaseContinuation();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
|
private void BaseContinuation()
|
||||||
|
{
|
||||||
|
if(completed)
|
||||||
|
{
|
||||||
|
TryReturn();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
completed = true;
|
||||||
|
if(handle.Status == EOperationStatus.Failed)
|
||||||
|
{
|
||||||
|
core.TrySetException(new Exception(handle.LastError));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
core.TrySetResult(AsyncUnit.Default);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Continuation(HandleBase _)
|
||||||
|
{
|
||||||
|
switch(handle)
|
||||||
|
{
|
||||||
|
case AssetHandle asset_handle:
|
||||||
|
asset_handle.Completed -= continuationAction;
|
||||||
|
break;
|
||||||
|
case SceneHandle scene_handle:
|
||||||
|
scene_handle.Completed -= continuationAction;
|
||||||
|
break;
|
||||||
|
case SubAssetsHandle sub_asset_handle:
|
||||||
|
sub_asset_handle.Completed -= continuationAction;
|
||||||
|
break;
|
||||||
|
case RawFileHandle raw_file_handle:
|
||||||
|
raw_file_handle.Completed -= continuationAction;
|
||||||
|
break;
|
||||||
|
case AllAssetsHandle all_assets_handle:
|
||||||
|
all_assets_handle.Completed -= continuationAction;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
BaseContinuation();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool TryReturn()
|
||||||
|
{
|
||||||
|
TaskTracker.RemoveTracking(this);
|
||||||
|
core.Reset();
|
||||||
|
handle = default;
|
||||||
|
progress = default;
|
||||||
|
return pool.TryPush(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public UniTaskStatus GetStatus(short token) => core.GetStatus(token);
|
||||||
|
|
||||||
|
public void OnCompleted(Action<object> continuation, object state, short token)
|
||||||
|
{
|
||||||
|
core.OnCompleted(continuation, state, token);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void GetResult(short token) { core.GetResult(token); }
|
||||||
|
|
||||||
|
public UniTaskStatus UnsafeGetStatus() => core.UnsafeGetStatus();
|
||||||
|
|
||||||
|
public bool MoveNext()
|
||||||
|
{
|
||||||
|
if(completed)
|
||||||
|
{
|
||||||
|
TryReturn();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(handle.IsValid)
|
||||||
|
{
|
||||||
|
progress?.Report(handle.Progress);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
3
Runtime/External/YooAsset/OperationHandleBaseExtensions.cs.meta
vendored
Normal file
3
Runtime/External/YooAsset/OperationHandleBaseExtensions.cs.meta
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: e1c9a3a6de2246bf88547a6b59b99b9f
|
||||||
|
timeCreated: 1650851321
|
17
Runtime/External/YooAsset/UniTask.YooAsset.asmdef
vendored
Normal file
17
Runtime/External/YooAsset/UniTask.YooAsset.asmdef
vendored
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
{
|
||||||
|
"name": "UniTask.YooAsset",
|
||||||
|
"rootNamespace": "",
|
||||||
|
"references": [
|
||||||
|
"GUID:e34a5702dd353724aa315fb8011f08c3",
|
||||||
|
"GUID:f51ebe6a0ceec4240a699833d6309b23"
|
||||||
|
],
|
||||||
|
"includePlatforms": [],
|
||||||
|
"excludePlatforms": [],
|
||||||
|
"allowUnsafeCode": true,
|
||||||
|
"overrideReferences": false,
|
||||||
|
"precompiledReferences": [],
|
||||||
|
"autoReferenced": true,
|
||||||
|
"defineConstraints": [],
|
||||||
|
"versionDefines": [],
|
||||||
|
"noEngineReferences": false
|
||||||
|
}
|
7
Runtime/External/YooAsset/UniTask.YooAsset.asmdef.meta
vendored
Normal file
7
Runtime/External/YooAsset/UniTask.YooAsset.asmdef.meta
vendored
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: b4c00b967a932af48b2e067403eecbe2
|
||||||
|
AssemblyDefinitionImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
@ -1,6 +1,8 @@
|
|||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
|
|
||||||
|
[assembly: InternalsVisibleTo("UniTask.YooAsset")]
|
||||||
[assembly: InternalsVisibleTo("UniTask.Linq")]
|
[assembly: InternalsVisibleTo("UniTask.Linq")]
|
||||||
[assembly: InternalsVisibleTo("UniTask.Addressables")]
|
[assembly: InternalsVisibleTo("UniTask.Addressables")]
|
||||||
[assembly: InternalsVisibleTo("UniTask.DOTween")]
|
[assembly: InternalsVisibleTo("UniTask.DOTween")]
|
||||||
[assembly: InternalsVisibleTo("UniTask.TextMeshPro")]
|
[assembly: InternalsVisibleTo("UniTask.TextMeshPro")]
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user