mirror of https://github.com/tuyoogame/YooAsset
Compare commits
6 Commits
1e88bad73e
...
a7d9a4ecbc
Author | SHA1 | Date |
---|---|---|
|
a7d9a4ecbc | |
|
2643ab81ed | |
|
c5314c72f0 | |
|
fbb48ba330 | |
|
4e6879e34f | |
|
09c3d4e479 |
|
@ -25,19 +25,6 @@ namespace YooAsset.Editor
|
||||||
if (buildPipeline.Count == 0)
|
if (buildPipeline.Count == 0)
|
||||||
throw new Exception($"Build pipeline is empty !");
|
throw new Exception($"Build pipeline is empty !");
|
||||||
|
|
||||||
// 检测可编程构建管线参数
|
|
||||||
if (buildParameters.BuildPipeline == EBuildPipeline.ScriptableBuildPipeline)
|
|
||||||
{
|
|
||||||
if (buildParameters.SBPParameters == null)
|
|
||||||
throw new Exception($"{nameof(BuildParameters.SBPParameters)} is null !");
|
|
||||||
|
|
||||||
if (buildParameters.BuildMode == EBuildMode.DryRunBuild)
|
|
||||||
throw new Exception($"{nameof(EBuildPipeline.ScriptableBuildPipeline)} not support {nameof(EBuildMode.DryRunBuild)} build mode !");
|
|
||||||
|
|
||||||
if (buildParameters.BuildMode == EBuildMode.ForceRebuild)
|
|
||||||
throw new Exception($"{nameof(EBuildPipeline.ScriptableBuildPipeline)} not support {nameof(EBuildMode.ForceRebuild)} build mode !");
|
|
||||||
}
|
|
||||||
|
|
||||||
// 清空旧数据
|
// 清空旧数据
|
||||||
_buildContext.ClearAllContext();
|
_buildContext.ClearAllContext();
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ namespace YooAsset.Editor
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取默认的输出根路录
|
/// 获取默认的输出根路录
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static string GetDefaultOutputRoot()
|
public static string GetDefaultBuildOutputRoot()
|
||||||
{
|
{
|
||||||
string projectPath = EditorTools.GetProjectPath();
|
string projectPath = EditorTools.GetProjectPath();
|
||||||
return $"{projectPath}/Bundles";
|
return $"{projectPath}/Bundles";
|
||||||
|
@ -20,43 +20,9 @@ namespace YooAsset.Editor
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取流文件夹路径
|
/// 获取流文件夹路径
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static string GetStreamingAssetsFolderPath()
|
public static string GetDefaultStreamingAssetsRoot()
|
||||||
{
|
{
|
||||||
return $"{Application.dataPath}/StreamingAssets/{YooAssetSettings.StreamingAssetsBuildinFolder}/";
|
return $"{Application.dataPath}/StreamingAssets/{YooAssetSettings.DefaultYooFolderName}/";
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 清空流文件夹
|
|
||||||
/// </summary>
|
|
||||||
public static void ClearStreamingAssetsFolder()
|
|
||||||
{
|
|
||||||
string streamingFolderPath = GetStreamingAssetsFolderPath();
|
|
||||||
EditorTools.ClearFolder(streamingFolderPath);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 删除流文件夹内无关的文件
|
|
||||||
/// 删除.manifest文件和.meta文件
|
|
||||||
/// </summary>
|
|
||||||
public static void DeleteStreamingAssetsIgnoreFiles()
|
|
||||||
{
|
|
||||||
string streamingFolderPath = GetStreamingAssetsFolderPath();
|
|
||||||
if (Directory.Exists(streamingFolderPath))
|
|
||||||
{
|
|
||||||
string[] files = Directory.GetFiles(streamingFolderPath, "*.manifest", SearchOption.AllDirectories);
|
|
||||||
foreach (var file in files)
|
|
||||||
{
|
|
||||||
FileInfo info = new FileInfo(file);
|
|
||||||
info.Delete();
|
|
||||||
}
|
|
||||||
|
|
||||||
files = Directory.GetFiles(streamingFolderPath, "*.meta", SearchOption.AllDirectories);
|
|
||||||
foreach (var item in files)
|
|
||||||
{
|
|
||||||
FileInfo info = new FileInfo(item);
|
|
||||||
info.Delete();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -63,7 +63,7 @@ namespace YooAsset.Editor
|
||||||
_encryptionServicesClassNames = _encryptionServicesClassTypes.Select(t => t.Name).ToList();
|
_encryptionServicesClassNames = _encryptionServicesClassTypes.Select(t => t.Name).ToList();
|
||||||
|
|
||||||
// 输出目录
|
// 输出目录
|
||||||
string defaultOutputRoot = AssetBundleBuilderHelper.GetDefaultOutputRoot();
|
string defaultOutputRoot = AssetBundleBuilderHelper.GetDefaultBuildOutputRoot();
|
||||||
_buildOutputField = root.Q<TextField>("BuildOutput");
|
_buildOutputField = root.Q<TextField>("BuildOutput");
|
||||||
_buildOutputField.SetValueWithoutNotify(defaultOutputRoot);
|
_buildOutputField.SetValueWithoutNotify(defaultOutputRoot);
|
||||||
_buildOutputField.SetEnabled(false);
|
_buildOutputField.SetEnabled(false);
|
||||||
|
@ -266,9 +266,9 @@ namespace YooAsset.Editor
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private void ExecuteBuild()
|
private void ExecuteBuild()
|
||||||
{
|
{
|
||||||
string defaultOutputRoot = AssetBundleBuilderHelper.GetDefaultOutputRoot();
|
|
||||||
BuildParameters buildParameters = new BuildParameters();
|
BuildParameters buildParameters = new BuildParameters();
|
||||||
buildParameters.OutputRoot = defaultOutputRoot;
|
buildParameters.StreamingAssetsRoot = AssetBundleBuilderHelper.GetDefaultStreamingAssetsRoot();
|
||||||
|
buildParameters.BuildOutputRoot = AssetBundleBuilderHelper.GetDefaultBuildOutputRoot();
|
||||||
buildParameters.BuildTarget = _buildTarget;
|
buildParameters.BuildTarget = _buildTarget;
|
||||||
buildParameters.BuildPipeline = AssetBundleBuilderSettingData.Setting.BuildPipeline;
|
buildParameters.BuildPipeline = AssetBundleBuilderSettingData.Setting.BuildPipeline;
|
||||||
buildParameters.BuildMode = AssetBundleBuilderSettingData.Setting.BuildMode;
|
buildParameters.BuildMode = AssetBundleBuilderSettingData.Setting.BuildMode;
|
||||||
|
|
|
@ -11,9 +11,9 @@ namespace YooAsset.Editor
|
||||||
public static string SimulateBuild(string packageName)
|
public static string SimulateBuild(string packageName)
|
||||||
{
|
{
|
||||||
Debug.Log($"Begin to create simulate package : {packageName}");
|
Debug.Log($"Begin to create simulate package : {packageName}");
|
||||||
string defaultOutputRoot = AssetBundleBuilderHelper.GetDefaultOutputRoot();
|
|
||||||
BuildParameters buildParameters = new BuildParameters();
|
BuildParameters buildParameters = new BuildParameters();
|
||||||
buildParameters.OutputRoot = defaultOutputRoot;
|
buildParameters.StreamingAssetsRoot = AssetBundleBuilderHelper.GetDefaultStreamingAssetsRoot();
|
||||||
|
buildParameters.BuildOutputRoot = AssetBundleBuilderHelper.GetDefaultBuildOutputRoot();
|
||||||
buildParameters.BuildTarget = EditorUserBuildSettings.activeBuildTarget;
|
buildParameters.BuildTarget = EditorUserBuildSettings.activeBuildTarget;
|
||||||
buildParameters.BuildMode = EBuildMode.SimulateBuild;
|
buildParameters.BuildMode = EBuildMode.SimulateBuild;
|
||||||
buildParameters.PackageName = packageName;
|
buildParameters.PackageName = packageName;
|
||||||
|
|
|
@ -37,9 +37,14 @@ namespace YooAsset.Editor
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 输出的根目录
|
/// 内置资源的根目录
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string OutputRoot;
|
public string StreamingAssetsRoot;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 构建输出的根目录
|
||||||
|
/// </summary>
|
||||||
|
public string BuildOutputRoot;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 构建的平台
|
/// 构建的平台
|
||||||
|
|
|
@ -9,6 +9,8 @@ namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
private string _pipelineOutputDirectory = string.Empty;
|
private string _pipelineOutputDirectory = string.Empty;
|
||||||
private string _packageOutputDirectory = string.Empty;
|
private string _packageOutputDirectory = string.Empty;
|
||||||
|
private string _packageRootDirectory = string.Empty;
|
||||||
|
private string _streamingAssetsDirectory = string.Empty;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 构建参数
|
/// 构建参数
|
||||||
|
@ -29,23 +31,47 @@ namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(_pipelineOutputDirectory))
|
if (string.IsNullOrEmpty(_pipelineOutputDirectory))
|
||||||
{
|
{
|
||||||
_pipelineOutputDirectory = $"{Parameters.OutputRoot}/{Parameters.BuildTarget}/{Parameters.PackageName}/{YooAssetSettings.OutputFolderName}";
|
_pipelineOutputDirectory = $"{Parameters.BuildOutputRoot}/{Parameters.BuildTarget}/{Parameters.PackageName}/{YooAssetSettings.OutputFolderName}";
|
||||||
}
|
}
|
||||||
return _pipelineOutputDirectory;
|
return _pipelineOutputDirectory;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取本次构建的补丁目录
|
/// 获取本次构建的补丁输出目录
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string GetPackageOutputDirectory()
|
public string GetPackageOutputDirectory()
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(_packageOutputDirectory))
|
if (string.IsNullOrEmpty(_packageOutputDirectory))
|
||||||
{
|
{
|
||||||
_packageOutputDirectory = $"{Parameters.OutputRoot}/{Parameters.BuildTarget}/{Parameters.PackageName}/{Parameters.PackageVersion}";
|
_packageOutputDirectory = $"{Parameters.BuildOutputRoot}/{Parameters.BuildTarget}/{Parameters.PackageName}/{Parameters.PackageVersion}";
|
||||||
}
|
}
|
||||||
return _packageOutputDirectory;
|
return _packageOutputDirectory;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取本次构建的补丁根目录
|
||||||
|
/// </summary>
|
||||||
|
public string GetPackageRootDirectory()
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(_packageRootDirectory))
|
||||||
|
{
|
||||||
|
_packageRootDirectory = $"{Parameters.BuildOutputRoot}/{Parameters.BuildTarget}/{Parameters.PackageName}";
|
||||||
|
}
|
||||||
|
return _packageRootDirectory;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取内置资源的目录
|
||||||
|
/// </summary>
|
||||||
|
public string GetStreamingAssetsDirectory()
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(_streamingAssetsDirectory))
|
||||||
|
{
|
||||||
|
_streamingAssetsDirectory = $"{Parameters.StreamingAssetsRoot}/{Parameters.PackageName}";
|
||||||
|
}
|
||||||
|
return _streamingAssetsDirectory;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取内置构建管线的构建选项
|
/// 获取内置构建管线的构建选项
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -30,7 +30,7 @@ namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
ECopyBuildinFileOption option = buildParametersContext.Parameters.CopyBuildinFileOption;
|
ECopyBuildinFileOption option = buildParametersContext.Parameters.CopyBuildinFileOption;
|
||||||
string packageOutputDirectory = buildParametersContext.GetPackageOutputDirectory();
|
string packageOutputDirectory = buildParametersContext.GetPackageOutputDirectory();
|
||||||
string streamingAssetsDirectory = AssetBundleBuilderHelper.GetStreamingAssetsFolderPath();
|
string streamingAssetsDirectory = buildParametersContext.GetStreamingAssetsDirectory();
|
||||||
string buildPackageName = buildParametersContext.Parameters.PackageName;
|
string buildPackageName = buildParametersContext.Parameters.PackageName;
|
||||||
string buildPackageVersion = buildParametersContext.Parameters.PackageVersion;
|
string buildPackageVersion = buildParametersContext.Parameters.PackageVersion;
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ namespace YooAsset.Editor
|
||||||
// 清空流目录
|
// 清空流目录
|
||||||
if (option == ECopyBuildinFileOption.ClearAndCopyAll || option == ECopyBuildinFileOption.ClearAndCopyByTags)
|
if (option == ECopyBuildinFileOption.ClearAndCopyAll || option == ECopyBuildinFileOption.ClearAndCopyByTags)
|
||||||
{
|
{
|
||||||
AssetBundleBuilderHelper.ClearStreamingAssetsFolder();
|
EditorTools.ClearFolder(streamingAssetsDirectory);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 拷贝补丁清单文件
|
// 拷贝补丁清单文件
|
||||||
|
|
|
@ -147,17 +147,17 @@ namespace YooAsset.Editor
|
||||||
private void RemoveZeroReferenceAssets(List<CollectAssetInfo> allCollectAssetInfos)
|
private void RemoveZeroReferenceAssets(List<CollectAssetInfo> allCollectAssetInfos)
|
||||||
{
|
{
|
||||||
// 1. 检测是否任何存在依赖资源
|
// 1. 检测是否任何存在依赖资源
|
||||||
bool hasAnyDependAsset = false;
|
bool hasAnyDependCollector = false;
|
||||||
foreach (var collectAssetInfo in allCollectAssetInfos)
|
foreach (var collectAssetInfo in allCollectAssetInfos)
|
||||||
{
|
{
|
||||||
var collectorType = collectAssetInfo.CollectorType;
|
var collectorType = collectAssetInfo.CollectorType;
|
||||||
if (collectorType == ECollectorType.DependAssetCollector)
|
if (collectorType == ECollectorType.DependAssetCollector)
|
||||||
{
|
{
|
||||||
hasAnyDependAsset = true;
|
hasAnyDependCollector = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (hasAnyDependAsset == false)
|
if (hasAnyDependCollector == false)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// 2. 获取所有主资源的依赖资源集合
|
// 2. 获取所有主资源的依赖资源集合
|
||||||
|
|
|
@ -16,11 +16,27 @@ namespace YooAsset.Editor
|
||||||
|
|
||||||
// 检测构建参数合法性
|
// 检测构建参数合法性
|
||||||
if (buildParameters.BuildTarget == BuildTarget.NoTarget)
|
if (buildParameters.BuildTarget == BuildTarget.NoTarget)
|
||||||
throw new Exception("请选择目标平台");
|
throw new Exception("请选择目标平台!");
|
||||||
if (string.IsNullOrEmpty(buildParameters.PackageName))
|
if (string.IsNullOrEmpty(buildParameters.PackageName))
|
||||||
throw new Exception("包裹名称不能为空");
|
throw new Exception("包裹名称不能为空!");
|
||||||
if (string.IsNullOrEmpty(buildParameters.PackageVersion))
|
if (string.IsNullOrEmpty(buildParameters.PackageVersion))
|
||||||
throw new Exception("包裹版本不能为空");
|
throw new Exception("包裹版本不能为空!");
|
||||||
|
if (string.IsNullOrEmpty(buildParameters.BuildOutputRoot))
|
||||||
|
throw new Exception("构建输出的根目录为空!");
|
||||||
|
if (string.IsNullOrEmpty(buildParameters.StreamingAssetsRoot))
|
||||||
|
throw new Exception("内置资源根目录为空!");
|
||||||
|
|
||||||
|
if (buildParameters.BuildPipeline == EBuildPipeline.ScriptableBuildPipeline)
|
||||||
|
{
|
||||||
|
if (buildParameters.SBPParameters == null)
|
||||||
|
throw new Exception($"{nameof(BuildParameters.SBPParameters)} is null !");
|
||||||
|
|
||||||
|
if (buildParameters.BuildMode == EBuildMode.DryRunBuild)
|
||||||
|
throw new Exception($"{nameof(EBuildPipeline.ScriptableBuildPipeline)} not support {nameof(EBuildMode.DryRunBuild)} build mode !");
|
||||||
|
|
||||||
|
if (buildParameters.BuildMode == EBuildMode.ForceRebuild)
|
||||||
|
throw new Exception($"{nameof(EBuildPipeline.ScriptableBuildPipeline)} not support {nameof(EBuildMode.ForceRebuild)} build mode !");
|
||||||
|
}
|
||||||
|
|
||||||
if (buildParameters.BuildMode != EBuildMode.SimulateBuild)
|
if (buildParameters.BuildMode != EBuildMode.SimulateBuild)
|
||||||
{
|
{
|
||||||
|
@ -72,11 +88,10 @@ namespace YooAsset.Editor
|
||||||
|
|
||||||
if (buildParameters.BuildMode == EBuildMode.ForceRebuild)
|
if (buildParameters.BuildMode == EBuildMode.ForceRebuild)
|
||||||
{
|
{
|
||||||
// 删除总目录
|
string packageRootDirectory = buildParametersContext.GetPackageRootDirectory();
|
||||||
string platformDirectory = $"{buildParameters.OutputRoot}/{buildParameters.BuildTarget}/{buildParameters.PackageName}";
|
if (EditorTools.DeleteDirectory(packageRootDirectory))
|
||||||
if (EditorTools.DeleteDirectory(platformDirectory))
|
|
||||||
{
|
{
|
||||||
BuildLogger.Log($"删除平台总目录:{platformDirectory}");
|
BuildLogger.Log($"删除包裹目录:{packageRootDirectory}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -45,7 +45,7 @@ namespace YooAsset
|
||||||
{
|
{
|
||||||
// BundleFiles
|
// BundleFiles
|
||||||
{
|
{
|
||||||
string rootPath = PersistentTools.GetCachedBundleFileFolderPath(_packageName);
|
string rootPath = PersistentTools.GetPersistent(_packageName).SandboxCacheBundleFilesRoot;
|
||||||
DirectoryInfo rootDirectory = new DirectoryInfo(rootPath);
|
DirectoryInfo rootDirectory = new DirectoryInfo(rootPath);
|
||||||
if (rootDirectory.Exists)
|
if (rootDirectory.Exists)
|
||||||
{
|
{
|
||||||
|
@ -56,7 +56,7 @@ namespace YooAsset
|
||||||
|
|
||||||
// RawFiles
|
// RawFiles
|
||||||
{
|
{
|
||||||
string rootPath = PersistentTools.GetCachedRawFileFolderPath(_packageName);
|
string rootPath = PersistentTools.GetPersistent(_packageName).SandboxCacheRawFilesRoot;
|
||||||
DirectoryInfo rootDirectory = new DirectoryInfo(rootPath);
|
DirectoryInfo rootDirectory = new DirectoryInfo(rootPath);
|
||||||
if (rootDirectory.Exists)
|
if (rootDirectory.Exists)
|
||||||
{
|
{
|
||||||
|
|
|
@ -0,0 +1,163 @@
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
|
namespace YooAsset
|
||||||
|
{
|
||||||
|
internal class Persistent
|
||||||
|
{
|
||||||
|
private readonly string _packageName;
|
||||||
|
|
||||||
|
public string BuildinRoot { private set; get; }
|
||||||
|
public string BuildinPackageRoot { private set; get; }
|
||||||
|
|
||||||
|
public string SandboxRoot { private set; get; }
|
||||||
|
public string SandboxPackageRoot { private set; get; }
|
||||||
|
public string SandboxCacheBundleFilesRoot { private set; get; }
|
||||||
|
public string SandboxCacheRawFilesRoot { private set; get; }
|
||||||
|
public string SandboxManifestFilesRoot { private set; get; }
|
||||||
|
public string SandboxAppFootPrintFilePath { private set; get; }
|
||||||
|
|
||||||
|
|
||||||
|
public Persistent(string packageName)
|
||||||
|
{
|
||||||
|
_packageName = packageName;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 重写根路径
|
||||||
|
/// </summary>
|
||||||
|
public void OverwriteRootDirectory(string buildinRoot, string sandboxRoot)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(buildinRoot))
|
||||||
|
BuildinRoot = CreateDefaultBuildinRoot();
|
||||||
|
else
|
||||||
|
BuildinRoot = buildinRoot;
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(sandboxRoot))
|
||||||
|
SandboxRoot = CreateDefaultSandboxRoot();
|
||||||
|
else
|
||||||
|
SandboxRoot = sandboxRoot;
|
||||||
|
|
||||||
|
BuildinPackageRoot = PathUtility.Combine(BuildinRoot, _packageName);
|
||||||
|
SandboxPackageRoot = PathUtility.Combine(SandboxRoot, _packageName);
|
||||||
|
SandboxCacheBundleFilesRoot = PathUtility.Combine(SandboxPackageRoot, YooAssetSettings.CachedBundleFileFolder);
|
||||||
|
SandboxCacheRawFilesRoot = PathUtility.Combine(SandboxPackageRoot, YooAssetSettings.CachedRawFileFolder);
|
||||||
|
SandboxManifestFilesRoot = PathUtility.Combine(SandboxPackageRoot, YooAssetSettings.ManifestFolderName);
|
||||||
|
SandboxAppFootPrintFilePath = PathUtility.Combine(SandboxPackageRoot, YooAssetSettings.AppFootPrintFileName);
|
||||||
|
}
|
||||||
|
private static string CreateDefaultBuildinRoot()
|
||||||
|
{
|
||||||
|
return PathUtility.Combine(UnityEngine.Application.streamingAssetsPath, YooAssetSettings.DefaultYooFolderName);
|
||||||
|
}
|
||||||
|
private static string CreateDefaultSandboxRoot()
|
||||||
|
{
|
||||||
|
#if UNITY_EDITOR
|
||||||
|
// 注意:为了方便调试查看,编辑器下把存储目录放到项目里。
|
||||||
|
string projectPath = Path.GetDirectoryName(UnityEngine.Application.dataPath);
|
||||||
|
projectPath = PathUtility.RegularPath(projectPath);
|
||||||
|
return PathUtility.Combine(projectPath, YooAssetSettings.DefaultYooFolderName);
|
||||||
|
#elif UNITY_STANDALONE
|
||||||
|
return PathUtility.Combine(UnityEngine.Application.dataPath, YooAssetSettings.DefaultYooFolderName);
|
||||||
|
#else
|
||||||
|
return PathUtility.Combine(UnityEngine.Application.persistentDataPath, YooAssetSettings.DefaultYooFolderName);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 删除沙盒里的包裹目录
|
||||||
|
/// </summary>
|
||||||
|
public void DeleteSandboxPackageFolder()
|
||||||
|
{
|
||||||
|
if (Directory.Exists(SandboxPackageRoot))
|
||||||
|
Directory.Delete(SandboxPackageRoot, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 删除沙盒内的缓存文件夹
|
||||||
|
/// </summary>
|
||||||
|
public void DeleteSandboxCacheFilesFolder()
|
||||||
|
{
|
||||||
|
// CacheBundleFiles
|
||||||
|
if (Directory.Exists(SandboxCacheBundleFilesRoot))
|
||||||
|
Directory.Delete(SandboxCacheBundleFilesRoot, true);
|
||||||
|
|
||||||
|
// CacheRawFiles
|
||||||
|
if (Directory.Exists(SandboxCacheRawFilesRoot))
|
||||||
|
Directory.Delete(SandboxCacheRawFilesRoot, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 删除沙盒内的清单文件夹
|
||||||
|
/// </summary>
|
||||||
|
public void DeleteSandboxManifestFilesFolder()
|
||||||
|
{
|
||||||
|
if (Directory.Exists(SandboxManifestFilesRoot))
|
||||||
|
Directory.Delete(SandboxManifestFilesRoot, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取沙盒内包裹的清单文件的路径
|
||||||
|
/// </summary>
|
||||||
|
public string GetSandboxPackageManifestFilePath(string packageVersion)
|
||||||
|
{
|
||||||
|
string fileName = YooAssetSettingsData.GetManifestBinaryFileName(_packageName, packageVersion);
|
||||||
|
return PathUtility.Combine(SandboxManifestFilesRoot, fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取沙盒内包裹的哈希文件的路径
|
||||||
|
/// </summary>
|
||||||
|
public string GetSandboxPackageHashFilePath(string packageVersion)
|
||||||
|
{
|
||||||
|
string fileName = YooAssetSettingsData.GetPackageHashFileName(_packageName, packageVersion);
|
||||||
|
return PathUtility.Combine(SandboxManifestFilesRoot, fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取沙盒内包裹的版本文件的路径
|
||||||
|
/// </summary>
|
||||||
|
public string GetSandboxPackageVersionFilePath()
|
||||||
|
{
|
||||||
|
string fileName = YooAssetSettingsData.GetPackageVersionFileName(_packageName);
|
||||||
|
return PathUtility.Combine(SandboxManifestFilesRoot, fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 保存沙盒内默认的包裹版本
|
||||||
|
/// </summary>
|
||||||
|
public void SaveSandboxPackageVersionFile(string version)
|
||||||
|
{
|
||||||
|
string filePath = GetSandboxPackageVersionFilePath();
|
||||||
|
FileUtility.WriteAllText(filePath, version);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取APP内包裹的清单文件的路径
|
||||||
|
/// </summary>
|
||||||
|
public string GetBuildinPackageManifestFilePath(string packageVersion)
|
||||||
|
{
|
||||||
|
string fileName = YooAssetSettingsData.GetManifestBinaryFileName(_packageName, packageVersion);
|
||||||
|
return PathUtility.Combine(BuildinPackageRoot, fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取APP内包裹的哈希文件的路径
|
||||||
|
/// </summary>
|
||||||
|
public string GetBuildinPackageHashFilePath(string packageVersion)
|
||||||
|
{
|
||||||
|
string fileName = YooAssetSettingsData.GetPackageHashFileName(_packageName, packageVersion);
|
||||||
|
return PathUtility.Combine(BuildinPackageRoot, fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取APP内包裹的版本文件的路径
|
||||||
|
/// </summary>
|
||||||
|
public string GetBuildinPackageVersionFilePath()
|
||||||
|
{
|
||||||
|
string fileName = YooAssetSettingsData.GetPackageVersionFileName(_packageName);
|
||||||
|
return PathUtility.Combine(BuildinPackageRoot, fileName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 62ee5fd2821fe85488efff3f8242b703
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -3,92 +3,31 @@ using System.Collections.Generic;
|
||||||
|
|
||||||
namespace YooAsset
|
namespace YooAsset
|
||||||
{
|
{
|
||||||
internal static class PersistentTools
|
internal class PersistentTools
|
||||||
{
|
{
|
||||||
private const string SandboxFolderName = "Sandbox";
|
private static readonly Dictionary<string, Persistent> _persitentDic = new Dictionary<string, Persistent>(100);
|
||||||
private const string CacheFolderName = "CacheFiles";
|
|
||||||
private const string CachedBundleFileFolder = "BundleFiles";
|
|
||||||
private const string CachedRawFileFolder = "RawFiles";
|
|
||||||
private const string ManifestFolderName = "ManifestFiles";
|
|
||||||
private const string AppFootPrintFileName = "ApplicationFootPrint.bytes";
|
|
||||||
|
|
||||||
private static string _buildinPath;
|
|
||||||
private static string _sandboxPath;
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 重写内置跟路径
|
/// 获取包裹的持久化类
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static void OverwriteBuildinPath(string path)
|
public static Persistent GetPersistent(string packageName)
|
||||||
{
|
{
|
||||||
_buildinPath = path;
|
if (_persitentDic.ContainsKey(packageName) == false)
|
||||||
|
throw new System.Exception("Should never get here !");
|
||||||
|
return _persitentDic[packageName];
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 重写沙盒跟路径
|
/// 获取或创建包裹的持久化类
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static void OverwriteSandboxPath(string path)
|
public static Persistent GetOrCreatePersistent(string packageName)
|
||||||
{
|
{
|
||||||
_sandboxPath = path;
|
if (_persitentDic.ContainsKey(packageName) == false)
|
||||||
|
{
|
||||||
|
Persistent persistent = new Persistent(packageName);
|
||||||
|
_persitentDic.Add(packageName, persistent);
|
||||||
}
|
}
|
||||||
|
return _persitentDic[packageName];
|
||||||
/// <summary>
|
|
||||||
/// 获取沙盒文件夹路径
|
|
||||||
/// </summary>
|
|
||||||
public static string GetPersistentRootPath()
|
|
||||||
{
|
|
||||||
#if UNITY_EDITOR
|
|
||||||
// 注意:为了方便调试查看,编辑器下把存储目录放到项目里
|
|
||||||
if (string.IsNullOrEmpty(_sandboxPath))
|
|
||||||
{
|
|
||||||
string projectPath = Path.GetDirectoryName(UnityEngine.Application.dataPath);
|
|
||||||
projectPath = PathUtility.RegularPath(projectPath);
|
|
||||||
_sandboxPath = PathUtility.Combine(projectPath, SandboxFolderName);
|
|
||||||
}
|
|
||||||
#elif UNITY_STANDALONE
|
|
||||||
if (string.IsNullOrEmpty(_sandboxPath))
|
|
||||||
{
|
|
||||||
_sandboxPath = PathUtility.Combine(UnityEngine.Application.dataPath, SandboxFolderName);
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
if (string.IsNullOrEmpty(_sandboxPath))
|
|
||||||
{
|
|
||||||
_sandboxPath = PathUtility.Combine(UnityEngine.Application.persistentDataPath, SandboxFolderName);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return _sandboxPath;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 获取基于流文件夹的加载路径
|
|
||||||
/// </summary>
|
|
||||||
public static string MakeStreamingLoadPath(string path)
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(_buildinPath))
|
|
||||||
{
|
|
||||||
_buildinPath = PathUtility.Combine(UnityEngine.Application.streamingAssetsPath, YooAssetSettings.StreamingAssetsBuildinFolder);
|
|
||||||
}
|
|
||||||
return PathUtility.Combine(_buildinPath, path);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 获取基于沙盒文件夹的加载路径
|
|
||||||
/// </summary>
|
|
||||||
public static string MakePersistentLoadPath(string path)
|
|
||||||
{
|
|
||||||
string root = GetPersistentRootPath();
|
|
||||||
return PathUtility.Combine(root, path);
|
|
||||||
}
|
|
||||||
public static string MakePersistentLoadPath(string path1, string path2)
|
|
||||||
{
|
|
||||||
string root = GetPersistentRootPath();
|
|
||||||
return PathUtility.Combine(root, path1, path2);
|
|
||||||
}
|
|
||||||
public static string MakePersistentLoadPath(string path1, string path2, string path3)
|
|
||||||
{
|
|
||||||
string root = GetPersistentRootPath();
|
|
||||||
return PathUtility.Combine(root, path1, path2, path3);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -108,109 +47,5 @@ namespace YooAsset
|
||||||
return path;
|
return path;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 删除沙盒总目录
|
|
||||||
/// </summary>
|
|
||||||
public static void DeleteSandbox()
|
|
||||||
{
|
|
||||||
string directoryPath = GetPersistentRootPath();
|
|
||||||
if (Directory.Exists(directoryPath))
|
|
||||||
Directory.Delete(directoryPath, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 删除沙盒内的缓存文件夹
|
|
||||||
/// </summary>
|
|
||||||
public static void DeleteCacheFolder()
|
|
||||||
{
|
|
||||||
string root = MakePersistentLoadPath(CacheFolderName);
|
|
||||||
if (Directory.Exists(root))
|
|
||||||
Directory.Delete(root, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 删除沙盒内的清单文件夹
|
|
||||||
/// </summary>
|
|
||||||
public static void DeleteManifestFolder()
|
|
||||||
{
|
|
||||||
string root = MakePersistentLoadPath(ManifestFolderName);
|
|
||||||
if (Directory.Exists(root))
|
|
||||||
Directory.Delete(root, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 获取缓存的BundleFile文件夹路径
|
|
||||||
/// </summary>
|
|
||||||
private readonly static Dictionary<string, string> _cachedBundleFileFolder = new Dictionary<string, string>(100);
|
|
||||||
public static string GetCachedBundleFileFolderPath(string packageName)
|
|
||||||
{
|
|
||||||
if (_cachedBundleFileFolder.TryGetValue(packageName, out string value) == false)
|
|
||||||
{
|
|
||||||
value = MakePersistentLoadPath(CacheFolderName, packageName, CachedBundleFileFolder);
|
|
||||||
_cachedBundleFileFolder.Add(packageName, value);
|
|
||||||
}
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 获取缓存的RawFile文件夹路径
|
|
||||||
/// </summary>
|
|
||||||
private readonly static Dictionary<string, string> _cachedRawFileFolder = new Dictionary<string, string>(100);
|
|
||||||
public static string GetCachedRawFileFolderPath(string packageName)
|
|
||||||
{
|
|
||||||
if (_cachedRawFileFolder.TryGetValue(packageName, out string value) == false)
|
|
||||||
{
|
|
||||||
value = MakePersistentLoadPath(CacheFolderName, packageName, CachedRawFileFolder);
|
|
||||||
_cachedRawFileFolder.Add(packageName, value);
|
|
||||||
}
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 获取应用程序的水印文件路径
|
|
||||||
/// </summary>
|
|
||||||
public static string GetAppFootPrintFilePath()
|
|
||||||
{
|
|
||||||
return MakePersistentLoadPath(AppFootPrintFileName);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 获取沙盒内清单文件的路径
|
|
||||||
/// </summary>
|
|
||||||
public static string GetCacheManifestFilePath(string packageName, string packageVersion)
|
|
||||||
{
|
|
||||||
string fileName = YooAssetSettingsData.GetManifestBinaryFileName(packageName, packageVersion);
|
|
||||||
return MakePersistentLoadPath(ManifestFolderName, fileName);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 获取沙盒内包裹的哈希文件的路径
|
|
||||||
/// </summary>
|
|
||||||
public static string GetCachePackageHashFilePath(string packageName, string packageVersion)
|
|
||||||
{
|
|
||||||
string fileName = YooAssetSettingsData.GetPackageHashFileName(packageName, packageVersion);
|
|
||||||
return MakePersistentLoadPath(ManifestFolderName, fileName);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 获取沙盒内包裹的版本文件的路径
|
|
||||||
/// </summary>
|
|
||||||
public static string GetCachePackageVersionFilePath(string packageName)
|
|
||||||
{
|
|
||||||
string fileName = YooAssetSettingsData.GetPackageVersionFileName(packageName);
|
|
||||||
return MakePersistentLoadPath(ManifestFolderName, fileName);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 保存默认的包裹版本
|
|
||||||
/// </summary>
|
|
||||||
public static void SaveCachePackageVersionFile(string packageName, string version)
|
|
||||||
{
|
|
||||||
string filePath = GetCachePackageVersionFilePath(packageName);
|
|
||||||
FileUtility.WriteAllText(filePath, version);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -32,6 +32,18 @@ namespace YooAsset
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public IDecryptionServices DecryptionServices = null;
|
public IDecryptionServices DecryptionServices = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 内置文件的根路径
|
||||||
|
/// 注意:当参数为空的时候会使用默认的根目录。
|
||||||
|
/// </summary>
|
||||||
|
public string BuildinRootDirectory = string.Empty;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 沙盒文件的根路径
|
||||||
|
/// 注意:当参数为空的时候会使用默认的根目录。
|
||||||
|
/// </summary>
|
||||||
|
public string SandboxRootDirectory = string.Empty;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 资源加载每帧处理的最大时间片段
|
/// 资源加载每帧处理的最大时间片段
|
||||||
/// 注意:默认值为MaxValue
|
/// 注意:默认值为MaxValue
|
||||||
|
|
|
@ -217,13 +217,13 @@ namespace YooAsset
|
||||||
if (_steps == ESteps.CheckAppFootPrint)
|
if (_steps == ESteps.CheckAppFootPrint)
|
||||||
{
|
{
|
||||||
var appFootPrint = new AppFootPrint();
|
var appFootPrint = new AppFootPrint();
|
||||||
appFootPrint.Load();
|
appFootPrint.Load(_packageName);
|
||||||
|
|
||||||
// 如果水印发生变化,则说明覆盖安装后首次打开游戏
|
// 如果水印发生变化,则说明覆盖安装后首次打开游戏
|
||||||
if (appFootPrint.IsDirty())
|
if (appFootPrint.IsDirty())
|
||||||
{
|
{
|
||||||
PersistentTools.DeleteManifestFolder();
|
PersistentTools.GetPersistent(_packageName).DeleteSandboxManifestFilesFolder();
|
||||||
appFootPrint.Coverage();
|
appFootPrint.Coverage(_packageName);
|
||||||
YooLogger.Log("Delete manifest files when application foot print dirty !");
|
YooLogger.Log("Delete manifest files when application foot print dirty !");
|
||||||
}
|
}
|
||||||
_steps = ESteps.QueryCachePackageVersion;
|
_steps = ESteps.QueryCachePackageVersion;
|
||||||
|
@ -374,16 +374,16 @@ namespace YooAsset
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 读取应用程序水印
|
/// 读取应用程序水印
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void Load()
|
public void Load(string packageName)
|
||||||
{
|
{
|
||||||
string footPrintFilePath = PersistentTools.GetAppFootPrintFilePath();
|
string footPrintFilePath = PersistentTools.GetPersistent(packageName).SandboxAppFootPrintFilePath;
|
||||||
if (File.Exists(footPrintFilePath))
|
if (File.Exists(footPrintFilePath))
|
||||||
{
|
{
|
||||||
_footPrint = FileUtility.ReadAllText(footPrintFilePath);
|
_footPrint = FileUtility.ReadAllText(footPrintFilePath);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Coverage();
|
Coverage(packageName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -402,14 +402,14 @@ namespace YooAsset
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 覆盖掉水印
|
/// 覆盖掉水印
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void Coverage()
|
public void Coverage(string packageName)
|
||||||
{
|
{
|
||||||
#if UNITY_EDITOR
|
#if UNITY_EDITOR
|
||||||
_footPrint = Application.version;
|
_footPrint = Application.version;
|
||||||
#else
|
#else
|
||||||
_footPrint = Application.buildGUID;
|
_footPrint = Application.buildGUID;
|
||||||
#endif
|
#endif
|
||||||
string footPrintFilePath = PersistentTools.GetAppFootPrintFilePath();
|
string footPrintFilePath = PersistentTools.GetPersistent(packageName).SandboxAppFootPrintFilePath;
|
||||||
FileUtility.WriteAllText(footPrintFilePath, _footPrint);
|
FileUtility.WriteAllText(footPrintFilePath, _footPrint);
|
||||||
YooLogger.Log($"Save application foot print : {_footPrint}");
|
YooLogger.Log($"Save application foot print : {_footPrint}");
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,7 +41,7 @@ namespace YooAsset
|
||||||
{
|
{
|
||||||
if (_downloader1 == null)
|
if (_downloader1 == null)
|
||||||
{
|
{
|
||||||
string savePath = PersistentTools.GetCachePackageHashFilePath(_packageName, _packageVersion);
|
string savePath = PersistentTools.GetPersistent(_packageName).GetSandboxPackageHashFilePath(_packageVersion);
|
||||||
string fileName = YooAssetSettingsData.GetPackageHashFileName(_packageName, _packageVersion);
|
string fileName = YooAssetSettingsData.GetPackageHashFileName(_packageName, _packageVersion);
|
||||||
string webURL = GetDownloadRequestURL(fileName);
|
string webURL = GetDownloadRequestURL(fileName);
|
||||||
YooLogger.Log($"Beginning to download package hash file : {webURL}");
|
YooLogger.Log($"Beginning to download package hash file : {webURL}");
|
||||||
|
@ -71,7 +71,7 @@ namespace YooAsset
|
||||||
{
|
{
|
||||||
if (_downloader2 == null)
|
if (_downloader2 == null)
|
||||||
{
|
{
|
||||||
string savePath = PersistentTools.GetCacheManifestFilePath(_packageName, _packageVersion);
|
string savePath = PersistentTools.GetPersistent(_packageName).GetSandboxPackageManifestFilePath(_packageVersion);
|
||||||
string fileName = YooAssetSettingsData.GetManifestBinaryFileName(_packageName, _packageVersion);
|
string fileName = YooAssetSettingsData.GetManifestBinaryFileName(_packageName, _packageVersion);
|
||||||
string webURL = GetDownloadRequestURL(fileName);
|
string webURL = GetDownloadRequestURL(fileName);
|
||||||
YooLogger.Log($"Beginning to download manifest file : {webURL}");
|
YooLogger.Log($"Beginning to download manifest file : {webURL}");
|
||||||
|
|
|
@ -41,8 +41,7 @@ namespace YooAsset
|
||||||
{
|
{
|
||||||
if (_downloader == null)
|
if (_downloader == null)
|
||||||
{
|
{
|
||||||
string fileName = YooAssetSettingsData.GetManifestBinaryFileName(_buildinPackageName, _buildinPackageVersion);
|
string filePath = PersistentTools.GetPersistent(_buildinPackageName).GetBuildinPackageManifestFilePath(_buildinPackageVersion);
|
||||||
string filePath = PersistentTools.MakeStreamingLoadPath(fileName);
|
|
||||||
string url = PersistentTools.ConvertToWWWPath(filePath);
|
string url = PersistentTools.ConvertToWWWPath(filePath);
|
||||||
_downloader = new UnityWebDataRequester();
|
_downloader = new UnityWebDataRequester();
|
||||||
_downloader.SendRequest(url);
|
_downloader.SendRequest(url);
|
||||||
|
|
|
@ -67,7 +67,7 @@ namespace YooAsset
|
||||||
|
|
||||||
if (_steps == ESteps.VerifyFileHash)
|
if (_steps == ESteps.VerifyFileHash)
|
||||||
{
|
{
|
||||||
_manifestFilePath = PersistentTools.GetCacheManifestFilePath(_packageName, _packageVersion);
|
_manifestFilePath = PersistentTools.GetPersistent(_packageName).GetSandboxPackageManifestFilePath(_packageVersion);
|
||||||
if (File.Exists(_manifestFilePath) == false)
|
if (File.Exists(_manifestFilePath) == false)
|
||||||
{
|
{
|
||||||
_steps = ESteps.Done;
|
_steps = ESteps.Done;
|
||||||
|
@ -131,7 +131,7 @@ namespace YooAsset
|
||||||
File.Delete(_manifestFilePath);
|
File.Delete(_manifestFilePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
string hashFilePath = PersistentTools.GetCachePackageHashFilePath(_packageName, _packageVersion);
|
string hashFilePath = PersistentTools.GetPersistent(_packageName).GetSandboxPackageHashFilePath(_packageVersion);
|
||||||
if (File.Exists(hashFilePath))
|
if (File.Exists(hashFilePath))
|
||||||
{
|
{
|
||||||
File.Delete(hashFilePath);
|
File.Delete(hashFilePath);
|
||||||
|
|
|
@ -37,8 +37,7 @@ namespace YooAsset
|
||||||
{
|
{
|
||||||
if (_downloader == null)
|
if (_downloader == null)
|
||||||
{
|
{
|
||||||
string fileName = YooAssetSettingsData.GetPackageVersionFileName(_packageName);
|
string filePath = PersistentTools.GetPersistent(_packageName).GetBuildinPackageVersionFilePath();
|
||||||
string filePath = PersistentTools.MakeStreamingLoadPath(fileName);
|
|
||||||
string url = PersistentTools.ConvertToWWWPath(filePath);
|
string url = PersistentTools.ConvertToWWWPath(filePath);
|
||||||
_downloader = new UnityWebDataRequester();
|
_downloader = new UnityWebDataRequester();
|
||||||
_downloader.SendRequest(url);
|
_downloader.SendRequest(url);
|
||||||
|
|
|
@ -37,7 +37,7 @@ namespace YooAsset
|
||||||
|
|
||||||
if (_steps == ESteps.LoadCachePackageHashFile)
|
if (_steps == ESteps.LoadCachePackageHashFile)
|
||||||
{
|
{
|
||||||
string filePath = PersistentTools.GetCachePackageHashFilePath(_packageName, _packageVersion);
|
string filePath = PersistentTools.GetPersistent(_packageName).GetSandboxPackageHashFilePath(_packageVersion);
|
||||||
if (File.Exists(filePath) == false)
|
if (File.Exists(filePath) == false)
|
||||||
{
|
{
|
||||||
_steps = ESteps.Done;
|
_steps = ESteps.Done;
|
||||||
|
|
|
@ -35,7 +35,7 @@ namespace YooAsset
|
||||||
|
|
||||||
if (_steps == ESteps.LoadCachePackageVersionFile)
|
if (_steps == ESteps.LoadCachePackageVersionFile)
|
||||||
{
|
{
|
||||||
string filePath = PersistentTools.GetCachePackageVersionFilePath(_packageName);
|
string filePath = PersistentTools.GetPersistent(_packageName).GetSandboxPackageVersionFilePath();
|
||||||
if (File.Exists(filePath) == false)
|
if (File.Exists(filePath) == false)
|
||||||
{
|
{
|
||||||
_steps = ESteps.Done;
|
_steps = ESteps.Done;
|
||||||
|
|
|
@ -35,9 +35,9 @@ namespace YooAsset
|
||||||
{
|
{
|
||||||
if (_downloader1 == null)
|
if (_downloader1 == null)
|
||||||
{
|
{
|
||||||
string savePath = PersistentTools.GetCachePackageHashFilePath(_buildinPackageName, _buildinPackageVersion);
|
var persistent = PersistentTools.GetPersistent(_buildinPackageName);
|
||||||
string fileName = YooAssetSettingsData.GetPackageHashFileName(_buildinPackageName, _buildinPackageVersion);
|
string savePath = persistent.GetSandboxPackageHashFilePath(_buildinPackageVersion);
|
||||||
string filePath = PersistentTools.MakeStreamingLoadPath(fileName);
|
string filePath = persistent.GetBuildinPackageHashFilePath(_buildinPackageVersion);
|
||||||
string url = PersistentTools.ConvertToWWWPath(filePath);
|
string url = PersistentTools.ConvertToWWWPath(filePath);
|
||||||
_downloader1 = new UnityWebFileRequester();
|
_downloader1 = new UnityWebFileRequester();
|
||||||
_downloader1.SendRequest(url, savePath);
|
_downloader1.SendRequest(url, savePath);
|
||||||
|
@ -64,9 +64,9 @@ namespace YooAsset
|
||||||
{
|
{
|
||||||
if (_downloader2 == null)
|
if (_downloader2 == null)
|
||||||
{
|
{
|
||||||
string savePath = PersistentTools.GetCacheManifestFilePath(_buildinPackageName, _buildinPackageVersion);
|
var persistent = PersistentTools.GetPersistent(_buildinPackageName);
|
||||||
string fileName = YooAssetSettingsData.GetManifestBinaryFileName(_buildinPackageName, _buildinPackageVersion);
|
string savePath = persistent.GetSandboxPackageManifestFilePath(_buildinPackageVersion);
|
||||||
string filePath = PersistentTools.MakeStreamingLoadPath(fileName);
|
string filePath = persistent.GetBuildinPackageManifestFilePath(_buildinPackageVersion);
|
||||||
string url = PersistentTools.ConvertToWWWPath(filePath);
|
string url = PersistentTools.ConvertToWWWPath(filePath);
|
||||||
_downloader2 = new UnityWebFileRequester();
|
_downloader2 = new UnityWebFileRequester();
|
||||||
_downloader2.SendRequest(url, savePath);
|
_downloader2.SendRequest(url, savePath);
|
||||||
|
|
|
@ -74,13 +74,13 @@ namespace YooAsset
|
||||||
string folderName = FileHash.Substring(0, 2);
|
string folderName = FileHash.Substring(0, 2);
|
||||||
if (IsRawFile)
|
if (IsRawFile)
|
||||||
{
|
{
|
||||||
string cacheRoot = PersistentTools.GetCachedRawFileFolderPath(PackageName);
|
string cacheRoot = PersistentTools.GetPersistent(PackageName).SandboxCacheRawFilesRoot;
|
||||||
_cachedDataFilePath = PathUtility.Combine(cacheRoot, folderName, CacheGUID, YooAssetSettings.CacheBundleDataFileName);
|
_cachedDataFilePath = PathUtility.Combine(cacheRoot, folderName, CacheGUID, YooAssetSettings.CacheBundleDataFileName);
|
||||||
_cachedDataFilePath += _fileExtension;
|
_cachedDataFilePath += _fileExtension;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
string cacheRoot = PersistentTools.GetCachedBundleFileFolderPath(PackageName);
|
string cacheRoot = PersistentTools.GetPersistent(PackageName).SandboxCacheBundleFilesRoot;
|
||||||
_cachedDataFilePath = PathUtility.Combine(cacheRoot, folderName, CacheGUID, YooAssetSettings.CacheBundleDataFileName);
|
_cachedDataFilePath = PathUtility.Combine(cacheRoot, folderName, CacheGUID, YooAssetSettings.CacheBundleDataFileName);
|
||||||
}
|
}
|
||||||
return _cachedDataFilePath;
|
return _cachedDataFilePath;
|
||||||
|
@ -101,12 +101,12 @@ namespace YooAsset
|
||||||
string folderName = FileHash.Substring(0, 2);
|
string folderName = FileHash.Substring(0, 2);
|
||||||
if (IsRawFile)
|
if (IsRawFile)
|
||||||
{
|
{
|
||||||
string cacheRoot = PersistentTools.GetCachedRawFileFolderPath(PackageName);
|
string cacheRoot = PersistentTools.GetPersistent(PackageName).SandboxCacheRawFilesRoot;
|
||||||
_cachedInfoFilePath = PathUtility.Combine(cacheRoot, folderName, CacheGUID, YooAssetSettings.CacheBundleInfoFileName);
|
_cachedInfoFilePath = PathUtility.Combine(cacheRoot, folderName, CacheGUID, YooAssetSettings.CacheBundleInfoFileName);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
string cacheRoot = PersistentTools.GetCachedBundleFileFolderPath(PackageName);
|
string cacheRoot = PersistentTools.GetPersistent(PackageName).SandboxCacheBundleFilesRoot;
|
||||||
_cachedInfoFilePath = PathUtility.Combine(cacheRoot, folderName, CacheGUID, YooAssetSettings.CacheBundleInfoFileName);
|
_cachedInfoFilePath = PathUtility.Combine(cacheRoot, folderName, CacheGUID, YooAssetSettings.CacheBundleInfoFileName);
|
||||||
}
|
}
|
||||||
return _cachedInfoFilePath;
|
return _cachedInfoFilePath;
|
||||||
|
@ -140,7 +140,8 @@ namespace YooAsset
|
||||||
if (string.IsNullOrEmpty(_streamingFilePath) == false)
|
if (string.IsNullOrEmpty(_streamingFilePath) == false)
|
||||||
return _streamingFilePath;
|
return _streamingFilePath;
|
||||||
|
|
||||||
_streamingFilePath = PersistentTools.MakeStreamingLoadPath(FileName);
|
string root = PersistentTools.GetPersistent(PackageName).BuildinPackageRoot;
|
||||||
|
_streamingFilePath = PathUtility.Combine(root, FileName);
|
||||||
return _streamingFilePath;
|
return _streamingFilePath;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -74,7 +74,9 @@ namespace YooAsset
|
||||||
public void FlushManifestVersionFile()
|
public void FlushManifestVersionFile()
|
||||||
{
|
{
|
||||||
if (_activeManifest != null)
|
if (_activeManifest != null)
|
||||||
PersistentTools.SaveCachePackageVersionFile(_packageName, _activeManifest.PackageVersion);
|
{
|
||||||
|
PersistentTools.GetPersistent(_packageName).SaveSandboxPackageVersionFile(_activeManifest.PackageVersion);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool IsBuildinPackageBundle(PackageBundle packageBundle)
|
private bool IsBuildinPackageBundle(PackageBundle packageBundle)
|
||||||
|
|
|
@ -79,6 +79,10 @@ namespace YooAsset
|
||||||
// 检测初始化参数合法性
|
// 检测初始化参数合法性
|
||||||
CheckInitializeParameters(parameters);
|
CheckInitializeParameters(parameters);
|
||||||
|
|
||||||
|
// 重写持久化根目录
|
||||||
|
var persistent = PersistentTools.GetOrCreatePersistent(PackageName);
|
||||||
|
persistent.OverwriteRootDirectory(parameters.BuildinRootDirectory, parameters.SandboxRootDirectory);
|
||||||
|
|
||||||
// 初始化资源系统
|
// 初始化资源系统
|
||||||
InitializationOperation initializeOperation;
|
InitializationOperation initializeOperation;
|
||||||
_assetSystemImpl = new AssetSystemImpl();
|
_assetSystemImpl = new AssetSystemImpl();
|
||||||
|
@ -291,6 +295,37 @@ namespace YooAsset
|
||||||
_assetSystemImpl.ForceUnloadAllAssets();
|
_assetSystemImpl.ForceUnloadAllAssets();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#region 沙盒相关
|
||||||
|
/// <summary>
|
||||||
|
/// 获取包裹的内置文件根路径
|
||||||
|
/// </summary>
|
||||||
|
public string GetPackageBuildinRootDirectory()
|
||||||
|
{
|
||||||
|
DebugCheckInitialize();
|
||||||
|
var persistent = PersistentTools.GetPersistent(PackageName);
|
||||||
|
return persistent.BuildinRoot;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取包裹的沙盒文件根路径
|
||||||
|
/// </summary>
|
||||||
|
public string GetPackageSandboxRootDirectory()
|
||||||
|
{
|
||||||
|
DebugCheckInitialize();
|
||||||
|
var persistent = PersistentTools.GetPersistent(PackageName);
|
||||||
|
return persistent.SandboxRoot;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 清空包裹的沙盒目录
|
||||||
|
/// </summary>
|
||||||
|
public void ClearPackageSandbox()
|
||||||
|
{
|
||||||
|
DebugCheckInitialize();
|
||||||
|
var persistent = PersistentTools.GetPersistent(PackageName);
|
||||||
|
persistent.DeleteSandboxPackageFolder();
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
#region 资源信息
|
#region 资源信息
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -37,6 +37,31 @@ namespace YooAsset
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public const string CacheBundleInfoFileName = "__info";
|
public const string CacheBundleInfoFileName = "__info";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 默认的YooAsset文件夹名称
|
||||||
|
/// </summary>
|
||||||
|
public const string DefaultYooFolderName = "yoo";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 缓存的资源文件的文件夹名称
|
||||||
|
/// </summary>
|
||||||
|
public const string CachedBundleFileFolder = "CacheBundleFiles";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 缓存的原生文件的文件夹名称
|
||||||
|
/// </summary>
|
||||||
|
public const string CachedRawFileFolder = "CacheRawFiles";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 缓存的清单文件的文件夹名称
|
||||||
|
/// </summary>
|
||||||
|
public const string ManifestFolderName = "ManifestFiles";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 记录应用程序版本的文件名称
|
||||||
|
/// </summary>
|
||||||
|
public const string AppFootPrintFileName = "ApplicationFootPrint.bytes";
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 构建输出文件夹名称
|
/// 构建输出文件夹名称
|
||||||
|
@ -47,10 +72,5 @@ namespace YooAsset
|
||||||
/// 构建输出的报告文件
|
/// 构建输出的报告文件
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public const string ReportFileName = "BuildReport";
|
public const string ReportFileName = "BuildReport";
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 内置资源目录名称
|
|
||||||
/// </summary>
|
|
||||||
public const string StreamingAssetsBuildinFolder = "BuildinFiles";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -253,48 +253,6 @@ namespace YooAsset
|
||||||
CacheSystem.InitVerifyLevel = verifyLevel;
|
CacheSystem.InitVerifyLevel = verifyLevel;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 设置缓存系统参数,沙盒目录的存储路径
|
|
||||||
/// </summary>
|
|
||||||
public static void SetCacheSystemBuildinPath(string buildinPath)
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(buildinPath))
|
|
||||||
{
|
|
||||||
YooLogger.Error($"Buildin path is null or empty !");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 注意:需要确保没有任何资源系统起效之前才可以设置!
|
|
||||||
if (_packages.Count > 0)
|
|
||||||
{
|
|
||||||
YooLogger.Error($"Please call this method {nameof(SetCacheSystemBuildinPath)} before the package is created !");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
PersistentTools.OverwriteBuildinPath(buildinPath);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 设置缓存系统参数,沙盒目录的存储路径
|
|
||||||
/// </summary>
|
|
||||||
public static void SetCacheSystemSandboxPath(string sandboxPath)
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(sandboxPath))
|
|
||||||
{
|
|
||||||
YooLogger.Error($"Sandbox path is null or empty !");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 注意:需要确保没有任何资源系统起效之前才可以设置!
|
|
||||||
if (_packages.Count > 0)
|
|
||||||
{
|
|
||||||
YooLogger.Error($"Please call this method {nameof(SetCacheSystemSandboxPath)} before the package is created !");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
PersistentTools.OverwriteSandboxPath(sandboxPath);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 设置缓存系统参数,禁用缓存在WebGL平台
|
/// 设置缓存系统参数,禁用缓存在WebGL平台
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -304,33 +262,6 @@ namespace YooAsset
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region 沙盒相关
|
|
||||||
/// <summary>
|
|
||||||
/// 获取内置文件夹名称
|
|
||||||
/// </summary>
|
|
||||||
public static string GetStreamingAssetBuildinFolderName()
|
|
||||||
{
|
|
||||||
return YooAssetSettings.StreamingAssetsBuildinFolder;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 获取沙盒的根路径
|
|
||||||
/// </summary>
|
|
||||||
public static string GetSandboxRoot()
|
|
||||||
{
|
|
||||||
return PersistentTools.GetPersistentRootPath();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 清空沙盒目录(需要重启APP)
|
|
||||||
/// </summary>
|
|
||||||
public static void ClearSandbox()
|
|
||||||
{
|
|
||||||
YooLogger.Warning("Clear sandbox folder files, Finally, restart the application !");
|
|
||||||
PersistentTools.DeleteSandbox();
|
|
||||||
}
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region 调试信息
|
#region 调试信息
|
||||||
internal static DebugReport GetDebugReport()
|
internal static DebugReport GetDebugReport()
|
||||||
{
|
{
|
||||||
|
|
|
@ -20,6 +20,7 @@ namespace YooAsset.Editor
|
||||||
}
|
}
|
||||||
|
|
||||||
private string _manifestPath = string.Empty;
|
private string _manifestPath = string.Empty;
|
||||||
|
private string _packageName = "DefaultPackage";
|
||||||
|
|
||||||
private void OnGUI()
|
private void OnGUI()
|
||||||
{
|
{
|
||||||
|
@ -39,7 +40,8 @@ namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
if (GUILayout.Button("导入补丁包(全部文件)", GUILayout.MaxWidth(150)))
|
if (GUILayout.Button("导入补丁包(全部文件)", GUILayout.MaxWidth(150)))
|
||||||
{
|
{
|
||||||
AssetBundleBuilderHelper.ClearStreamingAssetsFolder();
|
string streamingAssetsRoot = AssetBundleBuilderHelper.GetDefaultStreamingAssetsRoot();
|
||||||
|
EditorTools.ClearFolder(streamingAssetsRoot);
|
||||||
CopyPackageFiles(_manifestPath);
|
CopyPackageFiles(_manifestPath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -57,18 +59,18 @@ namespace YooAsset.Editor
|
||||||
// 拷贝核心文件
|
// 拷贝核心文件
|
||||||
{
|
{
|
||||||
string sourcePath = $"{outputDirectory}/{manifestFileName}.bytes";
|
string sourcePath = $"{outputDirectory}/{manifestFileName}.bytes";
|
||||||
string destPath = $"{AssetBundleBuilderHelper.GetStreamingAssetsFolderPath()}/{manifestFileName}.bytes";
|
string destPath = $"{AssetBundleBuilderHelper.GetDefaultStreamingAssetsRoot()}/{_packageName}/{manifestFileName}.bytes";
|
||||||
EditorTools.CopyFile(sourcePath, destPath, true);
|
EditorTools.CopyFile(sourcePath, destPath, true);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
string sourcePath = $"{outputDirectory}/{manifestFileName}.hash";
|
string sourcePath = $"{outputDirectory}/{manifestFileName}.hash";
|
||||||
string destPath = $"{AssetBundleBuilderHelper.GetStreamingAssetsFolderPath()}/{manifestFileName}.hash";
|
string destPath = $"{AssetBundleBuilderHelper.GetDefaultStreamingAssetsRoot()}/{_packageName}/{manifestFileName}.hash";
|
||||||
EditorTools.CopyFile(sourcePath, destPath, true);
|
EditorTools.CopyFile(sourcePath, destPath, true);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
string fileName = YooAssetSettingsData.GetPackageVersionFileName(manifest.PackageName);
|
string fileName = YooAssetSettingsData.GetPackageVersionFileName(manifest.PackageName);
|
||||||
string sourcePath = $"{outputDirectory}/{fileName}";
|
string sourcePath = $"{outputDirectory}/{fileName}";
|
||||||
string destPath = $"{AssetBundleBuilderHelper.GetStreamingAssetsFolderPath()}/{fileName}";
|
string destPath = $"{AssetBundleBuilderHelper.GetDefaultStreamingAssetsRoot()}/{_packageName}/{fileName}";
|
||||||
EditorTools.CopyFile(sourcePath, destPath, true);
|
EditorTools.CopyFile(sourcePath, destPath, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,7 +80,7 @@ namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
fileCount++;
|
fileCount++;
|
||||||
string sourcePath = $"{outputDirectory}/{packageBundle.FileName}";
|
string sourcePath = $"{outputDirectory}/{packageBundle.FileName}";
|
||||||
string destPath = $"{AssetBundleBuilderHelper.GetStreamingAssetsFolderPath()}/{packageBundle.FileName}";
|
string destPath = $"{AssetBundleBuilderHelper.GetDefaultStreamingAssetsRoot()}/{_packageName}/{packageBundle.FileName}";
|
||||||
EditorTools.CopyFile(sourcePath, destPath, true);
|
EditorTools.CopyFile(sourcePath, destPath, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue