mirror of https://github.com/tuyoogame/YooAsset
parent
5a850aef07
commit
8803003cf7
|
@ -156,14 +156,14 @@ namespace YooAsset
|
||||||
YooLogger.Warning($"Invalid parameter : {name}");
|
YooLogger.Warning($"Invalid parameter : {name}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public virtual void OnCreate(string packageName, string rootDirectory)
|
public virtual void OnCreate(string packageName, string packageRoot)
|
||||||
{
|
{
|
||||||
PackageName = packageName;
|
PackageName = packageName;
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(rootDirectory))
|
if (string.IsNullOrEmpty(packageRoot))
|
||||||
rootDirectory = GetDefaultBuildinRoot();
|
_packageRoot = GetDefaultBuildinPackageRoot(packageName);
|
||||||
|
else
|
||||||
_packageRoot = PathUtility.Combine(rootDirectory, packageName);
|
_packageRoot = packageRoot;
|
||||||
|
|
||||||
// 创建解压文件系统
|
// 创建解压文件系统
|
||||||
var remoteServices = new DefaultUnpackRemoteServices(_packageRoot);
|
var remoteServices = new DefaultUnpackRemoteServices(_packageRoot);
|
||||||
|
@ -282,9 +282,10 @@ namespace YooAsset
|
||||||
}
|
}
|
||||||
|
|
||||||
#region 内部方法
|
#region 内部方法
|
||||||
protected string GetDefaultBuildinRoot()
|
protected string GetDefaultBuildinPackageRoot(string packageName)
|
||||||
{
|
{
|
||||||
return YooAssetSettingsData.GetYooMobileBuildinRoot();
|
string rootDirectory = YooAssetSettingsData.GetYooMobileBuildinRoot();
|
||||||
|
return PathUtility.Combine(rootDirectory, packageName);
|
||||||
}
|
}
|
||||||
public string GetBuildinFileLoadPath(PackageBundle bundle)
|
public string GetBuildinFileLoadPath(PackageBundle bundle)
|
||||||
{
|
{
|
||||||
|
|
|
@ -26,7 +26,8 @@ namespace YooAsset
|
||||||
DirectoryInfo rootDirectory = new DirectoryInfo(rootPath);
|
DirectoryInfo rootDirectory = new DirectoryInfo(rootPath);
|
||||||
if (rootDirectory.Exists == false)
|
if (rootDirectory.Exists == false)
|
||||||
{
|
{
|
||||||
throw new System.Exception($"Can not found StreamingAssets root directory : {rootPath}");
|
UnityEngine.Debug.LogWarning($"Can not found StreamingAssets root directory : {rootPath}");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 搜索所有Package目录
|
// 搜索所有Package目录
|
||||||
|
|
|
@ -73,8 +73,7 @@ namespace YooAsset
|
||||||
#if UNITY_EDITOR
|
#if UNITY_EDITOR
|
||||||
// 兼容性初始化
|
// 兼容性初始化
|
||||||
// 说明:内置文件系统在编辑器下运行时需要动态生成
|
// 说明:内置文件系统在编辑器下运行时需要动态生成
|
||||||
string buildinRoot = YooAssetSettingsData.GetYooEditorBuildinRoot();
|
string packageRoot = _fileSystem.FileRoot;
|
||||||
string packageRoot = PathUtility.Combine(buildinRoot, _fileSystem.PackageName);
|
|
||||||
DefaultBuildinFileSystemBuild.CreateBuildinCatalogFile(_fileSystem.PackageName, packageRoot);
|
DefaultBuildinFileSystemBuild.CreateBuildinCatalogFile(_fileSystem.PackageName, packageRoot);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -208,14 +208,15 @@ namespace YooAsset
|
||||||
YooLogger.Warning($"Invalid parameter : {name}");
|
YooLogger.Warning($"Invalid parameter : {name}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public virtual void OnCreate(string packageName, string rootDirectory)
|
public virtual void OnCreate(string packageName, string packageRoot)
|
||||||
{
|
{
|
||||||
PackageName = packageName;
|
PackageName = packageName;
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(rootDirectory))
|
if (string.IsNullOrEmpty(packageRoot))
|
||||||
rootDirectory = GetDefaultCacheRoot();
|
_packageRoot = GetDefaultCachePackageRoot(packageName);
|
||||||
|
else
|
||||||
|
_packageRoot = packageRoot;
|
||||||
|
|
||||||
_packageRoot = PathUtility.Combine(rootDirectory, packageName);
|
|
||||||
_cacheFileRoot = PathUtility.Combine(_packageRoot, DefaultCacheFileSystemDefine.SaveFilesFolderName);
|
_cacheFileRoot = PathUtility.Combine(_packageRoot, DefaultCacheFileSystemDefine.SaveFilesFolderName);
|
||||||
_tempFileRoot = PathUtility.Combine(_packageRoot, DefaultCacheFileSystemDefine.TempFilesFolderName);
|
_tempFileRoot = PathUtility.Combine(_packageRoot, DefaultCacheFileSystemDefine.TempFilesFolderName);
|
||||||
_manifestFileRoot = PathUtility.Combine(_packageRoot, DefaultCacheFileSystemDefine.ManifestFilesFolderName);
|
_manifestFileRoot = PathUtility.Combine(_packageRoot, DefaultCacheFileSystemDefine.ManifestFilesFolderName);
|
||||||
|
@ -462,15 +463,19 @@ namespace YooAsset
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region 内部方法
|
#region 内部方法
|
||||||
public string GetDefaultCacheRoot()
|
public string GetDefaultCachePackageRoot(string packageName)
|
||||||
{
|
{
|
||||||
|
string rootDirectory;
|
||||||
|
|
||||||
#if UNITY_EDITOR
|
#if UNITY_EDITOR
|
||||||
return YooAssetSettingsData.GetYooEditorCacheRoot();
|
rootDirectory = YooAssetSettingsData.GetYooEditorCacheRoot();
|
||||||
#elif UNITY_STANDALONE
|
#elif UNITY_STANDALONE
|
||||||
return YooAssetSettingsData.GetYooStandaloneCacheRoot();
|
rootDirectory = YooAssetSettingsData.GetYooStandaloneCacheRoot();
|
||||||
#else
|
#else
|
||||||
return YooAssetSettingsData.GetYooMobileCacheRoot();
|
rootDirectory = YooAssetSettingsData.GetYooMobileCacheRoot();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
return PathUtility.Combine(rootDirectory, packageName);
|
||||||
}
|
}
|
||||||
public string GetCacheFileLoadPath(PackageBundle bundle)
|
public string GetCacheFileLoadPath(PackageBundle bundle)
|
||||||
{
|
{
|
||||||
|
|
|
@ -111,15 +111,14 @@ namespace YooAsset
|
||||||
YooLogger.Warning($"Invalid parameter : {name}");
|
YooLogger.Warning($"Invalid parameter : {name}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public virtual void OnCreate(string packageName, string rootDirectory)
|
public virtual void OnCreate(string packageName, string packageRoot)
|
||||||
{
|
{
|
||||||
PackageName = packageName;
|
PackageName = packageName;
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(rootDirectory))
|
if (string.IsNullOrEmpty(packageRoot))
|
||||||
throw new Exception($"{nameof(DefaultEditorFileSystem)} root directory is null or empty !");
|
throw new Exception($"{nameof(DefaultEditorFileSystem)} root directory is null or empty !");
|
||||||
|
|
||||||
// 注意:基础目录即为包裹目录
|
_packageRoot = packageRoot;
|
||||||
_packageRoot = rootDirectory;
|
|
||||||
}
|
}
|
||||||
public virtual void OnUpdate()
|
public virtual void OnUpdate()
|
||||||
{
|
{
|
||||||
|
|
|
@ -113,7 +113,7 @@ namespace YooAsset
|
||||||
YooLogger.Warning($"Invalid parameter : {name}");
|
YooLogger.Warning($"Invalid parameter : {name}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public virtual void OnCreate(string packageName, string rootDirectory)
|
public virtual void OnCreate(string packageName, string packageRoot)
|
||||||
{
|
{
|
||||||
PackageName = packageName;
|
PackageName = packageName;
|
||||||
}
|
}
|
||||||
|
|
|
@ -118,14 +118,14 @@ namespace YooAsset
|
||||||
YooLogger.Warning($"Invalid parameter : {name}");
|
YooLogger.Warning($"Invalid parameter : {name}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public virtual void OnCreate(string packageName, string rootDirectory)
|
public virtual void OnCreate(string packageName, string packageRoot)
|
||||||
{
|
{
|
||||||
PackageName = packageName;
|
PackageName = packageName;
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(rootDirectory))
|
if (string.IsNullOrEmpty(packageRoot))
|
||||||
rootDirectory = GetDefaultWebRoot();
|
_webPackageRoot = GetDefaultWebPackageRoot(packageName);
|
||||||
|
else
|
||||||
_webPackageRoot = PathUtility.Combine(rootDirectory, packageName);
|
_webPackageRoot = packageRoot;
|
||||||
}
|
}
|
||||||
public virtual void OnUpdate()
|
public virtual void OnUpdate()
|
||||||
{
|
{
|
||||||
|
@ -166,9 +166,10 @@ namespace YooAsset
|
||||||
}
|
}
|
||||||
|
|
||||||
#region 内部方法
|
#region 内部方法
|
||||||
protected string GetDefaultWebRoot()
|
protected string GetDefaultWebPackageRoot(string packageName)
|
||||||
{
|
{
|
||||||
return YooAssetSettingsData.GetYooWebBuildinRoot();
|
string rootDirectory = YooAssetSettingsData.GetYooWebBuildinRoot();
|
||||||
|
return PathUtility.Combine(rootDirectory, packageName);
|
||||||
}
|
}
|
||||||
public string GetWebFileLoadPath(PackageBundle bundle)
|
public string GetWebFileLoadPath(PackageBundle bundle)
|
||||||
{
|
{
|
||||||
|
|
|
@ -20,13 +20,13 @@ namespace YooAsset
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 文件系统的根目录
|
/// 文件系统的根目录
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string RootDirectory { private set; get; }
|
public string PackageRoot { private set; get; }
|
||||||
|
|
||||||
|
|
||||||
public FileSystemParameters(string fileSystemClass, string rootDirectory)
|
public FileSystemParameters(string fileSystemClass, string packageRoot)
|
||||||
{
|
{
|
||||||
FileSystemClass = fileSystemClass;
|
FileSystemClass = fileSystemClass;
|
||||||
RootDirectory = rootDirectory;
|
PackageRoot = packageRoot;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -62,7 +62,7 @@ namespace YooAsset
|
||||||
{
|
{
|
||||||
instance.SetParameter(param.Key, param.Value);
|
instance.SetParameter(param.Key, param.Value);
|
||||||
}
|
}
|
||||||
instance.OnCreate(packageName, RootDirectory);
|
instance.OnCreate(packageName, PackageRoot);
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,14 +82,12 @@ namespace YooAsset
|
||||||
/// 创建默认的内置文件系统参数
|
/// 创建默认的内置文件系统参数
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="decryptionServices">加密文件解密服务类</param>
|
/// <param name="decryptionServices">加密文件解密服务类</param>
|
||||||
/// <param name="verifyLevel">缓存文件的校验等级</param>
|
/// <param name="packageRoot">内置文件的根路径</param>
|
||||||
/// <param name="rootDirectory">内置文件的根路径</param>
|
public static FileSystemParameters CreateDefaultBuildinFileSystemParameters(IDecryptionServices decryptionServices = null, string packageRoot = null)
|
||||||
public static FileSystemParameters CreateDefaultBuildinFileSystemParameters(IDecryptionServices decryptionServices = null, EFileVerifyLevel verifyLevel = EFileVerifyLevel.Middle, string rootDirectory = null)
|
|
||||||
{
|
{
|
||||||
string fileSystemClass = typeof(DefaultBuildinFileSystem).FullName;
|
string fileSystemClass = typeof(DefaultBuildinFileSystem).FullName;
|
||||||
var fileSystemParams = new FileSystemParameters(fileSystemClass, rootDirectory);
|
var fileSystemParams = new FileSystemParameters(fileSystemClass, packageRoot);
|
||||||
fileSystemParams.AddParameter(FileSystemParametersDefine.DECRYPTION_SERVICES, decryptionServices);
|
fileSystemParams.AddParameter(FileSystemParametersDefine.DECRYPTION_SERVICES, decryptionServices);
|
||||||
fileSystemParams.AddParameter(FileSystemParametersDefine.FILE_VERIFY_LEVEL, verifyLevel);
|
|
||||||
return fileSystemParams;
|
return fileSystemParams;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,15 +96,13 @@ namespace YooAsset
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="remoteServices">远端资源地址查询服务类</param>
|
/// <param name="remoteServices">远端资源地址查询服务类</param>
|
||||||
/// <param name="decryptionServices">加密文件解密服务类</param>
|
/// <param name="decryptionServices">加密文件解密服务类</param>
|
||||||
/// <param name="verifyLevel">缓存文件的校验等级</param>
|
/// <param name="packageRoot">文件系统的根目录</param>
|
||||||
/// <param name="rootDirectory">文件系统的根目录</param>
|
public static FileSystemParameters CreateDefaultCacheFileSystemParameters(IRemoteServices remoteServices, IDecryptionServices decryptionServices = null, string packageRoot = null)
|
||||||
public static FileSystemParameters CreateDefaultCacheFileSystemParameters(IRemoteServices remoteServices, IDecryptionServices decryptionServices = null, EFileVerifyLevel verifyLevel = EFileVerifyLevel.Middle, string rootDirectory = null)
|
|
||||||
{
|
{
|
||||||
string fileSystemClass = typeof(DefaultCacheFileSystem).FullName;
|
string fileSystemClass = typeof(DefaultCacheFileSystem).FullName;
|
||||||
var fileSystemParams = new FileSystemParameters(fileSystemClass, rootDirectory);
|
var fileSystemParams = new FileSystemParameters(fileSystemClass, packageRoot);
|
||||||
fileSystemParams.AddParameter(FileSystemParametersDefine.REMOTE_SERVICES, remoteServices);
|
fileSystemParams.AddParameter(FileSystemParametersDefine.REMOTE_SERVICES, remoteServices);
|
||||||
fileSystemParams.AddParameter(FileSystemParametersDefine.DECRYPTION_SERVICES, decryptionServices);
|
fileSystemParams.AddParameter(FileSystemParametersDefine.DECRYPTION_SERVICES, decryptionServices);
|
||||||
fileSystemParams.AddParameter(FileSystemParametersDefine.FILE_VERIFY_LEVEL, verifyLevel);
|
|
||||||
return fileSystemParams;
|
return fileSystemParams;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -54,11 +54,11 @@ namespace YooAsset
|
||||||
/// 设置自定义参数
|
/// 设置自定义参数
|
||||||
/// </summary>
|
/// </summary>
|
||||||
void SetParameter(string name, object value);
|
void SetParameter(string name, object value);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 创建缓存系统
|
/// 创建缓存系统
|
||||||
/// </summary>
|
/// </summary>
|
||||||
void OnCreate(string packageName, string rootDirectory);
|
void OnCreate(string packageName, string packageRoot);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 更新文件系统
|
/// 更新文件系统
|
||||||
|
|
Loading…
Reference in New Issue