From a72ceeba119de0b8a41eeb3ecd0c3dba1f22aae3 Mon Sep 17 00:00:00 2001 From: neuecc Date: Thu, 13 Aug 2020 16:33:32 +0900 Subject: [PATCH] UNITASK_ASSETBUNDLE_SUPPORT #131 --- src/UniTask/Assets/Plugins/UniTask/Runtime/UniTask.asmdef | 5 +++++ .../UnityAsyncExtensions.AssetBundleRequestAllAssets.cs | 2 ++ .../Assets/Plugins/UniTask/Runtime/UnityAsyncExtensions.cs | 4 ++++ .../Assets/Plugins/UniTask/Runtime/UnityAsyncExtensions.tt | 5 ++++- 4 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/UniTask/Assets/Plugins/UniTask/Runtime/UniTask.asmdef b/src/UniTask/Assets/Plugins/UniTask/Runtime/UniTask.asmdef index e1fab8b..1c888bf 100644 --- a/src/UniTask/Assets/Plugins/UniTask/Runtime/UniTask.asmdef +++ b/src/UniTask/Assets/Plugins/UniTask/Runtime/UniTask.asmdef @@ -10,6 +10,11 @@ "autoReferenced": true, "defineConstraints": [], "versionDefines": [ + { + "name": "com.unity.modules.assetbundle", + "expression": "", + "define": "UNITASK_ASSETBUNDLE_SUPPORT" + } ], "noEngineReferences": false } \ No newline at end of file diff --git a/src/UniTask/Assets/Plugins/UniTask/Runtime/UnityAsyncExtensions.AssetBundleRequestAllAssets.cs b/src/UniTask/Assets/Plugins/UniTask/Runtime/UnityAsyncExtensions.AssetBundleRequestAllAssets.cs index b1e23c0..076d255 100644 --- a/src/UniTask/Assets/Plugins/UniTask/Runtime/UnityAsyncExtensions.AssetBundleRequestAllAssets.cs +++ b/src/UniTask/Assets/Plugins/UniTask/Runtime/UnityAsyncExtensions.AssetBundleRequestAllAssets.cs @@ -1,6 +1,7 @@ #pragma warning disable CS1591 // Missing XML comment for publicly visible type or member #if UNITY_2018_4 || UNITY_2019_4_OR_NEWER +#if UNITASK_ASSETBUNDLE_SUPPORT using Cysharp.Threading.Tasks.Internal; using System; @@ -312,4 +313,5 @@ namespace Cysharp.Threading.Tasks } } +#endif #endif \ No newline at end of file diff --git a/src/UniTask/Assets/Plugins/UniTask/Runtime/UnityAsyncExtensions.cs b/src/UniTask/Assets/Plugins/UniTask/Runtime/UnityAsyncExtensions.cs index b045d96..5246bc1 100644 --- a/src/UniTask/Assets/Plugins/UniTask/Runtime/UnityAsyncExtensions.cs +++ b/src/UniTask/Assets/Plugins/UniTask/Runtime/UnityAsyncExtensions.cs @@ -605,6 +605,7 @@ namespace Cysharp.Threading.Tasks #endregion +#if UNITASK_ASSETBUNDLE_SUPPORT #region AssetBundleRequest public static AssetBundleRequestAwaiter GetAwaiter(this AssetBundleRequest asyncOperation) @@ -906,7 +907,9 @@ namespace Cysharp.Threading.Tasks } #endregion +#endif +#if UNITASK_ASSETBUNDLE_SUPPORT #region AssetBundleCreateRequest public static AssetBundleCreateRequestAwaiter GetAwaiter(this AssetBundleCreateRequest asyncOperation) @@ -1208,6 +1211,7 @@ namespace Cysharp.Threading.Tasks } #endregion +#endif #if ENABLE_UNITYWEBREQUEST #region UnityWebRequestAsyncOperation diff --git a/src/UniTask/Assets/Plugins/UniTask/Runtime/UnityAsyncExtensions.tt b/src/UniTask/Assets/Plugins/UniTask/Runtime/UnityAsyncExtensions.tt index ee4c457..0aba600 100644 --- a/src/UniTask/Assets/Plugins/UniTask/Runtime/UnityAsyncExtensions.tt +++ b/src/UniTask/Assets/Plugins/UniTask/Runtime/UnityAsyncExtensions.tt @@ -17,6 +17,7 @@ Func ToUniTaskReturnType = x => (x == "void") ? "UniTask" : $"UniTask<{x}>"; Func ToIUniTaskSourceReturnType = x => (x == "void") ? "IUniTaskSource" : $"IUniTaskSource<{x}>"; Func<(string typeName, string returnType, string returnField), bool> IsUnityWebRequest = x => x.returnType == "UnityWebRequest"; + Func<(string typeName, string returnType, string returnField), bool> IsAssetBundleModule = x => x.typeName == "AssetBundleRequest" || x.typeName == "AssetBundleCreateRequest"; Func<(string typeName, string returnType, string returnField), bool> IsVoid = x => x.returnType == "void"; #> #pragma warning disable CS1591 // Missing XML comment for publicly visible type or member @@ -37,6 +38,8 @@ namespace Cysharp.Threading.Tasks <# foreach(var t in types) { #> <# if(IsUnityWebRequest(t)) { #> #if ENABLE_UNITYWEBREQUEST +<# } else if(IsAssetBundleModule(t)) { #> +#if UNITASK_ASSETBUNDLE_SUPPORT <# } #> #region <#= t.typeName #> @@ -422,7 +425,7 @@ namespace Cysharp.Threading.Tasks } #endregion -<# if(IsUnityWebRequest(t)) { #> +<# if(IsUnityWebRequest(t) || IsAssetBundleModule(t)) { #> #endif <# } #>