mirror of https://github.com/tuyoogame/YooAsset
parent
3a81d7babd
commit
45ca1ebf02
|
@ -1,6 +1,5 @@
|
||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Text;
|
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
@ -407,10 +406,6 @@ namespace YooAsset
|
||||||
return manifest;
|
return manifest;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
[ThreadStatic]
|
|
||||||
private static StringBuilder _cacheBuilder = new StringBuilder(1024);
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 生成Bundle文件的正式名称
|
/// 生成Bundle文件的正式名称
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -422,22 +417,12 @@ namespace YooAsset
|
||||||
}
|
}
|
||||||
else if (nameStype == 2)
|
else if (nameStype == 2)
|
||||||
{
|
{
|
||||||
_cacheBuilder.Clear();
|
string fileExtension = isRawFile ? YooAssetSettingsData.Setting.RawFileVariant : YooAssetSettingsData.Setting.AssetBundleFileVariant;
|
||||||
_cacheBuilder.Append(fileHash);
|
return StringUtility.Format("{0}.{1}", fileHash, fileExtension);
|
||||||
_cacheBuilder.Append(".");
|
|
||||||
if (isRawFile)
|
|
||||||
_cacheBuilder.Append(YooAssetSettingsData.Setting.RawFileVariant);
|
|
||||||
else
|
|
||||||
_cacheBuilder.Append(YooAssetSettingsData.Setting.AssetBundleFileVariant);
|
|
||||||
return _cacheBuilder.ToString();
|
|
||||||
}
|
}
|
||||||
else if (nameStype == 4)
|
else if (nameStype == 4)
|
||||||
{
|
{
|
||||||
_cacheBuilder.Clear();
|
return StringUtility.Format("{0}_{1}", fileHash, bundleName);
|
||||||
_cacheBuilder.Append(fileHash);
|
|
||||||
_cacheBuilder.Append("_");
|
|
||||||
_cacheBuilder.Append(bundleName);
|
|
||||||
return _cacheBuilder.ToString();
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -8,29 +8,19 @@ namespace YooAsset
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal static class PathHelper
|
internal static class PathHelper
|
||||||
{
|
{
|
||||||
/// <summary>
|
private static string _buildinPath;
|
||||||
/// 获取规范化的路径
|
private static string _sandboxPath;
|
||||||
/// </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);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取基于流文件夹的加载路径
|
/// 获取基于流文件夹的加载路径
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static string MakeStreamingLoadPath(string path)
|
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>
|
/// <summary>
|
||||||
|
@ -38,23 +28,36 @@ namespace YooAsset
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static string MakePersistentLoadPath(string path)
|
public static string MakePersistentLoadPath(string path)
|
||||||
{
|
{
|
||||||
string root = MakePersistentRootPath();
|
string root = GetPersistentRootPath();
|
||||||
return StringUtility.Format("{0}/{1}", root, path);
|
return StringUtility.Format("{0}/{1}", root, path);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取沙盒文件夹路径
|
/// 获取沙盒文件夹路径
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static string MakePersistentRootPath()
|
public static string GetPersistentRootPath()
|
||||||
{
|
{
|
||||||
#if UNITY_EDITOR
|
#if UNITY_EDITOR
|
||||||
// 注意:为了方便调试查看,编辑器下把存储目录放到项目里
|
// 注意:为了方便调试查看,编辑器下把存储目录放到项目里
|
||||||
string projectPath = GetDirectory(UnityEngine.Application.dataPath);
|
if (string.IsNullOrEmpty(_sandboxPath))
|
||||||
return StringUtility.Format("{0}/Sandbox", projectPath);
|
{
|
||||||
|
string directory = Path.GetDirectoryName(UnityEngine.Application.dataPath);
|
||||||
|
string projectPath = GetRegularPath(directory);
|
||||||
|
_sandboxPath = StringUtility.Format("{0}/Sandbox", projectPath);
|
||||||
|
}
|
||||||
|
return _sandboxPath;
|
||||||
#else
|
#else
|
||||||
return StringUtility.Format("{0}/Sandbox", UnityEngine.Application.persistentDataPath);
|
if (string.IsNullOrEmpty(_sandboxPath))
|
||||||
|
{
|
||||||
|
_sandboxPath = StringUtility.Format("{0}/Sandbox", UnityEngine.Application.persistentDataPath);
|
||||||
|
}
|
||||||
|
return _sandboxPath;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
private static string GetRegularPath(string path)
|
||||||
|
{
|
||||||
|
return path.Replace('\\', '/').Replace("\\", "/"); //替换为Linux路径格式
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取WWW加载本地资源的路径
|
/// 获取WWW加载本地资源的路径
|
||||||
|
|
|
@ -55,37 +55,6 @@ namespace YooAsset
|
||||||
return _cacheBuilder.ToString();
|
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)
|
public static string RemoveFirstChar(string str)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(str))
|
if (string.IsNullOrEmpty(str))
|
||||||
|
|
|
@ -220,7 +220,7 @@ namespace YooAsset
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static string GetSandboxRoot()
|
public static string GetSandboxRoot()
|
||||||
{
|
{
|
||||||
return PathHelper.MakePersistentRootPath();
|
return PathHelper.GetPersistentRootPath();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
Loading…
Reference in New Issue