From 69c7a51215c385ed2b87640e0b99f92eacee9978 Mon Sep 17 00:00:00 2001 From: hevinci Date: Fri, 17 Feb 2023 18:43:39 +0800 Subject: [PATCH] update runtime logic --- .../Runtime/PatchSystem/PatchBundle.cs | 19 +++++++++++-- .../Runtime/PatchSystem/PatchManifestTools.cs | 16 +++++------ .../Runtime/Settings/YooAssetSettings.cs | 28 +------------------ .../Runtime/Settings/YooAssetSettingsData.cs | 13 --------- 4 files changed, 26 insertions(+), 50 deletions(-) diff --git a/Assets/YooAsset/Runtime/PatchSystem/PatchBundle.cs b/Assets/YooAsset/Runtime/PatchSystem/PatchBundle.cs index fb017fe..7e5e018 100644 --- a/Assets/YooAsset/Runtime/PatchSystem/PatchBundle.cs +++ b/Assets/YooAsset/Runtime/PatchSystem/PatchBundle.cs @@ -122,7 +122,7 @@ namespace YooAsset } /// - /// 文件名称(远端文件名和内置文件名) + /// 文件名称 /// private string _fileName; public string FileName @@ -135,6 +135,20 @@ namespace YooAsset } } + /// + /// 文件后缀名 + /// + private string _fileExtension; + public string FileExtension + { + get + { + if (string.IsNullOrEmpty(_fileExtension)) + throw new Exception("Should never get here !"); + return _fileExtension; + } + } + public PatchBundle() { @@ -146,7 +160,8 @@ namespace YooAsset public void ParseBundle(string packageName, int nameStype) { PackageName = packageName; - _fileName = PatchManifestTools.CreateBundleFileName(nameStype, BundleName, FileHash, IsRawFile); + _fileExtension = PatchManifestTools.GetRemoteBundleFileExtension(BundleName); + _fileName = PatchManifestTools.GetRemoteBundleFileName(nameStype, BundleName, _fileExtension, FileHash); } /// diff --git a/Assets/YooAsset/Runtime/PatchSystem/PatchManifestTools.cs b/Assets/YooAsset/Runtime/PatchSystem/PatchManifestTools.cs index 3ca72ec..10d93e7 100644 --- a/Assets/YooAsset/Runtime/PatchSystem/PatchManifestTools.cs +++ b/Assets/YooAsset/Runtime/PatchSystem/PatchManifestTools.cs @@ -155,21 +155,21 @@ namespace YooAsset } #endif - /// - /// 生成Bundle文件的正式名称 - /// - public static string CreateBundleFileName(int nameStyle, string bundleName, string fileHash, bool isRawFile) + public static string GetRemoteBundleFileExtension(string bundleName) + { + string fileExtension = Path.GetExtension(bundleName); + return fileExtension; + } + public static string GetRemoteBundleFileName(int nameStyle, string bundleName, string fileExtension, string fileHash) { if (nameStyle == 1) //HashName { - string fileExtension = isRawFile ? YooAssetSettingsData.Setting.RawBundleFileVariant : YooAssetSettingsData.Setting.AssetBundleFileVariant; - return StringUtility.Format("{0}.{1}", fileHash, fileExtension); + return StringUtility.Format("{0}{1}", fileHash, fileExtension); } else if (nameStyle == 4) //BundleName_HashName { string fileName = bundleName.Remove(bundleName.LastIndexOf('.')); - string fileExtension = isRawFile ? YooAssetSettingsData.Setting.RawBundleFileVariant : YooAssetSettingsData.Setting.AssetBundleFileVariant; - return StringUtility.Format("{0}_{1}.{2}", fileName, fileHash, fileExtension); + return StringUtility.Format("{0}_{1}{2}", fileName, fileHash, fileExtension); } else { diff --git a/Assets/YooAsset/Runtime/Settings/YooAssetSettings.cs b/Assets/YooAsset/Runtime/Settings/YooAssetSettings.cs index 3dbcdb1..dac7ac6 100644 --- a/Assets/YooAsset/Runtime/Settings/YooAssetSettings.cs +++ b/Assets/YooAsset/Runtime/Settings/YooAssetSettings.cs @@ -5,26 +5,11 @@ namespace YooAsset [CreateAssetMenu(fileName = "YooAssetSettings", menuName = "YooAsset/Create Settings")] internal class YooAssetSettings : ScriptableObject { - /// - /// AssetBundle文件的后缀名 - /// - public string AssetBundleFileVariant = "bundle"; - - /// - /// 原生文件的后缀名 - /// - public string RawBundleFileVariant = "rawfile"; - /// /// 清单文件名称 /// public string PatchManifestFileName = "PatchManifest"; - /// - /// 资源包名正规化(移除路径分隔符) - /// - public bool RegularBundleName = true; - /// /// 清单文件头标记 @@ -41,7 +26,7 @@ namespace YooAsset /// public const string PatchManifestFileVersion = "1.4.0"; - + /// /// 缓存的数据文件名称 /// @@ -63,20 +48,9 @@ namespace YooAsset /// public const string ReportFileName = "BuildReport"; - /// - /// Unity着色器资源包名称 - /// - public const string UnityShadersBundleName = "unityshaders"; - /// /// 内置资源目录名称 /// public const string StreamingAssetsBuildinFolder = "BuildinFiles"; - - - /// - /// 忽略的文件类型 - /// - public static readonly string[] IgnoreFileExtensions = { "", ".so", ".dll", ".cs", ".js", ".boo", ".meta", ".cginc", ".hlsl" }; } } \ No newline at end of file diff --git a/Assets/YooAsset/Runtime/Settings/YooAssetSettingsData.cs b/Assets/YooAsset/Runtime/Settings/YooAssetSettingsData.cs index 05cbf2a..f30b5b9 100644 --- a/Assets/YooAsset/Runtime/Settings/YooAssetSettingsData.cs +++ b/Assets/YooAsset/Runtime/Settings/YooAssetSettingsData.cs @@ -71,18 +71,5 @@ namespace YooAsset { return $"{Setting.PatchManifestFileName}_{packageName}.version"; } - - /// - /// 获取着色器资源包全名称(包含后缀名) - /// - public static string GetUnityShadersBundleFullName(bool uniqueBundleName, string packageName) - { - string shareBundleName; - if (uniqueBundleName) - shareBundleName = $"{packageName.ToLower()}_{YooAssetSettings.UnityShadersBundleName}.{Setting.AssetBundleFileVariant}"; - else - shareBundleName = $"{YooAssetSettings.UnityShadersBundleName}.{Setting.AssetBundleFileVariant}"; - return shareBundleName.ToLower(); - } } } \ No newline at end of file