From 1f26f001e96386848f3e7e31c5ae62e3a7fe8ede Mon Sep 17 00:00:00 2001 From: hevinci Date: Fri, 14 Oct 2022 12:23:23 +0800 Subject: [PATCH] Update basic sample --- .../GameScript/Runtime/BootScene.cs | 12 +++++++--- .../GameScript/Runtime/GameScene1.cs | 3 ++- .../GameScript/Runtime/GameScene2.cs | 3 ++- .../PatchUpdater/FsmNode/FsmUpdateManifest.cs | 3 ++- .../FsmNode/FsmUpdateStaticVersion.cs | 3 ++- .../AssetBundleCollectorSetting.asset | 22 +++++++++---------- 6 files changed, 28 insertions(+), 18 deletions(-) diff --git a/Assets/YooAsset/Samples~/Basic Sample/GameScript/Runtime/BootScene.cs b/Assets/YooAsset/Samples~/Basic Sample/GameScript/Runtime/BootScene.cs index 4c95c24..55d601a 100644 --- a/Assets/YooAsset/Samples~/Basic Sample/GameScript/Runtime/BootScene.cs +++ b/Assets/YooAsset/Samples~/Basic Sample/GameScript/Runtime/BootScene.cs @@ -43,13 +43,19 @@ public class BootScene : MonoBehaviour // 初始化资源系统 YooAssets.Initialize(); + // 创建默认的资源包 + var defaultPackage = YooAssets.CreateAssetsPackage("DefaultPackage"); + + // 设置该资源包为默认的资源包 + YooAssets.SetDefaultAssetsPackage(defaultPackage); + // 编辑器下的模拟模式 if (PlayMode == EPlayMode.EditorSimulateMode) { var createParameters = new EditorSimulateModeParameters(); createParameters.LocationServices = new AddressLocationServices(); createParameters.SimulatePatchManifestPath = EditorSimulateModeHelper.SimulateBuild("DefaultPackage", true); - yield return YooAssets.InitializeAsync(createParameters); + yield return defaultPackage.InitializeAsync(createParameters); } // 单机运行模式 @@ -57,7 +63,7 @@ public class BootScene : MonoBehaviour { var createParameters = new OfflinePlayModeParameters(); createParameters.LocationServices = new AddressLocationServices(); - yield return YooAssets.InitializeAsync(createParameters); + yield return defaultPackage.InitializeAsync(createParameters); } // 联机运行模式 @@ -68,7 +74,7 @@ public class BootScene : MonoBehaviour createParameters.QueryServices = new QueryStreamingAssetsFileServices(); createParameters.DefaultHostServer = GetHostServerURL(); createParameters.FallbackHostServer = GetHostServerURL(); - yield return YooAssets.InitializeAsync(createParameters); + yield return defaultPackage.InitializeAsync(createParameters); } // 运行补丁流程 diff --git a/Assets/YooAsset/Samples~/Basic Sample/GameScript/Runtime/GameScene1.cs b/Assets/YooAsset/Samples~/Basic Sample/GameScript/Runtime/GameScene1.cs index e3bf2d4..2b90895 100644 --- a/Assets/YooAsset/Samples~/Basic Sample/GameScript/Runtime/GameScene1.cs +++ b/Assets/YooAsset/Samples~/Basic Sample/GameScript/Runtime/GameScene1.cs @@ -16,7 +16,8 @@ public class GameScene1 : MonoBehaviour void Start() { - YooAssets.UnloadUnusedAssets(); + var package = YooAssets.GetAssetsPackage("DefaultPackage"); + package.UnloadUnusedAssets(); // 初始化窗口 InitWindow(); diff --git a/Assets/YooAsset/Samples~/Basic Sample/GameScript/Runtime/GameScene2.cs b/Assets/YooAsset/Samples~/Basic Sample/GameScript/Runtime/GameScene2.cs index 3e81819..29efb3a 100644 --- a/Assets/YooAsset/Samples~/Basic Sample/GameScript/Runtime/GameScene2.cs +++ b/Assets/YooAsset/Samples~/Basic Sample/GameScript/Runtime/GameScene2.cs @@ -14,7 +14,8 @@ public class GameScene2 : MonoBehaviour void Start() { - YooAssets.UnloadUnusedAssets(); + var package = YooAssets.GetAssetsPackage("DefaultPackage"); + package.UnloadUnusedAssets(); // 初始化窗口 InitWindow(); diff --git a/Assets/YooAsset/Samples~/Basic Sample/GameScript/Runtime/PatchUpdater/FsmNode/FsmUpdateManifest.cs b/Assets/YooAsset/Samples~/Basic Sample/GameScript/Runtime/PatchUpdater/FsmNode/FsmUpdateManifest.cs index 5107072..420800f 100644 --- a/Assets/YooAsset/Samples~/Basic Sample/GameScript/Runtime/PatchUpdater/FsmNode/FsmUpdateManifest.cs +++ b/Assets/YooAsset/Samples~/Basic Sample/GameScript/Runtime/PatchUpdater/FsmNode/FsmUpdateManifest.cs @@ -24,7 +24,8 @@ public class FsmUpdateManifest : IFsmNode yield return new WaitForSecondsRealtime(0.5f); // 更新补丁清单 - var operation = YooAssets.UpdateManifestAsync(PatchUpdater.PackageCRC, 30); + var package = YooAssets.GetAssetsPackage("DefaultPackage"); + var operation = package.UpdateManifestAsync(PatchUpdater.PackageCRC, 30); yield return operation; if(operation.Status == EOperationStatus.Succeed) diff --git a/Assets/YooAsset/Samples~/Basic Sample/GameScript/Runtime/PatchUpdater/FsmNode/FsmUpdateStaticVersion.cs b/Assets/YooAsset/Samples~/Basic Sample/GameScript/Runtime/PatchUpdater/FsmNode/FsmUpdateStaticVersion.cs index d9ab1a6..e7e2ce0 100644 --- a/Assets/YooAsset/Samples~/Basic Sample/GameScript/Runtime/PatchUpdater/FsmNode/FsmUpdateStaticVersion.cs +++ b/Assets/YooAsset/Samples~/Basic Sample/GameScript/Runtime/PatchUpdater/FsmNode/FsmUpdateStaticVersion.cs @@ -24,7 +24,8 @@ internal class FsmUpdateStaticVersion : IFsmNode yield return new WaitForSecondsRealtime(0.5f); // 更新资源版本号 - var operation = YooAssets.UpdateStaticVersionAsync(30); + var package = YooAssets.GetAssetsPackage("DefaultPackage"); + var operation = package.UpdateStaticVersionAsync(30); yield return operation; if (operation.Status == EOperationStatus.Succeed) diff --git a/Assets/YooAsset/Samples~/Basic Sample/YooAssetSetting/AssetBundleCollectorSetting.asset b/Assets/YooAsset/Samples~/Basic Sample/YooAssetSetting/AssetBundleCollectorSetting.asset index edf7336..62bb97f 100644 --- a/Assets/YooAsset/Samples~/Basic Sample/YooAssetSetting/AssetBundleCollectorSetting.asset +++ b/Assets/YooAsset/Samples~/Basic Sample/YooAssetSetting/AssetBundleCollectorSetting.asset @@ -23,14 +23,14 @@ MonoBehaviour: AssetTags: level ActiveRuleName: EnableGroup Collectors: - - CollectPath: Assets/YooAsset/Samples/Basic Sample/GameRes/Entity/Level1 + - CollectPath: Assets/Samples/Basic Sample/GameRes/Entity/Level1 CollectorGUID: 724066efe61192e43a0d7e59166b36a4 CollectorType: 0 AddressRuleName: AddressByFileName PackRuleName: PackSeparately FilterRuleName: CollectPrefab AssetTags: level1 - - CollectPath: Assets/YooAsset/Samples/Basic Sample/GameRes/Entity/Level2 + - CollectPath: Assets/Samples/Basic Sample/GameRes/Entity/Level2 CollectorGUID: 8045c1986f0ae964f8b1ea29e3522388 CollectorType: 0 AddressRuleName: AddressByFileName @@ -42,21 +42,21 @@ MonoBehaviour: AssetTags: buildin ActiveRuleName: EnableGroup Collectors: - - CollectPath: Assets/YooAsset/Samples/Basic Sample/GameRes/Scene + - CollectPath: Assets/Samples/Basic Sample/GameRes/Scene CollectorGUID: f75e7d64104fb1a48b849b72b84ade4c CollectorType: 0 AddressRuleName: AddressByFileName PackRuleName: PackSeparately FilterRuleName: CollectScene AssetTags: - - CollectPath: Assets/YooAsset/Samples/Basic Sample/GameRes/Config + - CollectPath: Assets/Samples/Basic Sample/GameRes/Config CollectorGUID: 44774abdee2b91b45b42f9dadf8c17a4 CollectorType: 0 AddressRuleName: AddressByFileName PackRuleName: PackRawFile FilterRuleName: CollectAll AssetTags: - - CollectPath: Assets/YooAsset/Samples/Basic Sample/GameRes/Music + - CollectPath: Assets/Samples/Basic Sample/GameRes/Music CollectorGUID: e05b02ee4d90ae84a99871ce75288ea2 CollectorType: 0 AddressRuleName: AddressByFileName @@ -68,28 +68,28 @@ MonoBehaviour: AssetTags: panel ActiveRuleName: EnableGroup Collectors: - - CollectPath: Assets/YooAsset/Samples/Basic Sample/GameRes/Texture + - CollectPath: Assets/Samples/Basic Sample/GameRes/Texture CollectorGUID: 69b046f60ca75f647b2963e0113fd779 CollectorType: 0 AddressRuleName: AddressByFileName PackRuleName: PackCollector FilterRuleName: CollectAll AssetTags: - - CollectPath: Assets/YooAsset/Samples/Basic Sample/GameRes/TpAtlas + - CollectPath: Assets/Samples/Basic Sample/GameRes/TpAtlas CollectorGUID: 06e38aac2570d2b4a97c6a90223e5344 CollectorType: 0 AddressRuleName: AddressByFileName PackRuleName: PackDirectory FilterRuleName: CollectAll AssetTags: - - CollectPath: Assets/YooAsset/Samples/Basic Sample/GameRes/UIPanel + - CollectPath: Assets/Samples/Basic Sample/GameRes/UIPanel CollectorGUID: 926d3203fcefdb947881a7491496e039 CollectorType: 0 AddressRuleName: AddressByFileName PackRuleName: PackDirectory FilterRuleName: CollectAll AssetTags: - - CollectPath: Assets/YooAsset/Samples/Basic Sample/GameRes/UISprite + - CollectPath: Assets/Samples/Basic Sample/GameRes/UISprite CollectorGUID: 29f27e4abf667c04b88a3996d8cdadfc CollectorType: 0 AddressRuleName: AddressByFileName @@ -101,14 +101,14 @@ MonoBehaviour: AssetTags: ActiveRuleName: EnableGroup Collectors: - - CollectPath: Assets/YooAsset/Samples/Basic Sample/GameArt/ShaderVariants + - CollectPath: Assets/Samples/Basic Sample/GameArt/ShaderVariants CollectorGUID: 00781758c26692e40a9634ddeac838be CollectorType: 1 AddressRuleName: AddressByFileName PackRuleName: PackShaderVariants FilterRuleName: CollectAll AssetTags: - - CollectPath: Assets/YooAsset/Samples/Basic Sample/GameArt/UIFont + - CollectPath: Assets/Samples/Basic Sample/GameArt/UIFont CollectorGUID: 464727a15e4a7dc4d895346374432399 CollectorType: 2 AddressRuleName: AddressByFileName