diff --git a/Assets/YooAsset/Runtime/PatchSystem/PatchManifest.cs b/Assets/YooAsset/Runtime/PatchSystem/PatchManifest.cs
index 0a0c1ae..52f561e 100644
--- a/Assets/YooAsset/Runtime/PatchSystem/PatchManifest.cs
+++ b/Assets/YooAsset/Runtime/PatchSystem/PatchManifest.cs
@@ -1,6 +1,5 @@
using System;
using System.IO;
-using System.Text;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
@@ -407,10 +406,6 @@ namespace YooAsset
return manifest;
}
-
- [ThreadStatic]
- private static StringBuilder _cacheBuilder = new StringBuilder(1024);
-
///
/// 生成Bundle文件的正式名称
///
@@ -422,22 +417,12 @@ namespace YooAsset
}
else if (nameStype == 2)
{
- _cacheBuilder.Clear();
- _cacheBuilder.Append(fileHash);
- _cacheBuilder.Append(".");
- if (isRawFile)
- _cacheBuilder.Append(YooAssetSettingsData.Setting.RawFileVariant);
- else
- _cacheBuilder.Append(YooAssetSettingsData.Setting.AssetBundleFileVariant);
- return _cacheBuilder.ToString();
+ string fileExtension = isRawFile ? YooAssetSettingsData.Setting.RawFileVariant : YooAssetSettingsData.Setting.AssetBundleFileVariant;
+ return StringUtility.Format("{0}.{1}", fileHash, fileExtension);
}
else if (nameStype == 4)
{
- _cacheBuilder.Clear();
- _cacheBuilder.Append(fileHash);
- _cacheBuilder.Append("_");
- _cacheBuilder.Append(bundleName);
- return _cacheBuilder.ToString();
+ return StringUtility.Format("{0}_{1}", fileHash, bundleName);
}
else
{
diff --git a/Assets/YooAsset/Runtime/Utility/YooHelper.cs b/Assets/YooAsset/Runtime/Utility/YooHelper.cs
index 4c53320..f7d7027 100644
--- a/Assets/YooAsset/Runtime/Utility/YooHelper.cs
+++ b/Assets/YooAsset/Runtime/Utility/YooHelper.cs
@@ -8,29 +8,19 @@ namespace YooAsset
///
internal static class PathHelper
{
- ///
- /// 获取规范化的路径
- ///
- public static string GetRegularPath(string path)
- {
- return path.Replace('\\', '/').Replace("\\", "/"); //替换为Linux路径格式
- }
-
- ///
- /// 获取文件所在的目录路径(Linux格式)
- ///
- public static string GetDirectory(string filePath)
- {
- string directory = Path.GetDirectoryName(filePath);
- return GetRegularPath(directory);
- }
+ private static string _buildinPath;
+ private static string _sandboxPath;
///
/// 获取基于流文件夹的加载路径
///
public static string MakeStreamingLoadPath(string path)
{
- return StringUtility.Format("{0}/{1}/{2}", UnityEngine.Application.streamingAssetsPath, YooAssetSettings.StreamingAssetsBuildinFolder, path);
+ if (string.IsNullOrEmpty(_buildinPath))
+ {
+ _buildinPath = StringUtility.Format("{0}/{1}", UnityEngine.Application.streamingAssetsPath, YooAssetSettings.StreamingAssetsBuildinFolder);
+ }
+ return StringUtility.Format("{0}/{1}", _buildinPath, path);
}
///
@@ -38,23 +28,36 @@ namespace YooAsset
///
public static string MakePersistentLoadPath(string path)
{
- string root = MakePersistentRootPath();
+ string root = GetPersistentRootPath();
return StringUtility.Format("{0}/{1}", root, path);
}
///
/// 获取沙盒文件夹路径
///
- public static string MakePersistentRootPath()
+ public static string GetPersistentRootPath()
{
#if UNITY_EDITOR
// 注意:为了方便调试查看,编辑器下把存储目录放到项目里
- string projectPath = GetDirectory(UnityEngine.Application.dataPath);
- return StringUtility.Format("{0}/Sandbox", projectPath);
+ if (string.IsNullOrEmpty(_sandboxPath))
+ {
+ string directory = Path.GetDirectoryName(UnityEngine.Application.dataPath);
+ string projectPath = GetRegularPath(directory);
+ _sandboxPath = StringUtility.Format("{0}/Sandbox", projectPath);
+ }
+ return _sandboxPath;
#else
- return StringUtility.Format("{0}/Sandbox", UnityEngine.Application.persistentDataPath);
+ if (string.IsNullOrEmpty(_sandboxPath))
+ {
+ _sandboxPath = StringUtility.Format("{0}/Sandbox", UnityEngine.Application.persistentDataPath);
+ }
+ return _sandboxPath;
#endif
}
+ private static string GetRegularPath(string path)
+ {
+ return path.Replace('\\', '/').Replace("\\", "/"); //替换为Linux路径格式
+ }
///
/// 获取WWW加载本地资源的路径
diff --git a/Assets/YooAsset/Runtime/Utility/YooUtility.cs b/Assets/YooAsset/Runtime/Utility/YooUtility.cs
index 36e5a7d..45a5b56 100644
--- a/Assets/YooAsset/Runtime/Utility/YooUtility.cs
+++ b/Assets/YooAsset/Runtime/Utility/YooUtility.cs
@@ -55,37 +55,6 @@ namespace YooAsset
return _cacheBuilder.ToString();
}
- public static List StringToStringList(string str, char separator)
- {
- List result = new List();
- if (!String.IsNullOrEmpty(str))
- {
- string[] splits = str.Split(separator);
- foreach (string split in splits)
- {
- string value = split.Trim(); //移除首尾空格
- if (!String.IsNullOrEmpty(value))
- {
- result.Add(value);
- }
- }
- }
- return result;
- }
- public static bool StringToBool(string str)
- {
- int value = (int)Convert.ChangeType(str, typeof(int));
- return value > 0;
- }
- public static T NameToEnum(string name)
- {
- if (Enum.IsDefined(typeof(T), name) == false)
- {
- throw new ArgumentException($"Enum {typeof(T)} is not defined name {name}");
- }
- return (T)Enum.Parse(typeof(T), name);
- }
-
public static string RemoveFirstChar(string str)
{
if (string.IsNullOrEmpty(str))
diff --git a/Assets/YooAsset/Runtime/YooAssets.cs b/Assets/YooAsset/Runtime/YooAssets.cs
index 4eb96f9..4fce4f6 100644
--- a/Assets/YooAsset/Runtime/YooAssets.cs
+++ b/Assets/YooAsset/Runtime/YooAssets.cs
@@ -220,7 +220,7 @@ namespace YooAsset
///
public static string GetSandboxRoot()
{
- return PathHelper.MakePersistentRootPath();
+ return PathHelper.GetPersistentRootPath();
}
///