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