mirror of https://github.com/tuyoogame/YooAsset
parent
3a81d7babd
commit
45ca1ebf02
|
@ -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);
|
||||
|
||||
/// <summary>
|
||||
/// 生成Bundle文件的正式名称
|
||||
/// </summary>
|
||||
|
@ -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
|
||||
{
|
||||
|
|
|
@ -8,29 +8,19 @@ namespace YooAsset
|
|||
/// </summary>
|
||||
internal static class PathHelper
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取规范化的路径
|
||||
/// </summary>
|
||||
public static string GetRegularPath(string path)
|
||||
{
|
||||
return path.Replace('\\', '/').Replace("\\", "/"); //替换为Linux路径格式
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取文件所在的目录路径(Linux格式)
|
||||
/// </summary>
|
||||
public static string GetDirectory(string filePath)
|
||||
{
|
||||
string directory = Path.GetDirectoryName(filePath);
|
||||
return GetRegularPath(directory);
|
||||
}
|
||||
private static string _buildinPath;
|
||||
private static string _sandboxPath;
|
||||
|
||||
/// <summary>
|
||||
/// 获取基于流文件夹的加载路径
|
||||
/// </summary>
|
||||
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);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -38,23 +28,36 @@ namespace YooAsset
|
|||
/// </summary>
|
||||
public static string MakePersistentLoadPath(string path)
|
||||
{
|
||||
string root = MakePersistentRootPath();
|
||||
string root = GetPersistentRootPath();
|
||||
return StringUtility.Format("{0}/{1}", root, path);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取沙盒文件夹路径
|
||||
/// </summary>
|
||||
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路径格式
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取WWW加载本地资源的路径
|
||||
|
|
|
@ -55,37 +55,6 @@ namespace YooAsset
|
|||
return _cacheBuilder.ToString();
|
||||
}
|
||||
|
||||
public static List<string> StringToStringList(string str, char separator)
|
||||
{
|
||||
List<string> result = new List<string>();
|
||||
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<T>(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))
|
||||
|
|
|
@ -220,7 +220,7 @@ namespace YooAsset
|
|||
/// </summary>
|
||||
public static string GetSandboxRoot()
|
||||
{
|
||||
return PathHelper.MakePersistentRootPath();
|
||||
return PathHelper.GetPersistentRootPath();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
Loading…
Reference in New Issue