From 6fb5a4b9461f08a331de123646ad11b030735747 Mon Sep 17 00:00:00 2001 From: hevinci Date: Wed, 20 Sep 2023 16:10:57 +0800 Subject: [PATCH] update yooasset2.0 --- .../Scripts/Editor/CustomPackRule.cs | 10 ---------- .../Scripts/Editor/PackageImportWindow.cs | 10 +++++----- .../Runtime/AssetOperationHandleExtension.cs | 20 +------------------ .../Runtime/GameObjectAssetReference.cs | 4 ++-- .../Runtime/LoadAssetsByTagOperation.cs | 4 ++-- 5 files changed, 10 insertions(+), 38 deletions(-) diff --git a/Assets/YooAsset/Samples~/Extension Sample/Scripts/Editor/CustomPackRule.cs b/Assets/YooAsset/Samples~/Extension Sample/Scripts/Editor/CustomPackRule.cs index ebd7a3c..1e34ba6 100644 --- a/Assets/YooAsset/Samples~/Extension Sample/Scripts/Editor/CustomPackRule.cs +++ b/Assets/YooAsset/Samples~/Extension Sample/Scripts/Editor/CustomPackRule.cs @@ -22,11 +22,6 @@ public class PackEffectTexture : IPackRule var packRuleResult = new PackRuleResult(bundleName, DefaultPackRule.AssetBundleFileExtension); return packRuleResult; } - - bool IPackRule.IsRawFilePackRule() - { - return false; - } } [DisplayName("打包视频(自定义)")] @@ -41,11 +36,6 @@ public class PackVideo : IPackRule return result; } - bool IPackRule.IsRawFilePackRule() - { - return true; - } - private string RemoveExtension(string str) { if (string.IsNullOrEmpty(str)) diff --git a/Assets/YooAsset/Samples~/Extension Sample/Scripts/Editor/PackageImportWindow.cs b/Assets/YooAsset/Samples~/Extension Sample/Scripts/Editor/PackageImportWindow.cs index 50fd7e5..50c8cdc 100644 --- a/Assets/YooAsset/Samples~/Extension Sample/Scripts/Editor/PackageImportWindow.cs +++ b/Assets/YooAsset/Samples~/Extension Sample/Scripts/Editor/PackageImportWindow.cs @@ -40,7 +40,7 @@ namespace YooAsset.Editor { if (GUILayout.Button("导入补丁包(全部文件)", GUILayout.MaxWidth(150))) { - string streamingAssetsRoot = AssetBundleBuilderHelper.GetDefaultStreamingAssetsRoot(); + string streamingAssetsRoot = AssetBundleBuilderHelper.GetStreamingAssetsRoot(); EditorTools.ClearFolder(streamingAssetsRoot); CopyPackageFiles(_manifestPath); } @@ -59,18 +59,18 @@ namespace YooAsset.Editor // 拷贝核心文件 { string sourcePath = $"{outputDirectory}/{manifestFileName}.bytes"; - string destPath = $"{AssetBundleBuilderHelper.GetDefaultStreamingAssetsRoot()}/{_packageName}/{manifestFileName}.bytes"; + string destPath = $"{AssetBundleBuilderHelper.GetStreamingAssetsRoot()}/{_packageName}/{manifestFileName}.bytes"; EditorTools.CopyFile(sourcePath, destPath, true); } { string sourcePath = $"{outputDirectory}/{manifestFileName}.hash"; - string destPath = $"{AssetBundleBuilderHelper.GetDefaultStreamingAssetsRoot()}/{_packageName}/{manifestFileName}.hash"; + string destPath = $"{AssetBundleBuilderHelper.GetStreamingAssetsRoot()}/{_packageName}/{manifestFileName}.hash"; EditorTools.CopyFile(sourcePath, destPath, true); } { string fileName = YooAssetSettingsData.GetPackageVersionFileName(manifest.PackageName); string sourcePath = $"{outputDirectory}/{fileName}"; - string destPath = $"{AssetBundleBuilderHelper.GetDefaultStreamingAssetsRoot()}/{_packageName}/{fileName}"; + string destPath = $"{AssetBundleBuilderHelper.GetStreamingAssetsRoot()}/{_packageName}/{fileName}"; EditorTools.CopyFile(sourcePath, destPath, true); } @@ -80,7 +80,7 @@ namespace YooAsset.Editor { fileCount++; string sourcePath = $"{outputDirectory}/{packageBundle.FileName}"; - string destPath = $"{AssetBundleBuilderHelper.GetDefaultStreamingAssetsRoot()}/{_packageName}/{packageBundle.FileName}"; + string destPath = $"{AssetBundleBuilderHelper.GetStreamingAssetsRoot()}/{_packageName}/{packageBundle.FileName}"; EditorTools.CopyFile(sourcePath, destPath, true); } diff --git a/Assets/YooAsset/Samples~/Extension Sample/Scripts/Runtime/AssetOperationHandleExtension.cs b/Assets/YooAsset/Samples~/Extension Sample/Scripts/Runtime/AssetOperationHandleExtension.cs index 971b252..45cf55a 100644 --- a/Assets/YooAsset/Samples~/Extension Sample/Scripts/Runtime/AssetOperationHandleExtension.cs +++ b/Assets/YooAsset/Samples~/Extension Sample/Scripts/Runtime/AssetOperationHandleExtension.cs @@ -5,28 +5,10 @@ using YooAsset; public static class AssetOperationHandleExtension { - /* - /// - /// 获取资源对象 - /// - /// - /// - public static AssetOperationHandle GetAssetObject(this AssetOperationHandle thisHandle, out TAsset asset) where TAsset : UnityEngine.Object - { - if (thisHandle.Status != EOperationStatus.Succeed) - { - var assetInfo = thisHandle.GetAssetInfo(); - Debug.LogWarning($"The {assetInfo.AssetPath}[{assetInfo.AssetType}] is not success. Error[{thisHandle.LastError}]"); - } - asset = thisHandle.AssetObject as TAsset; - return thisHandle; - } - */ - /// /// 等待异步执行完毕 /// - public static AssetOperationHandle WaitForAsyncOperationComplete(this AssetOperationHandle thisHandle) + public static AssetHandle WaitForAsyncOperationComplete(this AssetHandle thisHandle) { thisHandle.WaitForAsyncComplete(); return thisHandle; diff --git a/Assets/YooAsset/Samples~/Extension Sample/Scripts/Runtime/GameObjectAssetReference.cs b/Assets/YooAsset/Samples~/Extension Sample/Scripts/Runtime/GameObjectAssetReference.cs index 0092ae4..fe75fa6 100644 --- a/Assets/YooAsset/Samples~/Extension Sample/Scripts/Runtime/GameObjectAssetReference.cs +++ b/Assets/YooAsset/Samples~/Extension Sample/Scripts/Runtime/GameObjectAssetReference.cs @@ -45,7 +45,7 @@ public class GameObjectAssetReference : MonoBehaviour [HideInInspector] public string AssetGUID = ""; - private AssetOperationHandle _handle; + private AssetHandle _handle; public void Start() { @@ -63,7 +63,7 @@ public class GameObjectAssetReference : MonoBehaviour } } - private void Handle_Completed(AssetOperationHandle handle) + private void Handle_Completed(AssetHandle handle) { if (handle.Status == EOperationStatus.Succeed) { diff --git a/Assets/YooAsset/Samples~/Extension Sample/Scripts/Runtime/LoadAssetsByTagOperation.cs b/Assets/YooAsset/Samples~/Extension Sample/Scripts/Runtime/LoadAssetsByTagOperation.cs index 3c9ee48..20bfc09 100644 --- a/Assets/YooAsset/Samples~/Extension Sample/Scripts/Runtime/LoadAssetsByTagOperation.cs +++ b/Assets/YooAsset/Samples~/Extension Sample/Scripts/Runtime/LoadAssetsByTagOperation.cs @@ -16,7 +16,7 @@ public class LoadAssetsByTagOperation : GameAsyncOperation where TObjec private readonly string _tag; private ESteps _steps = ESteps.None; - private List _handles; + private List _handles; /// /// 资源对象集合 @@ -40,7 +40,7 @@ public class LoadAssetsByTagOperation : GameAsyncOperation where TObjec if (_steps == ESteps.LoadAssets) { AssetInfo[] assetInfos = YooAssets.GetAssetInfos(_tag); - _handles = new List(assetInfos.Length); + _handles = new List(assetInfos.Length); foreach (var assetInfo in assetInfos) { var handle = YooAssets.LoadAssetAsync(assetInfo);