From ca89fb3c23f76d5205220b401bdb070d84ca3213 Mon Sep 17 00:00:00 2001 From: hevinci Date: Wed, 5 Jul 2023 14:56:18 +0800 Subject: [PATCH] update runtime code MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. 新增了ResourcePackage.GetPackageBuildinRootDirectory()方法 2. 新增了ResourcePackage.GetPackageSandboxRootDirectory()方法 3. 新增了ResourcePackage.ClearPackageSandbox()方法 --- .../Runtime/PackageSystem/ResourcePackage.cs | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/Assets/YooAsset/Runtime/PackageSystem/ResourcePackage.cs b/Assets/YooAsset/Runtime/PackageSystem/ResourcePackage.cs index a05d1db..e905ad4 100644 --- a/Assets/YooAsset/Runtime/PackageSystem/ResourcePackage.cs +++ b/Assets/YooAsset/Runtime/PackageSystem/ResourcePackage.cs @@ -79,6 +79,10 @@ namespace YooAsset // 检测初始化参数合法性 CheckInitializeParameters(parameters); + // 重写持久化根目录 + var persistent = PersistentTools.GetOrCreatePersistent(PackageName); + persistent.OverwriteRootDirectory(parameters.BuildinRootDirectory, parameters.SandboxRootDirectory); + // 初始化资源系统 InitializationOperation initializeOperation; _assetSystemImpl = new AssetSystemImpl(); @@ -291,6 +295,37 @@ namespace YooAsset _assetSystemImpl.ForceUnloadAllAssets(); } + #region 沙盒相关 + /// + /// 获取包裹的内置文件根路径 + /// + public string GetPackageBuildinRootDirectory() + { + DebugCheckInitialize(); + var persistent = PersistentTools.GetPersistent(PackageName); + return persistent.BuildinRoot; + } + + /// + /// 获取包裹的沙盒文件根路径 + /// + public string GetPackageSandboxRootDirectory() + { + DebugCheckInitialize(); + var persistent = PersistentTools.GetPersistent(PackageName); + return persistent.SandboxRoot; + } + + /// + /// 清空包裹的沙盒目录 + /// + public void ClearPackageSandbox() + { + DebugCheckInitialize(); + var persistent = PersistentTools.GetPersistent(PackageName); + persistent.DeleteSandboxPackageFolder(); + } + #endregion #region 资源信息 ///