mirror of
https://github.com/tuyoogame/YooAsset.git
synced 2026-05-22 00:11:41 +00:00
Compare commits
23 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9c05ac8cc2 | ||
|
|
55d1eb145e | ||
|
|
c8cdeb2ae1 | ||
|
|
9891ab23a2 | ||
|
|
9739fe2b79 | ||
|
|
c976221cbb | ||
|
|
8267904155 | ||
|
|
ef8a8ff497 | ||
|
|
2384921477 | ||
|
|
985b05f29d | ||
|
|
5254fb65ef | ||
|
|
8ff666d5e2 | ||
|
|
ed77d6dc1f | ||
|
|
7b41fd82a4 | ||
|
|
ac0112199d | ||
|
|
ef5e1e65f9 | ||
|
|
b330d26b4f | ||
|
|
93d7c34454 | ||
|
|
0bd5677e26 | ||
|
|
22e2e978ef | ||
|
|
65c2651105 | ||
|
|
ef13e19c48 | ||
|
|
69125e967f |
@@ -2,6 +2,31 @@
|
|||||||
|
|
||||||
All notable changes to this package will be documented in this file.
|
All notable changes to this package will be documented in this file.
|
||||||
|
|
||||||
|
## [1.4.8] - 2023-03-10
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- 修复了同步加载原生文件,程序卡死的问题。
|
||||||
|
- 修复了可编程构建管线,当项目里没有着色器,如果有引用内置着色器会导致打包失败的问题。
|
||||||
|
- 修复了在Unity2021.3版本下着色器收集界面错乱的问题。
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- 优化了打包逻辑,提高构建速度。
|
||||||
|
|
||||||
|
- 支持自定义日志处理,方便收集线上问题。
|
||||||
|
|
||||||
|
```c#
|
||||||
|
public class YooAssets
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 初始化资源系统
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="logger">自定义日志处理</param>
|
||||||
|
public static void Initialize(ILogger logger = null)
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
## [1.4.7] - 2023-03-03
|
## [1.4.7] - 2023-03-03
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|||||||
@@ -39,12 +39,6 @@ namespace YooAsset.Editor
|
|||||||
var buildParametersContext = new BuildParametersContext(buildParameters);
|
var buildParametersContext = new BuildParametersContext(buildParameters);
|
||||||
_buildContext.SetContextObject(buildParametersContext);
|
_buildContext.SetContextObject(buildParametersContext);
|
||||||
|
|
||||||
// 是否显示LOG
|
|
||||||
if (buildParameters.BuildMode == EBuildMode.SimulateBuild)
|
|
||||||
BuildLogger.EnableLog = false;
|
|
||||||
else
|
|
||||||
BuildLogger.EnableLog = true;
|
|
||||||
|
|
||||||
// 创建构建节点
|
// 创建构建节点
|
||||||
List<IBuildTask> pipeline;
|
List<IBuildTask> pipeline;
|
||||||
if (buildParameters.BuildPipeline == EBuildPipeline.BuiltinBuildPipeline)
|
if (buildParameters.BuildPipeline == EBuildPipeline.BuiltinBuildPipeline)
|
||||||
@@ -57,7 +51,7 @@ namespace YooAsset.Editor
|
|||||||
new TaskCopyRawFile(), //拷贝原生文件
|
new TaskCopyRawFile(), //拷贝原生文件
|
||||||
new TaskVerifyBuildResult(), //验证构建结果
|
new TaskVerifyBuildResult(), //验证构建结果
|
||||||
new TaskEncryption(), //加密资源文件
|
new TaskEncryption(), //加密资源文件
|
||||||
new TaskUpdateBuildInfo(), //更新构建信息
|
new TaskUpdatePatchInfo(), //更新补丁信息
|
||||||
new TaskCreatePatchManifest(), //创建清单文件
|
new TaskCreatePatchManifest(), //创建清单文件
|
||||||
new TaskCreateReport(), //创建报告文件
|
new TaskCreateReport(), //创建报告文件
|
||||||
new TaskCreatePatchPackage(), //制作补丁包
|
new TaskCreatePatchPackage(), //制作补丁包
|
||||||
@@ -74,7 +68,7 @@ namespace YooAsset.Editor
|
|||||||
new TaskCopyRawFile(), //拷贝原生文件
|
new TaskCopyRawFile(), //拷贝原生文件
|
||||||
new TaskVerifyBuildResult_SBP(), //验证构建结果
|
new TaskVerifyBuildResult_SBP(), //验证构建结果
|
||||||
new TaskEncryption(), //加密资源文件
|
new TaskEncryption(), //加密资源文件
|
||||||
new TaskUpdateBuildInfo(), //更新构建信息
|
new TaskUpdatePatchInfo(), //更新补丁信息
|
||||||
new TaskCreatePatchManifest(), //创建清单文件
|
new TaskCreatePatchManifest(), //创建清单文件
|
||||||
new TaskCreateReport(), //创建报告文件
|
new TaskCreateReport(), //创建报告文件
|
||||||
new TaskCreatePatchPackage(), //制作补丁包
|
new TaskCreatePatchPackage(), //制作补丁包
|
||||||
@@ -86,19 +80,23 @@ namespace YooAsset.Editor
|
|||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 初始化日志
|
||||||
|
BuildLogger.InitLogger(buildParameters.EnableLog);
|
||||||
|
|
||||||
// 执行构建流程
|
// 执行构建流程
|
||||||
var buildResult = BuildRunner.Run(pipeline, _buildContext);
|
var buildResult = BuildRunner.Run(pipeline, _buildContext);
|
||||||
if (buildResult.Success)
|
if (buildResult.Success)
|
||||||
{
|
{
|
||||||
buildResult.OutputPackageDirectory = buildParametersContext.GetPackageOutputDirectory();
|
buildResult.OutputPackageDirectory = buildParametersContext.GetPackageOutputDirectory();
|
||||||
Debug.Log($"{buildParameters.BuildMode} pipeline build succeed !");
|
BuildLogger.Log($"{buildParameters.BuildMode} pipeline build succeed !");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Debug.LogWarning($"{buildParameters.BuildMode} pipeline build failed !");
|
BuildLogger.Warning($"{buildParameters.BuildMode} pipeline build failed !");
|
||||||
Debug.LogError($"Build task failed : {buildResult.FailedTask}");
|
BuildLogger.Error($"Build task failed : {buildResult.FailedTask}");
|
||||||
Debug.LogError($"Build task error : {buildResult.FailedInfo}");
|
BuildLogger.Error($"Build task error : {buildResult.FailedInfo}");
|
||||||
}
|
}
|
||||||
|
|
||||||
return buildResult;
|
return buildResult;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ namespace YooAsset.Editor
|
|||||||
buildParameters.BuildMode = EBuildMode.SimulateBuild;
|
buildParameters.BuildMode = EBuildMode.SimulateBuild;
|
||||||
buildParameters.PackageName = packageName;
|
buildParameters.PackageName = packageName;
|
||||||
buildParameters.PackageVersion = "Simulate";
|
buildParameters.PackageVersion = "Simulate";
|
||||||
|
buildParameters.EnableLog = false;
|
||||||
|
|
||||||
AssetBundleBuilder builder = new AssetBundleBuilder();
|
AssetBundleBuilder builder = new AssetBundleBuilder();
|
||||||
var buildResult = builder.Run(buildParameters);
|
var buildResult = builder.Run(buildParameters);
|
||||||
|
|||||||
@@ -8,6 +8,8 @@ namespace YooAsset.Editor
|
|||||||
{
|
{
|
||||||
public class BuildMapContext : IContextObject
|
public class BuildMapContext : IContextObject
|
||||||
{
|
{
|
||||||
|
private readonly Dictionary<string, BuildBundleInfo> _bundleInfoDic = new Dictionary<string, BuildBundleInfo>(10000);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 参与构建的资源总数
|
/// 参与构建的资源总数
|
||||||
/// 说明:包括主动收集的资源以及其依赖的所有资源
|
/// 说明:包括主动收集的资源以及其依赖的所有资源
|
||||||
@@ -30,9 +32,15 @@ namespace YooAsset.Editor
|
|||||||
public string ShadersBundleName;
|
public string ShadersBundleName;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 资源包列表
|
/// 资源包信息列表
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public readonly List<BuildBundleInfo> BundleInfos = new List<BuildBundleInfo>(1000);
|
public Dictionary<string, BuildBundleInfo>.ValueCollection Collection
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _bundleInfoDic.Values;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -44,7 +52,7 @@ namespace YooAsset.Editor
|
|||||||
if (string.IsNullOrEmpty(bundleName))
|
if (string.IsNullOrEmpty(bundleName))
|
||||||
throw new Exception("Should never get here !");
|
throw new Exception("Should never get here !");
|
||||||
|
|
||||||
if (TryGetBundleInfo(bundleName, out BuildBundleInfo bundleInfo))
|
if (_bundleInfoDic.TryGetValue(bundleName, out BuildBundleInfo bundleInfo))
|
||||||
{
|
{
|
||||||
bundleInfo.PackAsset(assetInfo);
|
bundleInfo.PackAsset(assetInfo);
|
||||||
}
|
}
|
||||||
@@ -52,33 +60,28 @@ namespace YooAsset.Editor
|
|||||||
{
|
{
|
||||||
BuildBundleInfo newBundleInfo = new BuildBundleInfo(bundleName);
|
BuildBundleInfo newBundleInfo = new BuildBundleInfo(bundleName);
|
||||||
newBundleInfo.PackAsset(assetInfo);
|
newBundleInfo.PackAsset(assetInfo);
|
||||||
BundleInfos.Add(newBundleInfo);
|
_bundleInfoDic.Add(bundleName, newBundleInfo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取所有的打包资源
|
/// 是否包含资源包
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public List<BuildAssetInfo> GetAllAssets()
|
public bool IsContainsBundle(string bundleName)
|
||||||
{
|
{
|
||||||
List<BuildAssetInfo> result = new List<BuildAssetInfo>(BundleInfos.Count);
|
return _bundleInfoDic.ContainsKey(bundleName);
|
||||||
foreach (var bundleInfo in BundleInfos)
|
|
||||||
{
|
|
||||||
result.AddRange(bundleInfo.BuildinAssets);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取AssetBundle内构建的资源路径列表
|
/// 获取资源包信息,如果没找到返回NULL
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string[] GetBuildinAssetPaths(string bundleName)
|
public BuildBundleInfo GetBundleInfo(string bundleName)
|
||||||
{
|
{
|
||||||
if (TryGetBundleInfo(bundleName, out BuildBundleInfo bundleInfo))
|
if (_bundleInfoDic.TryGetValue(bundleName, out BuildBundleInfo result))
|
||||||
{
|
{
|
||||||
return bundleInfo.GetBuildinAssetPaths();
|
return result;
|
||||||
}
|
}
|
||||||
throw new Exception($"Not found {nameof(BuildBundleInfo)} : {bundleName}");
|
throw new Exception($"Not found bundle : {bundleName}");
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -86,8 +89,8 @@ namespace YooAsset.Editor
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public UnityEditor.AssetBundleBuild[] GetPipelineBuilds()
|
public UnityEditor.AssetBundleBuild[] GetPipelineBuilds()
|
||||||
{
|
{
|
||||||
List<UnityEditor.AssetBundleBuild> builds = new List<UnityEditor.AssetBundleBuild>(BundleInfos.Count);
|
List<UnityEditor.AssetBundleBuild> builds = new List<UnityEditor.AssetBundleBuild>(_bundleInfoDic.Count);
|
||||||
foreach (var bundleInfo in BundleInfos)
|
foreach (var bundleInfo in _bundleInfoDic.Values)
|
||||||
{
|
{
|
||||||
if (bundleInfo.IsRawFile == false)
|
if (bundleInfo.IsRawFile == false)
|
||||||
builds.Add(bundleInfo.CreatePipelineBuild());
|
builds.Add(bundleInfo.CreatePipelineBuild());
|
||||||
@@ -96,25 +99,15 @@ namespace YooAsset.Editor
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 是否包含资源包
|
/// 创建着色器信息类
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool IsContainsBundle(string bundleName)
|
public void CreateShadersBundleInfo(string shadersBundleName)
|
||||||
{
|
{
|
||||||
return TryGetBundleInfo(bundleName, out BuildBundleInfo bundleInfo);
|
if (IsContainsBundle(shadersBundleName) == false)
|
||||||
}
|
|
||||||
|
|
||||||
public bool TryGetBundleInfo(string bundleName, out BuildBundleInfo result)
|
|
||||||
{
|
|
||||||
foreach (var bundleInfo in BundleInfos)
|
|
||||||
{
|
{
|
||||||
if (bundleInfo.BundleName == bundleName)
|
var shaderBundleInfo = new BuildBundleInfo(shadersBundleName);
|
||||||
{
|
_bundleInfoDic.Add(shadersBundleName, shaderBundleInfo);
|
||||||
result = bundleInfo;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
result = null;
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,145 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
|
||||||
{
|
|
||||||
public static class BuildMapCreater
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// 执行资源构建上下文
|
|
||||||
/// </summary>
|
|
||||||
public static BuildMapContext CreateBuildMap(EBuildMode buildMode, string packageName)
|
|
||||||
{
|
|
||||||
Dictionary<string, BuildAssetInfo> buildAssetDic = new Dictionary<string, BuildAssetInfo>(1000);
|
|
||||||
|
|
||||||
// 1. 检测配置合法性
|
|
||||||
AssetBundleCollectorSettingData.Setting.CheckConfigError();
|
|
||||||
|
|
||||||
// 2. 获取所有收集器收集的资源
|
|
||||||
var buildResult = AssetBundleCollectorSettingData.Setting.GetPackageAssets(buildMode, packageName);
|
|
||||||
List<CollectAssetInfo> allCollectAssets = buildResult.CollectAssets;
|
|
||||||
|
|
||||||
// 3. 剔除未被引用的依赖项资源
|
|
||||||
List<CollectAssetInfo> removeDependList = new List<CollectAssetInfo>();
|
|
||||||
foreach (var collectAssetInfo in allCollectAssets)
|
|
||||||
{
|
|
||||||
if (collectAssetInfo.CollectorType == ECollectorType.DependAssetCollector)
|
|
||||||
{
|
|
||||||
if (IsRemoveDependAsset(allCollectAssets, collectAssetInfo.AssetPath))
|
|
||||||
removeDependList.Add(collectAssetInfo);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
foreach (var removeValue in removeDependList)
|
|
||||||
{
|
|
||||||
allCollectAssets.Remove(removeValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 4. 录入所有收集器收集的资源
|
|
||||||
foreach (var collectAssetInfo in allCollectAssets)
|
|
||||||
{
|
|
||||||
if (buildAssetDic.ContainsKey(collectAssetInfo.AssetPath) == false)
|
|
||||||
{
|
|
||||||
var buildAssetInfo = new BuildAssetInfo(
|
|
||||||
collectAssetInfo.CollectorType, collectAssetInfo.BundleName,
|
|
||||||
collectAssetInfo.Address, collectAssetInfo.AssetPath, collectAssetInfo.IsRawAsset);
|
|
||||||
buildAssetInfo.AddAssetTags(collectAssetInfo.AssetTags);
|
|
||||||
buildAssetInfo.AddBundleTags(collectAssetInfo.AssetTags);
|
|
||||||
buildAssetDic.Add(collectAssetInfo.AssetPath, buildAssetInfo);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
throw new Exception($"Should never get here !");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 5. 录入所有收集资源的依赖资源
|
|
||||||
foreach (var collectAssetInfo in allCollectAssets)
|
|
||||||
{
|
|
||||||
string collectAssetBundleName = collectAssetInfo.BundleName;
|
|
||||||
foreach (var dependAssetPath in collectAssetInfo.DependAssets)
|
|
||||||
{
|
|
||||||
if (buildAssetDic.ContainsKey(dependAssetPath))
|
|
||||||
{
|
|
||||||
buildAssetDic[dependAssetPath].AddBundleTags(collectAssetInfo.AssetTags);
|
|
||||||
buildAssetDic[dependAssetPath].AddReferenceBundleName(collectAssetBundleName);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
var buildAssetInfo = new BuildAssetInfo(dependAssetPath);
|
|
||||||
buildAssetInfo.AddBundleTags(collectAssetInfo.AssetTags);
|
|
||||||
buildAssetInfo.AddReferenceBundleName(collectAssetBundleName);
|
|
||||||
buildAssetDic.Add(dependAssetPath, buildAssetInfo);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 6. 填充所有收集资源的依赖列表
|
|
||||||
foreach (var collectAssetInfo in allCollectAssets)
|
|
||||||
{
|
|
||||||
var dependAssetInfos = new List<BuildAssetInfo>(collectAssetInfo.DependAssets.Count);
|
|
||||||
foreach (var dependAssetPath in collectAssetInfo.DependAssets)
|
|
||||||
{
|
|
||||||
if (buildAssetDic.TryGetValue(dependAssetPath, out BuildAssetInfo value))
|
|
||||||
dependAssetInfos.Add(value);
|
|
||||||
else
|
|
||||||
throw new Exception("Should never get here !");
|
|
||||||
}
|
|
||||||
buildAssetDic[collectAssetInfo.AssetPath].SetAllDependAssetInfos(dependAssetInfos);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 7. 记录关键信息
|
|
||||||
BuildMapContext context = new BuildMapContext();
|
|
||||||
context.AssetFileCount = buildAssetDic.Count;
|
|
||||||
context.EnableAddressable = buildResult.Command.EnableAddressable;
|
|
||||||
context.UniqueBundleName = buildResult.Command.UniqueBundleName;
|
|
||||||
context.ShadersBundleName = buildResult.ShadersBundleName;
|
|
||||||
|
|
||||||
// 8. 计算共享的资源包名
|
|
||||||
var command = buildResult.Command;
|
|
||||||
foreach (KeyValuePair<string, BuildAssetInfo> pair in buildAssetDic)
|
|
||||||
{
|
|
||||||
pair.Value.CalculateShareBundleName(command.UniqueBundleName, command.PackageName, buildResult.ShadersBundleName);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 9. 移除不参与构建的资源
|
|
||||||
List<BuildAssetInfo> removeBuildList = new List<BuildAssetInfo>();
|
|
||||||
foreach (KeyValuePair<string, BuildAssetInfo> pair in buildAssetDic)
|
|
||||||
{
|
|
||||||
var buildAssetInfo = pair.Value;
|
|
||||||
if (buildAssetInfo.HasBundleName() == false)
|
|
||||||
removeBuildList.Add(buildAssetInfo);
|
|
||||||
}
|
|
||||||
foreach (var removeValue in removeBuildList)
|
|
||||||
{
|
|
||||||
buildAssetDic.Remove(removeValue.AssetPath);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 10. 构建资源包
|
|
||||||
var allBuildinAssets = buildAssetDic.Values.ToList();
|
|
||||||
if (allBuildinAssets.Count == 0)
|
|
||||||
throw new Exception("构建的资源列表不能为空");
|
|
||||||
foreach (var assetInfo in allBuildinAssets)
|
|
||||||
{
|
|
||||||
context.PackAsset(assetInfo);
|
|
||||||
}
|
|
||||||
return context;
|
|
||||||
}
|
|
||||||
private static bool IsRemoveDependAsset(List<CollectAssetInfo> allCollectAssets, string dependAssetPath)
|
|
||||||
{
|
|
||||||
foreach (var collectAssetInfo in allCollectAssets)
|
|
||||||
{
|
|
||||||
var collectorType = collectAssetInfo.CollectorType;
|
|
||||||
if (collectorType == ECollectorType.MainAssetCollector || collectorType == ECollectorType.StaticAssetCollector)
|
|
||||||
{
|
|
||||||
if (collectAssetInfo.DependAssets.Contains(dependAssetPath))
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
BuildLogger.Log($"发现未被依赖的资源并自动移除 : {dependAssetPath}");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -67,6 +67,11 @@ namespace YooAsset.Editor
|
|||||||
public string PackageVersion;
|
public string PackageVersion;
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 是否显示普通日志
|
||||||
|
/// </summary>
|
||||||
|
public bool EnableLog = true;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 验证构建结果
|
/// 验证构建结果
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -1,30 +1,33 @@
|
|||||||
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
public static class BuildLogger
|
public static class BuildLogger
|
||||||
{
|
{
|
||||||
/// <summary>
|
private static bool _enableLog = true;
|
||||||
/// 是否启用LOG
|
|
||||||
/// </summary>
|
|
||||||
public static bool EnableLog = true;
|
|
||||||
|
|
||||||
/// <summary>
|
public static void InitLogger(bool enableLog)
|
||||||
/// 日志输出
|
|
||||||
/// </summary>
|
|
||||||
public static void Log(string info)
|
|
||||||
{
|
{
|
||||||
if (EnableLog)
|
_enableLog = enableLog;
|
||||||
{
|
|
||||||
UnityEngine.Debug.Log(info);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
public static void Log(string message)
|
||||||
/// 日志输出
|
|
||||||
/// </summary>
|
|
||||||
public static void Info(string info)
|
|
||||||
{
|
{
|
||||||
UnityEngine.Debug.Log(info);
|
if (_enableLog)
|
||||||
|
{
|
||||||
|
Debug.Log(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public static void Warning(string message)
|
||||||
|
{
|
||||||
|
Debug.LogWarning(message);
|
||||||
|
}
|
||||||
|
public static void Error(string message)
|
||||||
|
{
|
||||||
|
Debug.LogError(message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -40,6 +40,15 @@ namespace YooAsset.Editor
|
|||||||
throw new Exception($"构建过程中发生错误 : {exitCode}");
|
throw new Exception($"构建过程中发生错误 : {exitCode}");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 创建着色器信息
|
||||||
|
// 说明:解决因为着色器资源包导致验证失败。
|
||||||
|
// 例如:当项目里没有着色器,如果有依赖内置着色器就会验证失败。
|
||||||
|
string shadersBundleName = buildMapContext.ShadersBundleName;
|
||||||
|
if (buildResults.BundleInfos.ContainsKey(shadersBundleName))
|
||||||
|
{
|
||||||
|
buildMapContext.CreateShadersBundleInfo(shadersBundleName);
|
||||||
|
}
|
||||||
|
|
||||||
BuildLogger.Log("Unity引擎打包成功!");
|
BuildLogger.Log("Unity引擎打包成功!");
|
||||||
BuildResultContext buildResultContext = new BuildResultContext();
|
BuildResultContext buildResultContext = new BuildResultContext();
|
||||||
buildResultContext.Results = buildResults;
|
buildResultContext.Results = buildResults;
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ namespace YooAsset.Editor
|
|||||||
private void CopyRawBundle(BuildMapContext buildMapContext, BuildParametersContext buildParametersContext)
|
private void CopyRawBundle(BuildMapContext buildMapContext, BuildParametersContext buildParametersContext)
|
||||||
{
|
{
|
||||||
string pipelineOutputDirectory = buildParametersContext.GetPipelineOutputDirectory();
|
string pipelineOutputDirectory = buildParametersContext.GetPipelineOutputDirectory();
|
||||||
foreach (var bundleInfo in buildMapContext.BundleInfos)
|
foreach (var bundleInfo in buildMapContext.Collection)
|
||||||
{
|
{
|
||||||
if (bundleInfo.IsRawFile)
|
if (bundleInfo.IsRawFile)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -119,7 +119,7 @@ namespace YooAsset.Editor
|
|||||||
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
||||||
|
|
||||||
List<PatchBundle> result = new List<PatchBundle>(1000);
|
List<PatchBundle> result = new List<PatchBundle>(1000);
|
||||||
foreach (var bundleInfo in buildMapContext.BundleInfos)
|
foreach (var bundleInfo in buildMapContext.Collection)
|
||||||
{
|
{
|
||||||
var patchBundle = bundleInfo.CreatePatchBundle();
|
var patchBundle = bundleInfo.CreatePatchBundle();
|
||||||
result.Add(patchBundle);
|
result.Add(patchBundle);
|
||||||
@@ -135,7 +135,7 @@ namespace YooAsset.Editor
|
|||||||
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
||||||
|
|
||||||
List<PatchAsset> result = new List<PatchAsset>(1000);
|
List<PatchAsset> result = new List<PatchAsset>(1000);
|
||||||
foreach (var bundleInfo in buildMapContext.BundleInfos)
|
foreach (var bundleInfo in buildMapContext.Collection)
|
||||||
{
|
{
|
||||||
var assetInfos = bundleInfo.GetAllPatchAssetInfos();
|
var assetInfos = bundleInfo.GetAllPatchAssetInfos();
|
||||||
foreach (var assetInfo in assetInfos)
|
foreach (var assetInfo in assetInfos)
|
||||||
@@ -257,7 +257,10 @@ namespace YooAsset.Editor
|
|||||||
foreach (var patchBundle in patchManifest.BundleList)
|
foreach (var patchBundle in patchManifest.BundleList)
|
||||||
{
|
{
|
||||||
if (patchBundle.IsRawFile)
|
if (patchBundle.IsRawFile)
|
||||||
|
{
|
||||||
|
_cachedBundleDepends.Add(patchBundle.BundleName, new string[] { });
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (buildResultContext.Results.BundleInfos.ContainsKey(patchBundle.BundleName) == false)
|
if (buildResultContext.Results.BundleInfos.ContainsKey(patchBundle.BundleName) == false)
|
||||||
throw new Exception($"Not found bundle in SBP build results : {patchBundle.BundleName}");
|
throw new Exception($"Not found bundle in SBP build results : {patchBundle.BundleName}");
|
||||||
@@ -297,6 +300,12 @@ namespace YooAsset.Editor
|
|||||||
progressValue = 0;
|
progressValue = 0;
|
||||||
foreach (var patchBundle in patchManifest.BundleList)
|
foreach (var patchBundle in patchManifest.BundleList)
|
||||||
{
|
{
|
||||||
|
if (patchBundle.IsRawFile)
|
||||||
|
{
|
||||||
|
_cachedBundleDepends.Add(patchBundle.BundleName, new string[] { } );
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
var depends = buildResultContext.UnityManifest.GetDirectDependencies(patchBundle.BundleName);
|
var depends = buildResultContext.UnityManifest.GetDirectDependencies(patchBundle.BundleName);
|
||||||
_cachedBundleDepends.Add(patchBundle.BundleName, depends);
|
_cachedBundleDepends.Add(patchBundle.BundleName, depends);
|
||||||
EditorTools.DisplayProgressBar("缓存资源包依赖列表", ++progressValue, totalCount);
|
EditorTools.DisplayProgressBar("缓存资源包依赖列表", ++progressValue, totalCount);
|
||||||
|
|||||||
@@ -67,8 +67,8 @@ namespace YooAsset.Editor
|
|||||||
|
|
||||||
// 拷贝所有补丁文件
|
// 拷贝所有补丁文件
|
||||||
int progressValue = 0;
|
int progressValue = 0;
|
||||||
int patchFileTotalCount = buildMapContext.BundleInfos.Count;
|
int patchFileTotalCount = buildMapContext.Collection.Count;
|
||||||
foreach (var bundleInfo in buildMapContext.BundleInfos)
|
foreach (var bundleInfo in buildMapContext.Collection)
|
||||||
{
|
{
|
||||||
EditorTools.CopyFile(bundleInfo.PatchInfo.BuildOutputFilePath, bundleInfo.PatchInfo.PatchOutputFilePath, true);
|
EditorTools.CopyFile(bundleInfo.PatchInfo.BuildOutputFilePath, bundleInfo.PatchInfo.PatchOutputFilePath, true);
|
||||||
EditorTools.DisplayProgressBar("拷贝补丁文件", ++progressValue, patchFileTotalCount);
|
EditorTools.DisplayProgressBar("拷贝补丁文件", ++progressValue, patchFileTotalCount);
|
||||||
|
|||||||
@@ -127,7 +127,7 @@ namespace YooAsset.Editor
|
|||||||
private List<string> GetDependAssets(BuildMapContext buildMapContext, string bundleName, string assetPath)
|
private List<string> GetDependAssets(BuildMapContext buildMapContext, string bundleName, string assetPath)
|
||||||
{
|
{
|
||||||
List<string> result = new List<string>();
|
List<string> result = new List<string>();
|
||||||
if (buildMapContext.TryGetBundleInfo(bundleName, out BuildBundleInfo bundleInfo))
|
var bundleInfo = buildMapContext.GetBundleInfo(bundleName);
|
||||||
{
|
{
|
||||||
BuildAssetInfo findAssetInfo = null;
|
BuildAssetInfo findAssetInfo = null;
|
||||||
foreach (var buildinAsset in bundleInfo.BuildinAssets)
|
foreach (var buildinAsset in bundleInfo.BuildinAssets)
|
||||||
@@ -147,10 +147,6 @@ namespace YooAsset.Editor
|
|||||||
result.Add(dependAssetInfo.AssetPath);
|
result.Add(dependAssetInfo.AssetPath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
throw new Exception($"Not found bundle : {bundleName}");
|
|
||||||
}
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ namespace YooAsset.Editor
|
|||||||
|
|
||||||
int progressValue = 0;
|
int progressValue = 0;
|
||||||
string pipelineOutputDirectory = buildParametersContext.GetPipelineOutputDirectory();
|
string pipelineOutputDirectory = buildParametersContext.GetPipelineOutputDirectory();
|
||||||
foreach (var bundleInfo in buildMapContext.BundleInfos)
|
foreach (var bundleInfo in buildMapContext.Collection)
|
||||||
{
|
{
|
||||||
EncryptFileInfo fileInfo = new EncryptFileInfo();
|
EncryptFileInfo fileInfo = new EncryptFileInfo();
|
||||||
fileInfo.BundleName = bundleInfo.BundleName;
|
fileInfo.BundleName = bundleInfo.BundleName;
|
||||||
@@ -47,7 +47,7 @@ namespace YooAsset.Editor
|
|||||||
// 注意:原生文件不支持加密
|
// 注意:原生文件不支持加密
|
||||||
if (bundleInfo.IsRawFile)
|
if (bundleInfo.IsRawFile)
|
||||||
{
|
{
|
||||||
UnityEngine.Debug.LogWarning($"Encryption not support raw file : {bundleInfo.BundleName}");
|
BuildLogger.Warning($"Encryption not support raw file : {bundleInfo.BundleName}");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -59,7 +59,7 @@ namespace YooAsset.Editor
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 进度条
|
// 进度条
|
||||||
EditorTools.DisplayProgressBar("加密资源包", ++progressValue, buildMapContext.BundleInfos.Count);
|
EditorTools.DisplayProgressBar("加密资源包", ++progressValue, buildMapContext.Collection.Count);
|
||||||
}
|
}
|
||||||
EditorTools.ClearProgressBar();
|
EditorTools.ClearProgressBar();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ namespace YooAsset.Editor
|
|||||||
void IBuildTask.Run(BuildContext context)
|
void IBuildTask.Run(BuildContext context)
|
||||||
{
|
{
|
||||||
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||||
var buildMapContext = BuildMapCreater.CreateBuildMap(buildParametersContext.Parameters.BuildMode, buildParametersContext.Parameters.PackageName);
|
var buildMapContext = CreateBuildMap(buildParametersContext.Parameters.BuildMode, buildParametersContext.Parameters.PackageName);
|
||||||
context.SetContextObject(buildMapContext);
|
context.SetContextObject(buildMapContext);
|
||||||
BuildLogger.Log("构建内容准备完毕!");
|
BuildLogger.Log("构建内容准备完毕!");
|
||||||
|
|
||||||
@@ -21,12 +21,147 @@ namespace YooAsset.Editor
|
|||||||
CheckBuildMapContent(buildMapContext);
|
CheckBuildMapContent(buildMapContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 资源构建上下文
|
||||||
|
/// </summary>
|
||||||
|
public BuildMapContext CreateBuildMap(EBuildMode buildMode, string packageName)
|
||||||
|
{
|
||||||
|
Dictionary<string, BuildAssetInfo> buildAssetInfoDic = new Dictionary<string, BuildAssetInfo>(1000);
|
||||||
|
|
||||||
|
// 1. 检测配置合法性
|
||||||
|
AssetBundleCollectorSettingData.Setting.CheckConfigError();
|
||||||
|
|
||||||
|
// 2. 获取所有收集器收集的资源
|
||||||
|
var collectResult = AssetBundleCollectorSettingData.Setting.GetPackageAssets(buildMode, packageName);
|
||||||
|
List<CollectAssetInfo> collectAssetInfos = collectResult.CollectAssets;
|
||||||
|
|
||||||
|
// 3. 剔除未被引用的依赖项资源
|
||||||
|
List<CollectAssetInfo> removeDependList = new List<CollectAssetInfo>();
|
||||||
|
foreach (var collectAssetInfo in collectAssetInfos)
|
||||||
|
{
|
||||||
|
if (collectAssetInfo.CollectorType == ECollectorType.DependAssetCollector)
|
||||||
|
{
|
||||||
|
if (IsRemoveDependAsset(collectAssetInfos, collectAssetInfo.AssetPath))
|
||||||
|
removeDependList.Add(collectAssetInfo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
foreach (var removeValue in removeDependList)
|
||||||
|
{
|
||||||
|
collectAssetInfos.Remove(removeValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 4. 录入所有收集器收集的资源
|
||||||
|
foreach (var collectAssetInfo in collectAssetInfos)
|
||||||
|
{
|
||||||
|
if (buildAssetInfoDic.ContainsKey(collectAssetInfo.AssetPath) == false)
|
||||||
|
{
|
||||||
|
var buildAssetInfo = new BuildAssetInfo(
|
||||||
|
collectAssetInfo.CollectorType, collectAssetInfo.BundleName,
|
||||||
|
collectAssetInfo.Address, collectAssetInfo.AssetPath, collectAssetInfo.IsRawAsset);
|
||||||
|
buildAssetInfo.AddAssetTags(collectAssetInfo.AssetTags);
|
||||||
|
buildAssetInfo.AddBundleTags(collectAssetInfo.AssetTags);
|
||||||
|
buildAssetInfoDic.Add(collectAssetInfo.AssetPath, buildAssetInfo);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new Exception($"Should never get here !");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 5. 录入所有收集资源的依赖资源
|
||||||
|
foreach (var collectAssetInfo in collectAssetInfos)
|
||||||
|
{
|
||||||
|
string collectAssetBundleName = collectAssetInfo.BundleName;
|
||||||
|
foreach (var dependAssetPath in collectAssetInfo.DependAssets)
|
||||||
|
{
|
||||||
|
if (buildAssetInfoDic.ContainsKey(dependAssetPath))
|
||||||
|
{
|
||||||
|
buildAssetInfoDic[dependAssetPath].AddBundleTags(collectAssetInfo.AssetTags);
|
||||||
|
buildAssetInfoDic[dependAssetPath].AddReferenceBundleName(collectAssetBundleName);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var buildAssetInfo = new BuildAssetInfo(dependAssetPath);
|
||||||
|
buildAssetInfo.AddBundleTags(collectAssetInfo.AssetTags);
|
||||||
|
buildAssetInfo.AddReferenceBundleName(collectAssetBundleName);
|
||||||
|
buildAssetInfoDic.Add(dependAssetPath, buildAssetInfo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 6. 填充所有收集资源的依赖列表
|
||||||
|
foreach (var collectAssetInfo in collectAssetInfos)
|
||||||
|
{
|
||||||
|
var dependAssetInfos = new List<BuildAssetInfo>(collectAssetInfo.DependAssets.Count);
|
||||||
|
foreach (var dependAssetPath in collectAssetInfo.DependAssets)
|
||||||
|
{
|
||||||
|
if (buildAssetInfoDic.TryGetValue(dependAssetPath, out BuildAssetInfo value))
|
||||||
|
dependAssetInfos.Add(value);
|
||||||
|
else
|
||||||
|
throw new Exception("Should never get here !");
|
||||||
|
}
|
||||||
|
buildAssetInfoDic[collectAssetInfo.AssetPath].SetAllDependAssetInfos(dependAssetInfos);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 7. 记录关键信息
|
||||||
|
BuildMapContext context = new BuildMapContext();
|
||||||
|
context.AssetFileCount = buildAssetInfoDic.Count;
|
||||||
|
context.EnableAddressable = collectResult.Command.EnableAddressable;
|
||||||
|
context.UniqueBundleName = collectResult.Command.UniqueBundleName;
|
||||||
|
context.ShadersBundleName = collectResult.Command.ShadersBundleName;
|
||||||
|
|
||||||
|
// 8. 计算共享的资源包名
|
||||||
|
var command = collectResult.Command;
|
||||||
|
foreach (KeyValuePair<string, BuildAssetInfo> pair in buildAssetInfoDic)
|
||||||
|
{
|
||||||
|
pair.Value.CalculateShareBundleName(command.UniqueBundleName, command.PackageName, command.ShadersBundleName);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 9. 移除不参与构建的资源
|
||||||
|
List<BuildAssetInfo> removeBuildList = new List<BuildAssetInfo>();
|
||||||
|
foreach (KeyValuePair<string, BuildAssetInfo> pair in buildAssetInfoDic)
|
||||||
|
{
|
||||||
|
var buildAssetInfo = pair.Value;
|
||||||
|
if (buildAssetInfo.HasBundleName() == false)
|
||||||
|
removeBuildList.Add(buildAssetInfo);
|
||||||
|
}
|
||||||
|
foreach (var removeValue in removeBuildList)
|
||||||
|
{
|
||||||
|
buildAssetInfoDic.Remove(removeValue.AssetPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 10. 构建资源包
|
||||||
|
var allBuildinAssets = buildAssetInfoDic.Values.ToList();
|
||||||
|
if (allBuildinAssets.Count == 0)
|
||||||
|
throw new Exception("构建的资源列表不能为空");
|
||||||
|
foreach (var assetInfo in allBuildinAssets)
|
||||||
|
{
|
||||||
|
context.PackAsset(assetInfo);
|
||||||
|
}
|
||||||
|
return context;
|
||||||
|
}
|
||||||
|
private bool IsRemoveDependAsset(List<CollectAssetInfo> allCollectAssets, string dependAssetPath)
|
||||||
|
{
|
||||||
|
foreach (var collectAssetInfo in allCollectAssets)
|
||||||
|
{
|
||||||
|
var collectorType = collectAssetInfo.CollectorType;
|
||||||
|
if (collectorType == ECollectorType.MainAssetCollector || collectorType == ECollectorType.StaticAssetCollector)
|
||||||
|
{
|
||||||
|
if (collectAssetInfo.DependAssets.Contains(dependAssetPath))
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
BuildLogger.Log($"发现未被依赖的资源并自动移除 : {dependAssetPath}");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 检测构建结果
|
/// 检测构建结果
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private void CheckBuildMapContent(BuildMapContext buildMapContext)
|
private void CheckBuildMapContent(BuildMapContext buildMapContext)
|
||||||
{
|
{
|
||||||
foreach (var bundleInfo in buildMapContext.BundleInfos)
|
foreach (var bundleInfo in buildMapContext.Collection)
|
||||||
{
|
{
|
||||||
// 注意:原生文件资源包只能包含一个原生文件
|
// 注意:原生文件资源包只能包含一个原生文件
|
||||||
bool isRawFile = bundleInfo.IsRawFile;
|
bool isRawFile = bundleInfo.IsRawFile;
|
||||||
|
|||||||
@@ -6,8 +6,8 @@ using UnityEditor;
|
|||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
[TaskAttribute("更新构建信息")]
|
[TaskAttribute("更新补丁信息")]
|
||||||
public class TaskUpdateBuildInfo : IBuildTask
|
public class TaskUpdatePatchInfo : IBuildTask
|
||||||
{
|
{
|
||||||
void IBuildTask.Run(BuildContext context)
|
void IBuildTask.Run(BuildContext context)
|
||||||
{
|
{
|
||||||
@@ -18,7 +18,7 @@ namespace YooAsset.Editor
|
|||||||
int outputNameStyle = (int)buildParametersContext.Parameters.OutputNameStyle;
|
int outputNameStyle = (int)buildParametersContext.Parameters.OutputNameStyle;
|
||||||
|
|
||||||
// 1.检测路径长度
|
// 1.检测路径长度
|
||||||
foreach (var bundleInfo in buildMapContext.BundleInfos)
|
foreach (var bundleInfo in buildMapContext.Collection)
|
||||||
{
|
{
|
||||||
// NOTE:检测路径长度不要超过260字符。
|
// NOTE:检测路径长度不要超过260字符。
|
||||||
string filePath = $"{pipelineOutputDirectory}/{bundleInfo.BundleName}";
|
string filePath = $"{pipelineOutputDirectory}/{bundleInfo.BundleName}";
|
||||||
@@ -27,7 +27,7 @@ namespace YooAsset.Editor
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 2.更新构建输出的文件路径
|
// 2.更新构建输出的文件路径
|
||||||
foreach (var bundleInfo in buildMapContext.BundleInfos)
|
foreach (var bundleInfo in buildMapContext.Collection)
|
||||||
{
|
{
|
||||||
if (bundleInfo.IsEncryptedFile)
|
if (bundleInfo.IsEncryptedFile)
|
||||||
bundleInfo.PatchInfo.BuildOutputFilePath = bundleInfo.EncryptedFilePath;
|
bundleInfo.PatchInfo.BuildOutputFilePath = bundleInfo.EncryptedFilePath;
|
||||||
@@ -36,7 +36,7 @@ namespace YooAsset.Editor
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 3.更新文件其它信息
|
// 3.更新文件其它信息
|
||||||
foreach (var bundleInfo in buildMapContext.BundleInfos)
|
foreach (var bundleInfo in buildMapContext.Collection)
|
||||||
{
|
{
|
||||||
string buildOutputFilePath = bundleInfo.PatchInfo.BuildOutputFilePath;
|
string buildOutputFilePath = bundleInfo.PatchInfo.BuildOutputFilePath;
|
||||||
bundleInfo.PatchInfo.ContentHash = GetBundleContentHash(bundleInfo, context);
|
bundleInfo.PatchInfo.ContentHash = GetBundleContentHash(bundleInfo, context);
|
||||||
@@ -46,7 +46,7 @@ namespace YooAsset.Editor
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 4.更新补丁包输出的文件路径
|
// 4.更新补丁包输出的文件路径
|
||||||
foreach (var bundleInfo in buildMapContext.BundleInfos)
|
foreach (var bundleInfo in buildMapContext.Collection)
|
||||||
{
|
{
|
||||||
string patchFileExtension = PatchManifestTools.GetRemoteBundleFileExtension(bundleInfo.BundleName);
|
string patchFileExtension = PatchManifestTools.GetRemoteBundleFileExtension(bundleInfo.BundleName);
|
||||||
string patchFileName = PatchManifestTools.GetRemoteBundleFileName(outputNameStyle, bundleInfo.BundleName, patchFileExtension, bundleInfo.PatchInfo.PatchFileHash);
|
string patchFileName = PatchManifestTools.GetRemoteBundleFileName(outputNameStyle, bundleInfo.BundleName, patchFileExtension, bundleInfo.PatchInfo.PatchFileHash);
|
||||||
@@ -34,29 +34,29 @@ namespace YooAsset.Editor
|
|||||||
{
|
{
|
||||||
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||||
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
||||||
string[] buildedBundles = unityManifest.GetAllAssetBundles();
|
string[] unityCreateBundles = unityManifest.GetAllAssetBundles();
|
||||||
|
|
||||||
// 1. 过滤掉原生Bundle
|
// 1. 过滤掉原生Bundle
|
||||||
string[] mapBundles = buildMapContext.BundleInfos.Where(t => t.IsRawFile == false).Select(t => t.BundleName).ToArray();
|
string[] mapBundles = buildMapContext.Collection.Where(t => t.IsRawFile == false).Select(t => t.BundleName).ToArray();
|
||||||
|
|
||||||
// 2. 验证Bundle
|
// 2. 验证Bundle
|
||||||
List<string> exceptBundleList1 = buildedBundles.Except(mapBundles).ToList();
|
List<string> exceptBundleList1 = unityCreateBundles.Except(mapBundles).ToList();
|
||||||
if (exceptBundleList1.Count > 0)
|
if (exceptBundleList1.Count > 0)
|
||||||
{
|
{
|
||||||
foreach (var exceptBundle in exceptBundleList1)
|
foreach (var exceptBundle in exceptBundleList1)
|
||||||
{
|
{
|
||||||
Debug.LogWarning($"差异资源包: {exceptBundle}");
|
BuildLogger.Warning($"差异资源包: {exceptBundle}");
|
||||||
}
|
}
|
||||||
throw new System.Exception("存在差异资源包!请查看警告信息!");
|
throw new System.Exception("存在差异资源包!请查看警告信息!");
|
||||||
}
|
}
|
||||||
|
|
||||||
// 3. 验证Bundle
|
// 3. 验证Bundle
|
||||||
List<string> exceptBundleList2 = mapBundles.Except(buildedBundles).ToList();
|
List<string> exceptBundleList2 = mapBundles.Except(unityCreateBundles).ToList();
|
||||||
if (exceptBundleList2.Count > 0)
|
if (exceptBundleList2.Count > 0)
|
||||||
{
|
{
|
||||||
foreach (var exceptBundle in exceptBundleList2)
|
foreach (var exceptBundle in exceptBundleList2)
|
||||||
{
|
{
|
||||||
Debug.LogWarning($"差异资源包: {exceptBundle}");
|
BuildLogger.Warning($"差异资源包: {exceptBundle}");
|
||||||
}
|
}
|
||||||
throw new System.Exception("存在差异资源包!请查看警告信息!");
|
throw new System.Exception("存在差异资源包!请查看警告信息!");
|
||||||
}
|
}
|
||||||
@@ -76,16 +76,16 @@ namespace YooAsset.Editor
|
|||||||
string[] mapAssetPaths = buildMapContext.GetBuildinAssetPaths(buildedBundle);
|
string[] mapAssetPaths = buildMapContext.GetBuildinAssetPaths(buildedBundle);
|
||||||
if (mapAssetPaths.Length != buildedAssetPaths.Length)
|
if (mapAssetPaths.Length != buildedAssetPaths.Length)
|
||||||
{
|
{
|
||||||
Debug.LogWarning($"构建的Bundle文件内的资源对象数量和预期不匹配 : {buildedBundle}");
|
BuildLogger.Warning($"构建的Bundle文件内的资源对象数量和预期不匹配 : {buildedBundle}");
|
||||||
var exceptAssetList1 = mapAssetPaths.Except(buildedAssetPaths).ToList();
|
var exceptAssetList1 = mapAssetPaths.Except(buildedAssetPaths).ToList();
|
||||||
foreach (var excpetAsset in exceptAssetList1)
|
foreach (var excpetAsset in exceptAssetList1)
|
||||||
{
|
{
|
||||||
Debug.LogWarning($"构建失败的资源对象路径为 : {excpetAsset}");
|
BuildLogger.Warning($"构建失败的资源对象路径为 : {excpetAsset}");
|
||||||
}
|
}
|
||||||
var exceptAssetList2 = buildedAssetPaths.Except(mapAssetPaths).ToList();
|
var exceptAssetList2 = buildedAssetPaths.Except(mapAssetPaths).ToList();
|
||||||
foreach (var excpetAsset in exceptAssetList2)
|
foreach (var excpetAsset in exceptAssetList2)
|
||||||
{
|
{
|
||||||
Debug.LogWarning($"构建失败的资源对象路径为 : {excpetAsset}");
|
BuildLogger.Warning($"构建失败的资源对象路径为 : {excpetAsset}");
|
||||||
}
|
}
|
||||||
isPass = false;
|
isPass = false;
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
@@ -35,29 +35,29 @@ namespace YooAsset.Editor
|
|||||||
{
|
{
|
||||||
var buildParameters = context.GetContextObject<BuildParametersContext>();
|
var buildParameters = context.GetContextObject<BuildParametersContext>();
|
||||||
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
||||||
List<string> buildedBundles = buildResults.BundleInfos.Keys.ToList();
|
List<string> unityCreateBundles = buildResults.BundleInfos.Keys.ToList();
|
||||||
|
|
||||||
// 1. 过滤掉原生Bundle
|
// 1. 过滤掉原生Bundle
|
||||||
List<string> expectBundles = buildMapContext.BundleInfos.Where(t => t.IsRawFile == false).Select(t => t.BundleName).ToList();
|
List<string> expectBundles = buildMapContext.Collection.Where(t => t.IsRawFile == false).Select(t => t.BundleName).ToList();
|
||||||
|
|
||||||
// 2. 验证Bundle
|
// 2. 验证Bundle
|
||||||
List<string> exceptBundleList1 = buildedBundles.Except(expectBundles).ToList();
|
List<string> exceptBundleList1 = unityCreateBundles.Except(expectBundles).ToList();
|
||||||
if (exceptBundleList1.Count > 0)
|
if (exceptBundleList1.Count > 0)
|
||||||
{
|
{
|
||||||
foreach (var exceptBundle in exceptBundleList1)
|
foreach (var exceptBundle in exceptBundleList1)
|
||||||
{
|
{
|
||||||
Debug.LogWarning($"差异资源包: {exceptBundle}");
|
BuildLogger.Warning($"差异资源包: {exceptBundle}");
|
||||||
}
|
}
|
||||||
throw new System.Exception("存在差异资源包!请查看警告信息!");
|
throw new System.Exception("存在差异资源包!请查看警告信息!");
|
||||||
}
|
}
|
||||||
|
|
||||||
// 3. 验证Bundle
|
// 3. 验证Bundle
|
||||||
List<string> exceptBundleList2 = expectBundles.Except(buildedBundles).ToList();
|
List<string> exceptBundleList2 = expectBundles.Except(unityCreateBundles).ToList();
|
||||||
if (exceptBundleList2.Count > 0)
|
if (exceptBundleList2.Count > 0)
|
||||||
{
|
{
|
||||||
foreach (var exceptBundle in exceptBundleList2)
|
foreach (var exceptBundle in exceptBundleList2)
|
||||||
{
|
{
|
||||||
Debug.LogWarning($"差异资源包: {exceptBundle}");
|
BuildLogger.Warning($"差异资源包: {exceptBundle}");
|
||||||
}
|
}
|
||||||
throw new System.Exception("存在差异资源包!请查看警告信息!");
|
throw new System.Exception("存在差异资源包!请查看警告信息!");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -217,7 +217,7 @@ namespace YooAsset.Editor
|
|||||||
|
|
||||||
private CollectAssetInfo CreateCollectAssetInfo(CollectCommand command, AssetBundleCollectorGroup group, string assetPath, bool isRawFilePackRule)
|
private CollectAssetInfo CreateCollectAssetInfo(CollectCommand command, AssetBundleCollectorGroup group, string assetPath, bool isRawFilePackRule)
|
||||||
{
|
{
|
||||||
string address = GetAddress(group, assetPath);
|
string address = GetAddress(command, group, assetPath);
|
||||||
string bundleName = GetBundleName(command, group, assetPath);
|
string bundleName = GetBundleName(command, group, assetPath);
|
||||||
List<string> assetTags = GetAssetTags(group);
|
List<string> assetTags = GetAssetTags(group);
|
||||||
CollectAssetInfo collectAssetInfo = new CollectAssetInfo(CollectorType, bundleName, address, assetPath, isRawFilePackRule, assetTags);
|
CollectAssetInfo collectAssetInfo = new CollectAssetInfo(CollectorType, bundleName, address, assetPath, isRawFilePackRule, assetTags);
|
||||||
@@ -280,20 +280,11 @@ namespace YooAsset.Editor
|
|||||||
}
|
}
|
||||||
|
|
||||||
string fileExtension = System.IO.Path.GetExtension(assetPath);
|
string fileExtension = System.IO.Path.GetExtension(assetPath);
|
||||||
if (IsIgnoreFile(fileExtension))
|
if (DefaultFilterRule.IsIgnoreFile(fileExtension))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
private bool IsIgnoreFile(string fileExtension)
|
|
||||||
{
|
|
||||||
foreach (var extension in DefaultFilterRule.IgnoreFileExtensions)
|
|
||||||
{
|
|
||||||
if (extension == fileExtension)
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
private bool IsCollectAsset(string assetPath)
|
private bool IsCollectAsset(string assetPath)
|
||||||
{
|
{
|
||||||
Type assetType = AssetDatabase.GetMainAssetTypeAtPath(assetPath);
|
Type assetType = AssetDatabase.GetMainAssetTypeAtPath(assetPath);
|
||||||
@@ -304,8 +295,11 @@ namespace YooAsset.Editor
|
|||||||
IFilterRule filterRuleInstance = AssetBundleCollectorSettingData.GetFilterRuleInstance(FilterRuleName);
|
IFilterRule filterRuleInstance = AssetBundleCollectorSettingData.GetFilterRuleInstance(FilterRuleName);
|
||||||
return filterRuleInstance.IsCollectAsset(new FilterRuleData(assetPath));
|
return filterRuleInstance.IsCollectAsset(new FilterRuleData(assetPath));
|
||||||
}
|
}
|
||||||
private string GetAddress(AssetBundleCollectorGroup group, string assetPath)
|
private string GetAddress(CollectCommand command, AssetBundleCollectorGroup group, string assetPath)
|
||||||
{
|
{
|
||||||
|
if (command.EnableAddressable == false)
|
||||||
|
return string.Empty;
|
||||||
|
|
||||||
if (CollectorType != ECollectorType.MainAssetCollector)
|
if (CollectorType != ECollectorType.MainAssetCollector)
|
||||||
return string.Empty;
|
return string.Empty;
|
||||||
|
|
||||||
|
|||||||
@@ -100,7 +100,7 @@ namespace YooAsset.Editor
|
|||||||
{
|
{
|
||||||
if (package.PackageName == packageName)
|
if (package.PackageName == packageName)
|
||||||
{
|
{
|
||||||
CollectCommand command = new CollectCommand(buildMode, package.PackageName, EnableAddressable, UniqueBundleName);
|
CollectCommand command = new CollectCommand(buildMode, packageName, EnableAddressable, UniqueBundleName);
|
||||||
CollectResult collectResult = new CollectResult(command);
|
CollectResult collectResult = new CollectResult(command);
|
||||||
collectResult.SetCollectAssets(package.GetAllCollectAssets(command));
|
collectResult.SetCollectAssets(package.GetAllCollectAssets(command));
|
||||||
return collectResult;
|
return collectResult;
|
||||||
@@ -109,21 +109,5 @@ namespace YooAsset.Editor
|
|||||||
|
|
||||||
throw new Exception($"Not found collector pacakge : {packageName}");
|
throw new Exception($"Not found collector pacakge : {packageName}");
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 获取所有包裹收集的资源文件
|
|
||||||
/// </summary>
|
|
||||||
public List<CollectResult> GetAllPackageAssets(EBuildMode buildMode)
|
|
||||||
{
|
|
||||||
List<CollectResult> collectResultList = new List<CollectResult>(1000);
|
|
||||||
foreach (var package in Packages)
|
|
||||||
{
|
|
||||||
CollectCommand command = new CollectCommand(buildMode, package.PackageName, EnableAddressable, UniqueBundleName);
|
|
||||||
CollectResult collectResult = new CollectResult(command);
|
|
||||||
collectResult.SetCollectAssets(package.GetAllCollectAssets(command));
|
|
||||||
collectResultList.Add(collectResult);
|
|
||||||
}
|
|
||||||
return collectResultList;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -23,12 +23,22 @@ namespace YooAsset.Editor
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public bool UniqueBundleName { private set; get; }
|
public bool UniqueBundleName { private set; get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 着色器统一全名称
|
||||||
|
/// </summary>
|
||||||
|
public string ShadersBundleName { private set; get; }
|
||||||
|
|
||||||
|
|
||||||
public CollectCommand(EBuildMode buildMode, string packageName, bool enableAddressable, bool uniqueBundleName)
|
public CollectCommand(EBuildMode buildMode, string packageName, bool enableAddressable, bool uniqueBundleName)
|
||||||
{
|
{
|
||||||
BuildMode = buildMode;
|
BuildMode = buildMode;
|
||||||
PackageName = packageName;
|
PackageName = packageName;
|
||||||
EnableAddressable = enableAddressable;
|
EnableAddressable = enableAddressable;
|
||||||
UniqueBundleName = uniqueBundleName;
|
UniqueBundleName = uniqueBundleName;
|
||||||
|
|
||||||
|
// 着色器统一全名称
|
||||||
|
var packRuleResult = DefaultPackRule.CreateShadersPackRuleResult();
|
||||||
|
ShadersBundleName = packRuleResult.GetMainBundleName(packageName, uniqueBundleName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -10,26 +10,15 @@ namespace YooAsset.Editor
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public CollectCommand Command { private set; get; }
|
public CollectCommand Command { private set; get; }
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 着色器统一全名称
|
|
||||||
/// </summary>
|
|
||||||
public string ShadersBundleName { private set; get; }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 收集的资源信息列表
|
/// 收集的资源信息列表
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public List<CollectAssetInfo> CollectAssets { private set; get; }
|
public List<CollectAssetInfo> CollectAssets { private set; get; }
|
||||||
|
|
||||||
|
|
||||||
public CollectResult(CollectCommand command)
|
public CollectResult(CollectCommand command)
|
||||||
{
|
{
|
||||||
Command = command;
|
Command = command;
|
||||||
|
|
||||||
// 着色器统一全名称
|
|
||||||
var packRuleResult = DefaultPackRule.CreateShadersPackRuleResult();
|
|
||||||
ShadersBundleName = packRuleResult.GetMainBundleName(command.PackageName, command.UniqueBundleName);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetCollectAssets(List<CollectAssetInfo> collectAssets)
|
public void SetCollectAssets(List<CollectAssetInfo> collectAssets)
|
||||||
{
|
{
|
||||||
CollectAssets = collectAssets;
|
CollectAssets = collectAssets;
|
||||||
|
|||||||
@@ -27,8 +27,8 @@ namespace YooAsset.Editor
|
|||||||
string IAddressRule.GetAssetAddress(AddressRuleData data)
|
string IAddressRule.GetAssetAddress(AddressRuleData data)
|
||||||
{
|
{
|
||||||
string fileName = Path.GetFileNameWithoutExtension(data.AssetPath);
|
string fileName = Path.GetFileNameWithoutExtension(data.AssetPath);
|
||||||
string collectorName = Path.GetFileNameWithoutExtension(data.CollectPath);
|
FileInfo fileInfo = new FileInfo(data.AssetPath);
|
||||||
return $"{collectorName}_{fileName}";
|
return $"{fileInfo.Directory.Name}_{fileName}";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,8 @@
|
|||||||
using UnityEngine;
|
using System.Collections;
|
||||||
using UnityEditor;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEditor;
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
@@ -9,7 +11,15 @@ namespace YooAsset.Editor
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 忽略的文件类型
|
/// 忽略的文件类型
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static readonly string[] IgnoreFileExtensions = { "", ".so", ".dll", ".cs", ".js", ".boo", ".meta", ".cginc", ".hlsl" };
|
private readonly static HashSet<string> _ignoreFileExtensions = new HashSet<string>() { "", ".so", ".dll", ".cs", ".js", ".boo", ".meta", ".cginc", ".hlsl" };
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 查询是否为忽略文件
|
||||||
|
/// </summary>
|
||||||
|
public static bool IsIgnoreFile(string fileExtension)
|
||||||
|
{
|
||||||
|
return _ignoreFileExtensions.Contains(fileExtension);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[DisplayName("收集所有资源")]
|
[DisplayName("收集所有资源")]
|
||||||
|
|||||||
@@ -10,50 +10,6 @@ namespace YooAsset.Editor
|
|||||||
#if UNITY_2019_4_OR_NEWER
|
#if UNITY_2019_4_OR_NEWER
|
||||||
private readonly static Dictionary<System.Type, string> _uxmlDic = new Dictionary<System.Type, string>();
|
private readonly static Dictionary<System.Type, string> _uxmlDic = new Dictionary<System.Type, string>();
|
||||||
|
|
||||||
/*
|
|
||||||
static EditorHelper()
|
|
||||||
{
|
|
||||||
// 资源包收集
|
|
||||||
_uxmlDic.Add(typeof(AssetBundleCollectorWindow), "355c4ac5cdebddc4c8362bed6f17a79e");
|
|
||||||
|
|
||||||
// 资源包构建
|
|
||||||
_uxmlDic.Add(typeof(AssetBundleBuilderWindow), "28ba29adb4949284e8c48893218b0d9a");
|
|
||||||
|
|
||||||
// 资源包调试
|
|
||||||
_uxmlDic.Add(typeof(AssetBundleDebuggerWindow), "790db12999afd334e8fb6ba70ef0a947");
|
|
||||||
_uxmlDic.Add(typeof(DebuggerAssetListViewer), "31c6096c1cb29b4469096b7b4942a322");
|
|
||||||
_uxmlDic.Add(typeof(DebuggerBundleListViewer), "932a25ffd05c13c47994d66e9d73bc37");
|
|
||||||
|
|
||||||
// 构建报告
|
|
||||||
_uxmlDic.Add(typeof(AssetBundleReporterWindow), "9052b72c383e95043a0c7e7f369b1ad7");
|
|
||||||
_uxmlDic.Add(typeof(ReporterSummaryViewer), "f8929271050855e42a1ccc6b14993a04");
|
|
||||||
_uxmlDic.Add(typeof(ReporterAssetListViewer), "5f81bc15a55ee0a49a266f9d71e2372b");
|
|
||||||
_uxmlDic.Add(typeof(ReporterBundleListViewer), "56d6dbe0d65ce334a8996beb19612989");
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 加载窗口的布局文件
|
|
||||||
/// </summary>
|
|
||||||
public static UnityEngine.UIElements.VisualTreeAsset LoadWindowUXML<TWindow>() where TWindow : class
|
|
||||||
{
|
|
||||||
var windowType = typeof(TWindow);
|
|
||||||
if (_uxmlDic.TryGetValue(windowType, out string uxmlGUID))
|
|
||||||
{
|
|
||||||
string assetPath = AssetDatabase.GUIDToAssetPath(uxmlGUID);
|
|
||||||
if (string.IsNullOrEmpty(assetPath))
|
|
||||||
throw new System.Exception($"Invalid YooAsset uxml guid : {uxmlGUID}");
|
|
||||||
var visualTreeAsset = AssetDatabase.LoadAssetAtPath<UnityEngine.UIElements.VisualTreeAsset>(assetPath);
|
|
||||||
if (visualTreeAsset == null)
|
|
||||||
throw new System.Exception($"Failed to load {windowType}.uxml");
|
|
||||||
return visualTreeAsset;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
throw new System.Exception($"Invalid YooAsset window type : {windowType}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 加载窗口的布局文件
|
/// 加载窗口的布局文件
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -1,9 +1,8 @@
|
|||||||
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" editor-extension-mode="False">
|
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements">
|
||||||
<ui:VisualElement name="CollectContainer">
|
<ui:VisualElement name="CollectContainer">
|
||||||
|
<uie:Toolbar name="Toolbar" style="display: flex; flex-direction: row-reverse;" />
|
||||||
<ui:TextField picking-mode="Ignore" label="文件保存路径" name="CollectOutput" style="height: 22px;" />
|
<ui:TextField picking-mode="Ignore" label="文件保存路径" name="CollectOutput" style="height: 22px;" />
|
||||||
<ui:VisualElement name="PackageContainer" style="height: 24px;">
|
<ui:VisualElement name="PackageContainer" style="height: 24px;" />
|
||||||
<uie:Toolbar name="Toolbar" style="display: flex; flex-direction: row-reverse;" />
|
|
||||||
</ui:VisualElement>
|
|
||||||
<ui:Label text="Current Shader Count" display-tooltip-when-elided="true" name="CurrentShaderCount" style="height: 20px; padding-left: 4px;" />
|
<ui:Label text="Current Shader Count" display-tooltip-when-elided="true" name="CurrentShaderCount" style="height: 20px; padding-left: 4px;" />
|
||||||
<ui:Label text="Current Variant Count" display-tooltip-when-elided="true" name="CurrentVariantCount" style="height: 20px; padding-left: 4px;" />
|
<ui:Label text="Current Variant Count" display-tooltip-when-elided="true" name="CurrentVariantCount" style="height: 20px; padding-left: 4px;" />
|
||||||
<ui:SliderInt picking-mode="Ignore" label="Capacity" value="9999" high-value="1000" name="ProcessCapacity" low-value="10" show-input-field="true" />
|
<ui:SliderInt picking-mode="Ignore" label="Capacity" value="9999" high-value="1000" name="ProcessCapacity" low-value="10" show-input-field="true" />
|
||||||
|
|||||||
@@ -387,7 +387,7 @@ namespace YooAsset
|
|||||||
// 新增下载需求
|
// 新增下载需求
|
||||||
#if UNITY_WEBGL
|
#if UNITY_WEBGL
|
||||||
if (bundleInfo.Bundle.IsRawFile)
|
if (bundleInfo.Bundle.IsRawFile)
|
||||||
loader = new RawBundleFileLoader(this, bundleInfo);
|
loader = new RawBundleWebLoader(this, bundleInfo);
|
||||||
else
|
else
|
||||||
loader = new AssetBundleWebLoader(this, bundleInfo);
|
loader = new AssetBundleWebLoader(this, bundleInfo);
|
||||||
#else
|
#else
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ namespace YooAsset
|
|||||||
private DownloaderBase _unpacker;
|
private DownloaderBase _unpacker;
|
||||||
private DownloaderBase _downloader;
|
private DownloaderBase _downloader;
|
||||||
private AssetBundleCreateRequest _createRequest;
|
private AssetBundleCreateRequest _createRequest;
|
||||||
private FileStream _fileStream;
|
private Stream _stream;
|
||||||
|
|
||||||
|
|
||||||
public AssetBundleFileLoader(AssetSystemImpl impl, BundleInfo bundleInfo) : base(impl, bundleInfo)
|
public AssetBundleFileLoader(AssetSystemImpl impl, BundleInfo bundleInfo) : base(impl, bundleInfo)
|
||||||
@@ -196,12 +196,12 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
else if (loadMethod == EBundleLoadMethod.LoadFromStream)
|
else if (loadMethod == EBundleLoadMethod.LoadFromStream)
|
||||||
{
|
{
|
||||||
_fileStream = Impl.DecryptionServices.LoadFromStream(fileInfo);
|
_stream = Impl.DecryptionServices.LoadFromStream(fileInfo);
|
||||||
uint managedReadBufferSize = Impl.DecryptionServices.GetManagedReadBufferSize();
|
uint managedReadBufferSize = Impl.DecryptionServices.GetManagedReadBufferSize();
|
||||||
if (_isWaitForAsyncComplete)
|
if (_isWaitForAsyncComplete)
|
||||||
CacheBundle = AssetBundle.LoadFromStream(_fileStream, 0, managedReadBufferSize);
|
CacheBundle = AssetBundle.LoadFromStream(_stream, 0, managedReadBufferSize);
|
||||||
else
|
else
|
||||||
_createRequest = AssetBundle.LoadFromStreamAsync(_fileStream, 0, managedReadBufferSize);
|
_createRequest = AssetBundle.LoadFromStreamAsync(_stream, 0, managedReadBufferSize);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -265,11 +265,11 @@ namespace YooAsset
|
|||||||
{
|
{
|
||||||
base.Destroy(forceDestroy);
|
base.Destroy(forceDestroy);
|
||||||
|
|
||||||
if (_fileStream != null)
|
if (_stream != null)
|
||||||
{
|
{
|
||||||
_fileStream.Close();
|
_stream.Close();
|
||||||
_fileStream.Dispose();
|
_stream.Dispose();
|
||||||
_fileStream = null;
|
_stream = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -286,9 +286,12 @@ namespace YooAsset
|
|||||||
// 文件解压
|
// 文件解压
|
||||||
if (_unpacker != null)
|
if (_unpacker != null)
|
||||||
{
|
{
|
||||||
_unpacker.Update();
|
|
||||||
if (_unpacker.IsDone() == false)
|
if (_unpacker.IsDone() == false)
|
||||||
|
{
|
||||||
|
_unpacker.WaitForAsyncComplete = true;
|
||||||
|
_unpacker.Update();
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 保险机制
|
// 保险机制
|
||||||
@@ -299,7 +302,7 @@ namespace YooAsset
|
|||||||
if (_isShowWaitForAsyncError == false)
|
if (_isShowWaitForAsyncError == false)
|
||||||
{
|
{
|
||||||
_isShowWaitForAsyncError = true;
|
_isShowWaitForAsyncError = true;
|
||||||
YooLogger.Error($"WaitForAsyncComplete failed ! Try load bundle : {MainBundleInfo.Bundle.BundleName} from remote with sync load method !");
|
YooLogger.Error($"{nameof(WaitForAsyncComplete)} failed ! Try load bundle : {MainBundleInfo.Bundle.BundleName} from remote with sync load method !");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,9 @@ using UnityEngine.Networking;
|
|||||||
|
|
||||||
namespace YooAsset
|
namespace YooAsset
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// WebGL平台加载器
|
||||||
|
/// </summary>
|
||||||
internal sealed class AssetBundleWebLoader : BundleLoaderBase
|
internal sealed class AssetBundleWebLoader : BundleLoaderBase
|
||||||
{
|
{
|
||||||
private enum ESteps
|
private enum ESteps
|
||||||
@@ -24,7 +27,6 @@ namespace YooAsset
|
|||||||
|
|
||||||
private ESteps _steps = ESteps.None;
|
private ESteps _steps = ESteps.None;
|
||||||
private float _tryTimer = 0;
|
private float _tryTimer = 0;
|
||||||
private bool _isShowWaitForAsyncError = false;
|
|
||||||
private DownloaderBase _downloader;
|
private DownloaderBase _downloader;
|
||||||
private UnityWebRequest _webRequest;
|
private UnityWebRequest _webRequest;
|
||||||
private AssetBundleCreateRequest _createRequest;
|
private AssetBundleCreateRequest _createRequest;
|
||||||
@@ -225,10 +227,11 @@ namespace YooAsset
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public override void WaitForAsyncComplete()
|
public override void WaitForAsyncComplete()
|
||||||
{
|
{
|
||||||
if (_isShowWaitForAsyncError == false)
|
if (IsDone() == false)
|
||||||
{
|
{
|
||||||
_isShowWaitForAsyncError = true;
|
Status = EStatus.Failed;
|
||||||
YooLogger.Error($"WebGL platform not support {nameof(WaitForAsyncComplete)} ! Use the async load method instead of the sync load method !");
|
LastError = $"{nameof(WaitForAsyncComplete)} failed ! WebGL platform not support sync load method !";
|
||||||
|
YooLogger.Error(LastError);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
|
|
||||||
private ESteps _steps = ESteps.None;
|
private ESteps _steps = ESteps.None;
|
||||||
private bool _isShowWaitForAsyncError = false;
|
|
||||||
private DownloaderBase _unpacker;
|
private DownloaderBase _unpacker;
|
||||||
private DownloaderBase _downloader;
|
private DownloaderBase _downloader;
|
||||||
|
|
||||||
@@ -42,7 +41,7 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
else if (MainBundleInfo.LoadMode == BundleInfo.ELoadMode.LoadFromStreaming)
|
else if (MainBundleInfo.LoadMode == BundleInfo.ELoadMode.LoadFromStreaming)
|
||||||
{
|
{
|
||||||
#if UNITY_ANDROID || UNITY_WEBGL
|
#if UNITY_ANDROID
|
||||||
_steps = ESteps.Unpack;
|
_steps = ESteps.Unpack;
|
||||||
FileLoadPath = MainBundleInfo.Bundle.CachedDataFilePath;
|
FileLoadPath = MainBundleInfo.Bundle.CachedDataFilePath;
|
||||||
#else
|
#else
|
||||||
@@ -125,13 +124,14 @@ namespace YooAsset
|
|||||||
DownloadProgress = 1f;
|
DownloadProgress = 1f;
|
||||||
DownloadedBytes = (ulong)MainBundleInfo.Bundle.FileSize;
|
DownloadedBytes = (ulong)MainBundleInfo.Bundle.FileSize;
|
||||||
|
|
||||||
_steps = ESteps.Done;
|
|
||||||
if (File.Exists(FileLoadPath))
|
if (File.Exists(FileLoadPath))
|
||||||
{
|
{
|
||||||
|
_steps = ESteps.Done;
|
||||||
Status = EStatus.Succeed;
|
Status = EStatus.Succeed;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
_steps = ESteps.Done;
|
||||||
Status = EStatus.Failed;
|
Status = EStatus.Failed;
|
||||||
LastError = $"Raw file not found : {FileLoadPath}";
|
LastError = $"Raw file not found : {FileLoadPath}";
|
||||||
}
|
}
|
||||||
@@ -149,20 +149,24 @@ namespace YooAsset
|
|||||||
// 文件解压
|
// 文件解压
|
||||||
if (_unpacker != null)
|
if (_unpacker != null)
|
||||||
{
|
{
|
||||||
_unpacker.Update();
|
|
||||||
if (_unpacker.IsDone() == false)
|
if (_unpacker.IsDone() == false)
|
||||||
|
{
|
||||||
|
_unpacker.WaitForAsyncComplete = true;
|
||||||
|
_unpacker.Update();
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 保险机制
|
// 保险机制
|
||||||
// 注意:如果需要从WEB端下载资源,可能会触发保险机制!
|
// 注意:如果需要从远端下载资源,可能会触发保险机制!
|
||||||
frame--;
|
frame--;
|
||||||
if (frame == 0)
|
if (frame == 0)
|
||||||
{
|
{
|
||||||
if (_isShowWaitForAsyncError == false)
|
if (IsDone() == false)
|
||||||
{
|
{
|
||||||
_isShowWaitForAsyncError = true;
|
Status = EStatus.Failed;
|
||||||
YooLogger.Error($"WaitForAsyncComplete failed ! Try load bundle : {MainBundleInfo.Bundle.BundleName} from remote with sync load method !");
|
LastError = $"WaitForAsyncComplete failed ! Try load bundle : {MainBundleInfo.Bundle.BundleName} from remote with sync load method !";
|
||||||
|
YooLogger.Error(LastError);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
151
Assets/YooAsset/Runtime/AssetSystem/Loader/RawBundleWebLoader.cs
Normal file
151
Assets/YooAsset/Runtime/AssetSystem/Loader/RawBundleWebLoader.cs
Normal file
@@ -0,0 +1,151 @@
|
|||||||
|
using System.IO;
|
||||||
|
|
||||||
|
namespace YooAsset
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// WebGL平台加载器
|
||||||
|
/// </summary>
|
||||||
|
internal class RawBundleWebLoader : BundleLoaderBase
|
||||||
|
{
|
||||||
|
private enum ESteps
|
||||||
|
{
|
||||||
|
None,
|
||||||
|
Download,
|
||||||
|
CheckDownload,
|
||||||
|
Website,
|
||||||
|
CheckWebsite,
|
||||||
|
CheckFile,
|
||||||
|
Done,
|
||||||
|
}
|
||||||
|
|
||||||
|
private ESteps _steps = ESteps.None;
|
||||||
|
private DownloaderBase _website;
|
||||||
|
private DownloaderBase _downloader;
|
||||||
|
|
||||||
|
|
||||||
|
public RawBundleWebLoader(AssetSystemImpl impl, BundleInfo bundleInfo) : base(impl, bundleInfo)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 轮询更新
|
||||||
|
/// </summary>
|
||||||
|
public override void Update()
|
||||||
|
{
|
||||||
|
if (_steps == ESteps.Done)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (_steps == ESteps.None)
|
||||||
|
{
|
||||||
|
if (MainBundleInfo.LoadMode == BundleInfo.ELoadMode.LoadFromRemote)
|
||||||
|
{
|
||||||
|
_steps = ESteps.Download;
|
||||||
|
FileLoadPath = MainBundleInfo.Bundle.CachedDataFilePath;
|
||||||
|
}
|
||||||
|
else if (MainBundleInfo.LoadMode == BundleInfo.ELoadMode.LoadFromStreaming)
|
||||||
|
{
|
||||||
|
_steps = ESteps.Website;
|
||||||
|
FileLoadPath = MainBundleInfo.Bundle.CachedDataFilePath;
|
||||||
|
}
|
||||||
|
else if (MainBundleInfo.LoadMode == BundleInfo.ELoadMode.LoadFromCache)
|
||||||
|
{
|
||||||
|
_steps = ESteps.CheckFile;
|
||||||
|
FileLoadPath = MainBundleInfo.Bundle.CachedDataFilePath;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new System.NotImplementedException(MainBundleInfo.LoadMode.ToString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 1. 下载远端文件
|
||||||
|
if (_steps == ESteps.Download)
|
||||||
|
{
|
||||||
|
int failedTryAgain = int.MaxValue;
|
||||||
|
_downloader = DownloadSystem.BeginDownload(MainBundleInfo, failedTryAgain);
|
||||||
|
_steps = ESteps.CheckDownload;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 2. 检测下载结果
|
||||||
|
if (_steps == ESteps.CheckDownload)
|
||||||
|
{
|
||||||
|
DownloadProgress = _downloader.DownloadProgress;
|
||||||
|
DownloadedBytes = _downloader.DownloadedBytes;
|
||||||
|
if (_downloader.IsDone() == false)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (_downloader.HasError())
|
||||||
|
{
|
||||||
|
_steps = ESteps.Done;
|
||||||
|
Status = EStatus.Failed;
|
||||||
|
LastError = _downloader.GetLastError();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_steps = ESteps.CheckFile;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 3. 从站点下载
|
||||||
|
if (_steps == ESteps.Website)
|
||||||
|
{
|
||||||
|
int failedTryAgain = 1;
|
||||||
|
var bundleInfo = PatchManifestTools.GetUnpackInfo(MainBundleInfo.Bundle);
|
||||||
|
_website = DownloadSystem.BeginDownload(bundleInfo, failedTryAgain);
|
||||||
|
_steps = ESteps.CheckWebsite;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 4. 检测站点下载
|
||||||
|
if (_steps == ESteps.CheckWebsite)
|
||||||
|
{
|
||||||
|
DownloadProgress = _website.DownloadProgress;
|
||||||
|
DownloadedBytes = _website.DownloadedBytes;
|
||||||
|
if (_website.IsDone() == false)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (_website.HasError())
|
||||||
|
{
|
||||||
|
_steps = ESteps.Done;
|
||||||
|
Status = EStatus.Failed;
|
||||||
|
LastError = _website.GetLastError();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_steps = ESteps.CheckFile;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 5. 检测结果
|
||||||
|
if (_steps == ESteps.CheckFile)
|
||||||
|
{
|
||||||
|
// 设置下载进度
|
||||||
|
DownloadProgress = 1f;
|
||||||
|
DownloadedBytes = (ulong)MainBundleInfo.Bundle.FileSize;
|
||||||
|
|
||||||
|
_steps = ESteps.Done;
|
||||||
|
if (File.Exists(FileLoadPath))
|
||||||
|
{
|
||||||
|
Status = EStatus.Succeed;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Status = EStatus.Failed;
|
||||||
|
LastError = $"Raw file not found : {FileLoadPath}";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 主线程等待异步操作完毕
|
||||||
|
/// </summary>
|
||||||
|
public override void WaitForAsyncComplete()
|
||||||
|
{
|
||||||
|
if (IsDone() == false)
|
||||||
|
{
|
||||||
|
Status = EStatus.Failed;
|
||||||
|
LastError = $"{nameof(WaitForAsyncComplete)} failed ! WebGL platform not support sync load method !";
|
||||||
|
YooLogger.Error(LastError);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: e9274735f1f14af4b893c21a4240b816
|
guid: 1d16b689f73611e44bd01a4cc429a6ac
|
||||||
MonoImporter:
|
MonoImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
@@ -57,6 +57,25 @@ namespace YooAsset
|
|||||||
_steps = ESteps.Waiting;
|
_steps = ESteps.Waiting;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (_steps == ESteps.Waiting)
|
||||||
|
{
|
||||||
|
if (_element.IsDone == false)
|
||||||
|
return;
|
||||||
|
|
||||||
|
VerifyResult = _element.Result;
|
||||||
|
if (_element.Result == EVerifyResult.Succeed)
|
||||||
|
{
|
||||||
|
_steps = ESteps.Done;
|
||||||
|
Status = EOperationStatus.Succeed;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_steps = ESteps.Done;
|
||||||
|
Status = EOperationStatus.Failed;
|
||||||
|
Error = $"Failed verify file : {_element.TempDataFilePath} ! ErrorCode : {_element.Result}";
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool BeginVerifyFileWithThread(VerifyTempElement element)
|
private bool BeginVerifyFileWithThread(VerifyTempElement element)
|
||||||
@@ -67,23 +86,7 @@ namespace YooAsset
|
|||||||
{
|
{
|
||||||
VerifyTempElement element = (VerifyTempElement)obj;
|
VerifyTempElement element = (VerifyTempElement)obj;
|
||||||
element.Result = CacheSystem.VerifyingTempFile(element);
|
element.Result = CacheSystem.VerifyingTempFile(element);
|
||||||
DownloadSystem.SyncContext.Post(VerifyCallback, element);
|
element.IsDone = true;
|
||||||
}
|
|
||||||
private void VerifyCallback(object obj)
|
|
||||||
{
|
|
||||||
VerifyTempElement element = (VerifyTempElement)obj;
|
|
||||||
VerifyResult = element.Result;
|
|
||||||
if (element.Result == EVerifyResult.Succeed)
|
|
||||||
{
|
|
||||||
_steps = ESteps.Done;
|
|
||||||
Status = EOperationStatus.Succeed;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_steps = ESteps.Done;
|
|
||||||
Status = EOperationStatus.Failed;
|
|
||||||
Error = $"Failed verify file : {element.TempDataFilePath} ! ErrorCode : {element.Result}";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -101,7 +104,7 @@ namespace YooAsset
|
|||||||
|
|
||||||
private readonly VerifyTempElement _element;
|
private readonly VerifyTempElement _element;
|
||||||
private ESteps _steps = ESteps.None;
|
private ESteps _steps = ESteps.None;
|
||||||
|
|
||||||
public VerifyTempFileWithoutThreadOperation(VerifyTempElement element)
|
public VerifyTempFileWithoutThreadOperation(VerifyTempElement element)
|
||||||
{
|
{
|
||||||
_element = element;
|
_element = element;
|
||||||
@@ -118,6 +121,8 @@ namespace YooAsset
|
|||||||
if (_steps == ESteps.VerifyFile)
|
if (_steps == ESteps.VerifyFile)
|
||||||
{
|
{
|
||||||
_element.Result = CacheSystem.VerifyingTempFile(_element);
|
_element.Result = CacheSystem.VerifyingTempFile(_element);
|
||||||
|
_element.IsDone = true;
|
||||||
|
|
||||||
VerifyResult = _element.Result;
|
VerifyResult = _element.Result;
|
||||||
if (_element.Result == EVerifyResult.Succeed)
|
if (_element.Result == EVerifyResult.Succeed)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -49,6 +49,7 @@ namespace YooAsset
|
|||||||
public string FileCRC { private set; get; }
|
public string FileCRC { private set; get; }
|
||||||
public long FileSize { private set; get; }
|
public long FileSize { private set; get; }
|
||||||
|
|
||||||
|
public bool IsDone = false;
|
||||||
public EVerifyResult Result;
|
public EVerifyResult Result;
|
||||||
|
|
||||||
public VerifyTempElement(string tempDataFilePath, string fileCRC, long fileSize)
|
public VerifyTempElement(string tempDataFilePath, string fileCRC, long fileSize)
|
||||||
|
|||||||
@@ -22,11 +22,6 @@ namespace YooAsset
|
|||||||
private static readonly Dictionary<string, DownloaderBase> _downloaderDic = new Dictionary<string, DownloaderBase>();
|
private static readonly Dictionary<string, DownloaderBase> _downloaderDic = new Dictionary<string, DownloaderBase>();
|
||||||
private static readonly List<string> _removeList = new List<string>(100);
|
private static readonly List<string> _removeList = new List<string>(100);
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 线程同步
|
|
||||||
/// </summary>
|
|
||||||
public static ThreadSyncContext SyncContext { set; get; }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 自定义下载器的请求委托
|
/// 自定义下载器的请求委托
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -53,7 +48,6 @@ namespace YooAsset
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public static void Initialize()
|
public static void Initialize()
|
||||||
{
|
{
|
||||||
SyncContext = new ThreadSyncContext();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -61,9 +55,6 @@ namespace YooAsset
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public static void Update()
|
public static void Update()
|
||||||
{
|
{
|
||||||
if (SyncContext != null)
|
|
||||||
SyncContext.Update();
|
|
||||||
|
|
||||||
// 更新下载器
|
// 更新下载器
|
||||||
_removeList.Clear();
|
_removeList.Clear();
|
||||||
foreach (var valuePair in _downloaderDic)
|
foreach (var valuePair in _downloaderDic)
|
||||||
@@ -94,7 +85,6 @@ namespace YooAsset
|
|||||||
_downloaderDic.Clear();
|
_downloaderDic.Clear();
|
||||||
_removeList.Clear();
|
_removeList.Clear();
|
||||||
|
|
||||||
SyncContext = null;
|
|
||||||
RequestDelegate = null;
|
RequestDelegate = null;
|
||||||
CertificateHandlerInstance = null;
|
CertificateHandlerInstance = null;
|
||||||
BreakpointResumeFileSize = int.MaxValue;
|
BreakpointResumeFileSize = int.MaxValue;
|
||||||
|
|||||||
@@ -34,6 +34,11 @@ namespace YooAsset
|
|||||||
protected float _downloadProgress = 0f;
|
protected float _downloadProgress = 0f;
|
||||||
protected ulong _downloadedBytes = 0;
|
protected ulong _downloadedBytes = 0;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 是否等待异步结束
|
||||||
|
/// 警告:只能用于解压APP内部资源
|
||||||
|
/// </summary>
|
||||||
|
public bool WaitForAsyncComplete = false;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 下载进度(0f~1f)
|
/// 下载进度(0f~1f)
|
||||||
|
|||||||
@@ -48,6 +48,9 @@ namespace YooAsset
|
|||||||
// 等待检测结果
|
// 等待检测结果
|
||||||
if (_steps == ESteps.WaitingCheckTempFile)
|
if (_steps == ESteps.WaitingCheckTempFile)
|
||||||
{
|
{
|
||||||
|
if (WaitForAsyncComplete)
|
||||||
|
_checkFileOp.Update();
|
||||||
|
|
||||||
if (_checkFileOp.IsDone == false)
|
if (_checkFileOp.IsDone == false)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -220,6 +223,9 @@ namespace YooAsset
|
|||||||
// 等待验证完成
|
// 等待验证完成
|
||||||
if (_steps == ESteps.WaitingVerifyTempFile)
|
if (_steps == ESteps.WaitingVerifyTempFile)
|
||||||
{
|
{
|
||||||
|
if (WaitForAsyncComplete)
|
||||||
|
_verifyFileOp.Update();
|
||||||
|
|
||||||
if (_verifyFileOp.IsDone == false)
|
if (_verifyFileOp.IsDone == false)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,17 @@ namespace YooAsset
|
|||||||
private readonly PatchAsset _patchAsset;
|
private readonly PatchAsset _patchAsset;
|
||||||
private string _providerGUID;
|
private string _providerGUID;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 资源类型
|
||||||
|
/// </summary>
|
||||||
|
public System.Type AssetType { private set; get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 错误信息
|
||||||
|
/// </summary>
|
||||||
|
public string Error { private set; get; }
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 唯一标识符
|
/// 唯一标识符
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -35,40 +46,45 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 错误信息
|
|
||||||
/// </summary>
|
|
||||||
internal string Error { private set; get; }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 可寻址地址
|
/// 可寻址地址
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string Address { private set; get; }
|
public string Address
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (_patchAsset == null)
|
||||||
|
return string.Empty;
|
||||||
|
return _patchAsset.Address;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 资源路径
|
/// 资源路径
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string AssetPath { private set; get; }
|
public string AssetPath
|
||||||
|
{
|
||||||
/// <summary>
|
get
|
||||||
/// 资源类型
|
{
|
||||||
/// </summary>
|
if (_patchAsset == null)
|
||||||
public System.Type AssetType { private set; get; }
|
return string.Empty;
|
||||||
|
return _patchAsset.AssetPath;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// 注意:这是一个内部类,严格限制外部创建。
|
|
||||||
private AssetInfo()
|
private AssetInfo()
|
||||||
{
|
{
|
||||||
|
// 注意:禁止从外部创建该类
|
||||||
}
|
}
|
||||||
internal AssetInfo(PatchAsset patchAsset, System.Type assetType)
|
internal AssetInfo(PatchAsset patchAsset, System.Type assetType)
|
||||||
{
|
{
|
||||||
if (patchAsset == null)
|
if (patchAsset == null)
|
||||||
throw new System.Exception("Should never get here !");
|
throw new System.Exception("Should never get here !");
|
||||||
|
|
||||||
|
_providerGUID = string.Empty;
|
||||||
_patchAsset = patchAsset;
|
_patchAsset = patchAsset;
|
||||||
AssetType = assetType;
|
AssetType = assetType;
|
||||||
Address = patchAsset.Address;
|
|
||||||
AssetPath = patchAsset.AssetPath;
|
|
||||||
Error = string.Empty;
|
Error = string.Empty;
|
||||||
}
|
}
|
||||||
internal AssetInfo(PatchAsset patchAsset)
|
internal AssetInfo(PatchAsset patchAsset)
|
||||||
@@ -76,18 +92,16 @@ namespace YooAsset
|
|||||||
if (patchAsset == null)
|
if (patchAsset == null)
|
||||||
throw new System.Exception("Should never get here !");
|
throw new System.Exception("Should never get here !");
|
||||||
|
|
||||||
|
_providerGUID = string.Empty;
|
||||||
_patchAsset = patchAsset;
|
_patchAsset = patchAsset;
|
||||||
AssetType = null;
|
AssetType = null;
|
||||||
Address = patchAsset.Address;
|
|
||||||
AssetPath = patchAsset.AssetPath;
|
|
||||||
Error = string.Empty;
|
Error = string.Empty;
|
||||||
}
|
}
|
||||||
internal AssetInfo(string error)
|
internal AssetInfo(string error)
|
||||||
{
|
{
|
||||||
|
_providerGUID = string.Empty;
|
||||||
_patchAsset = null;
|
_patchAsset = null;
|
||||||
AssetType = null;
|
AssetType = null;
|
||||||
Address = string.Empty;
|
|
||||||
AssetPath = string.Empty;
|
|
||||||
Error = error;
|
Error = error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ namespace YooAsset
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 文件流解密方法
|
/// 文件流解密方法
|
||||||
/// </summary>
|
/// </summary>
|
||||||
System.IO.FileStream LoadFromStream(DecryptFileInfo fileInfo);
|
System.IO.Stream LoadFromStream(DecryptFileInfo fileInfo);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 文件流解密的托管缓存大小
|
/// 文件流解密的托管缓存大小
|
||||||
|
|||||||
8
Assets/YooAsset/Runtime/Services/Internal.meta
Normal file
8
Assets/YooAsset/Runtime/Services/Internal.meta
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 40c870edb8e84064a8be2d56acb8bbc0
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -2,15 +2,35 @@
|
|||||||
|
|
||||||
namespace YooAsset
|
namespace YooAsset
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 自定义日志处理
|
||||||
|
/// </summary>
|
||||||
|
public interface ILogger
|
||||||
|
{
|
||||||
|
void Log(string message);
|
||||||
|
void Warning(string message);
|
||||||
|
void Error(string message);
|
||||||
|
void Exception(System.Exception exception);
|
||||||
|
}
|
||||||
|
|
||||||
internal static class YooLogger
|
internal static class YooLogger
|
||||||
{
|
{
|
||||||
|
public static ILogger Logger = null;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 日志
|
/// 日志
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Conditional("DEBUG")]
|
[Conditional("DEBUG")]
|
||||||
public static void Log(string info)
|
public static void Log(string info)
|
||||||
{
|
{
|
||||||
UnityEngine.Debug.Log(info);
|
if (Logger != null)
|
||||||
|
{
|
||||||
|
Logger.Log(info);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
UnityEngine.Debug.Log(info);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -18,7 +38,14 @@ namespace YooAsset
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public static void Warning(string info)
|
public static void Warning(string info)
|
||||||
{
|
{
|
||||||
UnityEngine.Debug.LogWarning(info);
|
if (Logger != null)
|
||||||
|
{
|
||||||
|
Logger.Warning(info);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
UnityEngine.Debug.LogWarning(info);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -26,7 +53,14 @@ namespace YooAsset
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public static void Error(string info)
|
public static void Error(string info)
|
||||||
{
|
{
|
||||||
UnityEngine.Debug.LogError(info);
|
if (Logger != null)
|
||||||
|
{
|
||||||
|
Logger.Error(info);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
UnityEngine.Debug.LogError(info);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -34,7 +68,14 @@ namespace YooAsset
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public static void Exception(System.Exception exception)
|
public static void Exception(System.Exception exception)
|
||||||
{
|
{
|
||||||
UnityEngine.Debug.LogException(exception);
|
if (Logger != null)
|
||||||
|
{
|
||||||
|
Logger.Exception(exception);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
UnityEngine.Debug.LogException(exception);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -15,13 +15,16 @@ namespace YooAsset
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 初始化资源系统
|
/// 初始化资源系统
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static void Initialize()
|
/// <param name="logger">自定义日志处理</param>
|
||||||
|
public static void Initialize(ILogger logger = null)
|
||||||
{
|
{
|
||||||
if (_isInitialize)
|
if (_isInitialize)
|
||||||
throw new Exception($"{nameof(YooAssets)} is initialized !");
|
throw new Exception($"{nameof(YooAssets)} is initialized !");
|
||||||
|
|
||||||
if (_isInitialize == false)
|
if (_isInitialize == false)
|
||||||
{
|
{
|
||||||
|
YooLogger.Logger = logger;
|
||||||
|
|
||||||
// 创建驱动器
|
// 创建驱动器
|
||||||
_isInitialize = true;
|
_isInitialize = true;
|
||||||
_driver = new UnityEngine.GameObject($"[{nameof(YooAssets)}]");
|
_driver = new UnityEngine.GameObject($"[{nameof(YooAssets)}]");
|
||||||
|
|||||||
@@ -2,21 +2,24 @@
|
|||||||
<root Version="2.3">
|
<root Version="2.3">
|
||||||
<Common AutoAddressable="True" UniqueBundleName="False" ShowPackageView="False" ShowEditorAlias="False" />
|
<Common AutoAddressable="True" UniqueBundleName="False" ShowPackageView="False" ShowEditorAlias="False" />
|
||||||
<Package PackageName="DefaultPackage" PackageDesc="">
|
<Package PackageName="DefaultPackage" PackageDesc="">
|
||||||
<Group GroupName="battle" GroupDesc="" AssetTags="">
|
<Group GroupName="battle" GroupDesc="战斗" AssetTags="">
|
||||||
<Collector CollectPath="Assets/Samples/Space Shooter/GameRes/Effect" CollectGUID="80d76514758554baaa96a9efffe9f3ef" CollectType="MainAssetCollector" AddressRule="AddressByFileName" PackRule="PackDirectory" FilterRule="CollectAll" UserData="" AssetTags="" />
|
<Collector CollectPath="Assets/Samples/Space Shooter/GameRes/Effect" CollectGUID="80d76514758554baaa96a9efffe9f3ef" CollectType="MainAssetCollector" AddressRule="AddressByFileName" PackRule="PackDirectory" FilterRule="CollectAll" UserData="" AssetTags="" />
|
||||||
<Collector CollectPath="Assets/Samples/Space Shooter/GameRes/Entity" CollectGUID="4d7c84745db8e884f8020a8c5356e67c" CollectType="MainAssetCollector" AddressRule="AddressByFileName" PackRule="PackDirectory" FilterRule="CollectAll" UserData="" AssetTags="" />
|
<Collector CollectPath="Assets/Samples/Space Shooter/GameRes/Entity" CollectGUID="4d7c84745db8e884f8020a8c5356e67c" CollectType="MainAssetCollector" AddressRule="AddressByFileName" PackRule="PackDirectory" FilterRule="CollectAll" UserData="" AssetTags="" />
|
||||||
<Collector CollectPath="Assets/Samples/Space Shooter/GameRes/Audio" CollectGUID="306075fbe00b24251b6c889984a7a7d5" CollectType="MainAssetCollector" AddressRule="AddressByFileName" PackRule="PackDirectory" FilterRule="CollectAll" UserData="" AssetTags="" />
|
<Collector CollectPath="Assets/Samples/Space Shooter/GameRes/Audio" CollectGUID="306075fbe00b24251b6c889984a7a7d5" CollectType="MainAssetCollector" AddressRule="AddressByFileName" PackRule="PackDirectory" FilterRule="CollectAll" UserData="" AssetTags="" />
|
||||||
</Group>
|
</Group>
|
||||||
<Group GroupName="shader" GroupDesc="" AssetTags="">
|
<Group GroupName="shader" GroupDesc="着色器" AssetTags="">
|
||||||
<Collector CollectPath="Assets/Samples/Space Shooter/GameArt/ShaderVariants" CollectGUID="00781758c26692e40a9634ddeac838be" CollectType="MainAssetCollector" AddressRule="AddressByFileName" PackRule="PackShaderVariants" FilterRule="CollectShaderVariants" UserData="" AssetTags="" />
|
<Collector CollectPath="Assets/Samples/Space Shooter/GameArt/ShaderVariants" CollectGUID="00781758c26692e40a9634ddeac838be" CollectType="MainAssetCollector" AddressRule="AddressByFileName" PackRule="PackShaderVariants" FilterRule="CollectShaderVariants" UserData="" AssetTags="" />
|
||||||
</Group>
|
</Group>
|
||||||
<Group GroupName="scene" GroupDesc="" AssetTags="">
|
<Group GroupName="scene" GroupDesc="场景" AssetTags="">
|
||||||
<Collector CollectPath="Assets/Samples/Space Shooter/GameRes/Scene" CollectGUID="6070eae1192f2994887f2983a177d503" CollectType="MainAssetCollector" AddressRule="AddressByFileName" PackRule="PackSeparately" FilterRule="CollectAll" UserData="" AssetTags="" />
|
<Collector CollectPath="Assets/Samples/Space Shooter/GameRes/Scene" CollectGUID="6070eae1192f2994887f2983a177d503" CollectType="MainAssetCollector" AddressRule="AddressByFileName" PackRule="PackSeparately" FilterRule="CollectAll" UserData="" AssetTags="" />
|
||||||
</Group>
|
</Group>
|
||||||
<Group GroupName="ugui" GroupDesc="" AssetTags="">
|
<Group GroupName="ugui" GroupDesc="面板" AssetTags="">
|
||||||
<Collector CollectPath="Assets/Samples/Space Shooter/GameRes/UIImage" CollectGUID="30c57db62bb02a24590e7046d3a9e33a" CollectType="MainAssetCollector" AddressRule="AddressByFileName" PackRule="PackDirectory" FilterRule="CollectAll" UserData="" AssetTags="" />
|
<Collector CollectPath="Assets/Samples/Space Shooter/GameRes/UIImage" CollectGUID="30c57db62bb02a24590e7046d3a9e33a" CollectType="MainAssetCollector" AddressRule="AddressByFileName" PackRule="PackDirectory" FilterRule="CollectAll" UserData="" AssetTags="" />
|
||||||
<Collector CollectPath="Assets/Samples/Space Shooter/GameRes/UIPanel" CollectGUID="12d33f33f3a55224c9c747d7bffa1c68" CollectType="MainAssetCollector" AddressRule="AddressByFileName" PackRule="PackSeparately" FilterRule="CollectAll" UserData="" AssetTags="" />
|
<Collector CollectPath="Assets/Samples/Space Shooter/GameRes/UIPanel" CollectGUID="12d33f33f3a55224c9c747d7bffa1c68" CollectType="MainAssetCollector" AddressRule="AddressByFileName" PackRule="PackSeparately" FilterRule="CollectAll" UserData="" AssetTags="" />
|
||||||
<Collector CollectPath="Assets/Samples/Space Shooter/GameRes/UISprite" CollectGUID="01865ad6f7c806147b6cb37f2d83bc96" CollectType="MainAssetCollector" AddressRule="AddressByFileName" PackRule="PackTopDirectory" FilterRule="CollectAll" UserData="" AssetTags="" />
|
<Collector CollectPath="Assets/Samples/Space Shooter/GameRes/UISprite" CollectGUID="01865ad6f7c806147b6cb37f2d83bc96" CollectType="MainAssetCollector" AddressRule="AddressByFileName" PackRule="PackTopDirectory" FilterRule="CollectAll" UserData="" AssetTags="" />
|
||||||
</Group>
|
</Group>
|
||||||
|
<Group GroupName="config" GroupDesc="配置表" AssetTags="">
|
||||||
|
<Collector CollectPath="Assets/Samples/Space Shooter/GameRes/Config" CollectGUID="1894d23646ddbf8479e579cc03261dde" CollectType="MainAssetCollector" AddressRule="AddressByFileName" PackRule="PackRawFile" FilterRule="CollectAll" UserData="" AssetTags="" />
|
||||||
|
</Group>
|
||||||
</Package>
|
</Package>
|
||||||
</root>
|
</root>
|
||||||
@@ -21,7 +21,7 @@ MonoBehaviour:
|
|||||||
PackageDesc:
|
PackageDesc:
|
||||||
Groups:
|
Groups:
|
||||||
- GroupName: battle
|
- GroupName: battle
|
||||||
GroupDesc:
|
GroupDesc: "\u6218\u6597"
|
||||||
AssetTags:
|
AssetTags:
|
||||||
ActiveRuleName: EnableGroup
|
ActiveRuleName: EnableGroup
|
||||||
Collectors:
|
Collectors:
|
||||||
@@ -50,7 +50,7 @@ MonoBehaviour:
|
|||||||
AssetTags:
|
AssetTags:
|
||||||
UserData:
|
UserData:
|
||||||
- GroupName: shader
|
- GroupName: shader
|
||||||
GroupDesc:
|
GroupDesc: "\u7740\u8272\u5668"
|
||||||
AssetTags:
|
AssetTags:
|
||||||
ActiveRuleName: EnableGroup
|
ActiveRuleName: EnableGroup
|
||||||
Collectors:
|
Collectors:
|
||||||
@@ -63,7 +63,7 @@ MonoBehaviour:
|
|||||||
AssetTags:
|
AssetTags:
|
||||||
UserData:
|
UserData:
|
||||||
- GroupName: scene
|
- GroupName: scene
|
||||||
GroupDesc:
|
GroupDesc: "\u573A\u666F"
|
||||||
AssetTags:
|
AssetTags:
|
||||||
ActiveRuleName: EnableGroup
|
ActiveRuleName: EnableGroup
|
||||||
Collectors:
|
Collectors:
|
||||||
@@ -76,7 +76,7 @@ MonoBehaviour:
|
|||||||
AssetTags:
|
AssetTags:
|
||||||
UserData:
|
UserData:
|
||||||
- GroupName: ugui
|
- GroupName: ugui
|
||||||
GroupDesc:
|
GroupDesc: "\u9762\u677F"
|
||||||
AssetTags:
|
AssetTags:
|
||||||
ActiveRuleName: EnableGroup
|
ActiveRuleName: EnableGroup
|
||||||
Collectors:
|
Collectors:
|
||||||
@@ -104,3 +104,16 @@ MonoBehaviour:
|
|||||||
FilterRuleName: CollectAll
|
FilterRuleName: CollectAll
|
||||||
AssetTags:
|
AssetTags:
|
||||||
UserData:
|
UserData:
|
||||||
|
- GroupName: config
|
||||||
|
GroupDesc: "\u914D\u7F6E\u8868"
|
||||||
|
AssetTags:
|
||||||
|
ActiveRuleName: EnableGroup
|
||||||
|
Collectors:
|
||||||
|
- CollectPath: Assets/Samples/Space Shooter/GameRes/Config
|
||||||
|
CollectorGUID: 1894d23646ddbf8479e579cc03261dde
|
||||||
|
CollectorType: 0
|
||||||
|
AddressRuleName: AddressByFileName
|
||||||
|
PackRuleName: PackRawFile
|
||||||
|
FilterRuleName: CollectAll
|
||||||
|
AssetTags:
|
||||||
|
UserData:
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 1894d23646ddbf8479e579cc03261dde
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
Powered by YooAsset @tuyoogame
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 66ce1e032fc66694bb3fce32961d78d5
|
||||||
|
TextScriptImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -14,7 +14,7 @@ GameObject:
|
|||||||
- component: {fileID: 8153114547710269446}
|
- component: {fileID: 8153114547710269446}
|
||||||
m_Layer: 0
|
m_Layer: 0
|
||||||
m_Name: asteroid01
|
m_Name: asteroid01
|
||||||
m_TagString: Asteroid
|
m_TagString: Untagged
|
||||||
m_Icon: {fileID: 0}
|
m_Icon: {fileID: 0}
|
||||||
m_NavMeshLayer: 0
|
m_NavMeshLayer: 0
|
||||||
m_StaticEditorFlags: 0
|
m_StaticEditorFlags: 0
|
||||||
|
|||||||
@@ -93,7 +93,7 @@ GameObject:
|
|||||||
- component: {fileID: 6609967452740485438}
|
- component: {fileID: 6609967452740485438}
|
||||||
m_Layer: 0
|
m_Layer: 0
|
||||||
m_Name: asteroid02
|
m_Name: asteroid02
|
||||||
m_TagString: Asteroid
|
m_TagString: Untagged
|
||||||
m_Icon: {fileID: 0}
|
m_Icon: {fileID: 0}
|
||||||
m_NavMeshLayer: 0
|
m_NavMeshLayer: 0
|
||||||
m_StaticEditorFlags: 0
|
m_StaticEditorFlags: 0
|
||||||
|
|||||||
@@ -93,7 +93,7 @@ GameObject:
|
|||||||
- component: {fileID: 4093119317317235419}
|
- component: {fileID: 4093119317317235419}
|
||||||
m_Layer: 0
|
m_Layer: 0
|
||||||
m_Name: asteroid03
|
m_Name: asteroid03
|
||||||
m_TagString: Asteroid
|
m_TagString: Untagged
|
||||||
m_Icon: {fileID: 0}
|
m_Icon: {fileID: 0}
|
||||||
m_NavMeshLayer: 0
|
m_NavMeshLayer: 0
|
||||||
m_StaticEditorFlags: 0
|
m_StaticEditorFlags: 0
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ GameObject:
|
|||||||
- component: {fileID: 7168776728617073029}
|
- component: {fileID: 7168776728617073029}
|
||||||
m_Layer: 0
|
m_Layer: 0
|
||||||
m_Name: enemy_bullet
|
m_Name: enemy_bullet
|
||||||
m_TagString: EnemyBullet
|
m_TagString: Untagged
|
||||||
m_Icon: {fileID: 0}
|
m_Icon: {fileID: 0}
|
||||||
m_NavMeshLayer: 0
|
m_NavMeshLayer: 0
|
||||||
m_StaticEditorFlags: 0
|
m_StaticEditorFlags: 0
|
||||||
|
|||||||
@@ -4714,7 +4714,7 @@ GameObject:
|
|||||||
- component: {fileID: 8046716069608073559}
|
- component: {fileID: 8046716069608073559}
|
||||||
m_Layer: 0
|
m_Layer: 0
|
||||||
m_Name: enemy_ship
|
m_Name: enemy_ship
|
||||||
m_TagString: Enemy
|
m_TagString: Untagged
|
||||||
m_Icon: {fileID: 0}
|
m_Icon: {fileID: 0}
|
||||||
m_NavMeshLayer: 0
|
m_NavMeshLayer: 0
|
||||||
m_StaticEditorFlags: 0
|
m_StaticEditorFlags: 0
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ GameObject:
|
|||||||
- component: {fileID: 2296800368016434796}
|
- component: {fileID: 2296800368016434796}
|
||||||
m_Layer: 0
|
m_Layer: 0
|
||||||
m_Name: player_bullet
|
m_Name: player_bullet
|
||||||
m_TagString: PlayerBullet
|
m_TagString: Untagged
|
||||||
m_Icon: {fileID: 0}
|
m_Icon: {fileID: 0}
|
||||||
m_NavMeshLayer: 0
|
m_NavMeshLayer: 0
|
||||||
m_StaticEditorFlags: 0
|
m_StaticEditorFlags: 0
|
||||||
|
|||||||
@@ -9481,7 +9481,7 @@ GameObject:
|
|||||||
- component: {fileID: 5342208951388308754}
|
- component: {fileID: 5342208951388308754}
|
||||||
m_Layer: 0
|
m_Layer: 0
|
||||||
m_Name: player_ship
|
m_Name: player_ship
|
||||||
m_TagString: Player
|
m_TagString: Untagged
|
||||||
m_Icon: {fileID: 0}
|
m_Icon: {fileID: 0}
|
||||||
m_NavMeshLayer: 0
|
m_NavMeshLayer: 0
|
||||||
m_StaticEditorFlags: 0
|
m_StaticEditorFlags: 0
|
||||||
|
|||||||
@@ -129,7 +129,7 @@ GameObject:
|
|||||||
- component: {fileID: 37}
|
- component: {fileID: 37}
|
||||||
m_Layer: 0
|
m_Layer: 0
|
||||||
m_Name: Boundary
|
m_Name: Boundary
|
||||||
m_TagString: Boundary
|
m_TagString: Untagged
|
||||||
m_Icon: {fileID: 0}
|
m_Icon: {fileID: 0}
|
||||||
m_NavMeshLayer: 0
|
m_NavMeshLayer: 0
|
||||||
m_StaticEditorFlags: 0
|
m_StaticEditorFlags: 0
|
||||||
@@ -10999,7 +10999,7 @@ GameObject:
|
|||||||
- component: {fileID: 1691764579}
|
- component: {fileID: 1691764579}
|
||||||
m_Layer: 0
|
m_Layer: 0
|
||||||
m_Name: BoundaryWorld
|
m_Name: BoundaryWorld
|
||||||
m_TagString: Boundary
|
m_TagString: Untagged
|
||||||
m_Icon: {fileID: 0}
|
m_Icon: {fileID: 0}
|
||||||
m_NavMeshLayer: 0
|
m_NavMeshLayer: 0
|
||||||
m_StaticEditorFlags: 0
|
m_StaticEditorFlags: 0
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ MonoBehaviour:
|
|||||||
m_Calls: []
|
m_Calls: []
|
||||||
m_FontData:
|
m_FontData:
|
||||||
m_Font: {fileID: 12800000, guid: 8297a2bf97dbbba468bd2518d003a876, type: 3}
|
m_Font: {fileID: 12800000, guid: 8297a2bf97dbbba468bd2518d003a876, type: 3}
|
||||||
m_FontSize: 28
|
m_FontSize: 22
|
||||||
m_FontStyle: 0
|
m_FontStyle: 0
|
||||||
m_BestFit: 0
|
m_BestFit: 0
|
||||||
m_MinSize: 2
|
m_MinSize: 2
|
||||||
@@ -77,7 +77,7 @@ MonoBehaviour:
|
|||||||
m_HorizontalOverflow: 0
|
m_HorizontalOverflow: 0
|
||||||
m_VerticalOverflow: 0
|
m_VerticalOverflow: 0
|
||||||
m_LineSpacing: 1
|
m_LineSpacing: 1
|
||||||
m_Text: Powered by YooAsset
|
m_Text:
|
||||||
--- !u!1 &4142826567245113227
|
--- !u!1 &4142826567245113227
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
|||||||
@@ -25,7 +25,8 @@ public class EntityAsteroid : MonoBehaviour
|
|||||||
}
|
}
|
||||||
void OnTriggerEnter(Collider other)
|
void OnTriggerEnter(Collider other)
|
||||||
{
|
{
|
||||||
if (other.CompareTag("PlayerBullet"))
|
var name = other.gameObject.name;
|
||||||
|
if (name.StartsWith("player"))
|
||||||
{
|
{
|
||||||
BattleEventDefine.AsteroidExplosion.SendEventMessage(this.transform.position, this.transform.rotation);
|
BattleEventDefine.AsteroidExplosion.SendEventMessage(this.transform.position, this.transform.rotation);
|
||||||
_handle.Restore();
|
_handle.Restore();
|
||||||
@@ -34,7 +35,8 @@ public class EntityAsteroid : MonoBehaviour
|
|||||||
}
|
}
|
||||||
void OnTriggerExit(Collider other)
|
void OnTriggerExit(Collider other)
|
||||||
{
|
{
|
||||||
if (other.CompareTag("Boundary"))
|
var name = other.gameObject.name;
|
||||||
|
if (name.StartsWith("Boundary"))
|
||||||
{
|
{
|
||||||
_handle.Restore();
|
_handle.Restore();
|
||||||
_handle = null;
|
_handle = null;
|
||||||
|
|||||||
@@ -19,25 +19,27 @@ public class EntityBullet : MonoBehaviour
|
|||||||
|
|
||||||
void Awake()
|
void Awake()
|
||||||
{
|
{
|
||||||
_rigidbody = this.transform.GetComponent<Rigidbody>();
|
_rigidbody = this.transform.GetComponent<Rigidbody>();
|
||||||
}
|
}
|
||||||
void OnTriggerEnter(Collider other)
|
void OnTriggerEnter(Collider other)
|
||||||
{
|
{
|
||||||
if (other.CompareTag("Boundary"))
|
var name = other.gameObject.name;
|
||||||
|
if (name.StartsWith("Boundary"))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (this.gameObject.CompareTag("EnemyBullet"))
|
var goName = this.gameObject.name;
|
||||||
|
if (goName.StartsWith("enemy_bullet"))
|
||||||
{
|
{
|
||||||
if (other.CompareTag("Enemy") == false)
|
if (name.StartsWith("enemy") == false)
|
||||||
{
|
{
|
||||||
_handle.Restore();
|
_handle.Restore();
|
||||||
_handle = null;
|
_handle = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.gameObject.CompareTag("PlayerBullet"))
|
if (goName.StartsWith("player_bullet"))
|
||||||
{
|
{
|
||||||
if (other.CompareTag("Player") == false)
|
if (name.StartsWith("player") == false)
|
||||||
{
|
{
|
||||||
_handle.Restore();
|
_handle.Restore();
|
||||||
_handle = null;
|
_handle = null;
|
||||||
@@ -46,7 +48,8 @@ public class EntityBullet : MonoBehaviour
|
|||||||
}
|
}
|
||||||
void OnTriggerExit(Collider other)
|
void OnTriggerExit(Collider other)
|
||||||
{
|
{
|
||||||
if (other.CompareTag("Boundary"))
|
var name = other.gameObject.name;
|
||||||
|
if (name.StartsWith("Boundary"))
|
||||||
{
|
{
|
||||||
_handle.Restore();
|
_handle.Restore();
|
||||||
_handle = null;
|
_handle = null;
|
||||||
|
|||||||
@@ -68,7 +68,8 @@ public class EntityEnemy : MonoBehaviour
|
|||||||
}
|
}
|
||||||
void OnTriggerEnter(Collider other)
|
void OnTriggerEnter(Collider other)
|
||||||
{
|
{
|
||||||
if (other.CompareTag("PlayerBullet"))
|
var name = other.gameObject.name;
|
||||||
|
if (name.StartsWith("player"))
|
||||||
{
|
{
|
||||||
BattleEventDefine.EnemyDead.SendEventMessage(this.transform.position, this.transform.rotation);
|
BattleEventDefine.EnemyDead.SendEventMessage(this.transform.position, this.transform.rotation);
|
||||||
_handle.Restore();
|
_handle.Restore();
|
||||||
@@ -77,7 +78,8 @@ public class EntityEnemy : MonoBehaviour
|
|||||||
}
|
}
|
||||||
void OnTriggerExit(Collider other)
|
void OnTriggerExit(Collider other)
|
||||||
{
|
{
|
||||||
if (other.CompareTag("Boundary"))
|
var name = other.gameObject.name;
|
||||||
|
if (name.StartsWith("Boundary"))
|
||||||
{
|
{
|
||||||
_handle.Restore();
|
_handle.Restore();
|
||||||
_handle = null;
|
_handle = null;
|
||||||
|
|||||||
@@ -54,7 +54,8 @@ public class EntityPlayer : MonoBehaviour
|
|||||||
}
|
}
|
||||||
void OnTriggerEnter(Collider other)
|
void OnTriggerEnter(Collider other)
|
||||||
{
|
{
|
||||||
if (other.CompareTag("Enemy") || other.CompareTag("EnemyBullet") || other.CompareTag("Asteroid"))
|
var name = other.gameObject.name;
|
||||||
|
if (name.StartsWith("enemy") || name.StartsWith("asteroid"))
|
||||||
{
|
{
|
||||||
BattleEventDefine.PlayerDead.SendEventMessage(this.transform.position, this.transform.rotation);
|
BattleEventDefine.PlayerDead.SendEventMessage(this.transform.position, this.transform.rotation);
|
||||||
_handle.Restore();
|
_handle.Restore();
|
||||||
|
|||||||
@@ -142,7 +142,7 @@ internal class FsmInitialize : IStateNode
|
|||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
public FileStream LoadFromStream(DecryptFileInfo fileInfo)
|
public Stream LoadFromStream(DecryptFileInfo fileInfo)
|
||||||
{
|
{
|
||||||
BundleStream bundleStream = new BundleStream(fileInfo.FilePath, FileMode.Open);
|
BundleStream bundleStream = new BundleStream(fileInfo.FilePath, FileMode.Open);
|
||||||
return bundleStream;
|
return bundleStream;
|
||||||
|
|||||||
@@ -3,17 +3,26 @@ using System.Collections.Generic;
|
|||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
using UniFramework.Window;
|
using UniFramework.Window;
|
||||||
|
using YooAsset;
|
||||||
|
|
||||||
[WindowAttribute(100, false)]
|
[WindowAttribute(100, false)]
|
||||||
public class UIAboutWindow : UIWindow
|
public class UIAboutWindow : UIWindow
|
||||||
{
|
{
|
||||||
|
private Text _info;
|
||||||
|
private RawFileOperationHandle _handle;
|
||||||
|
|
||||||
public override void OnCreate()
|
public override void OnCreate()
|
||||||
{
|
{
|
||||||
var maskBtn = this.transform.Find("mask").GetComponent<Button>();
|
var maskBtn = this.transform.Find("mask").GetComponent<Button>();
|
||||||
maskBtn.onClick.AddListener(OnClicMaskBtn);
|
maskBtn.onClick.AddListener(OnClicMaskBtn);
|
||||||
|
|
||||||
|
_info = this.transform.Find("bg/info").GetComponent<Text>();
|
||||||
|
_handle = YooAssets.LoadRawFileAsync("about");
|
||||||
|
_handle.Completed += _handle_Completed;
|
||||||
}
|
}
|
||||||
public override void OnDestroy()
|
public override void OnDestroy()
|
||||||
{
|
{
|
||||||
|
_handle.Release();
|
||||||
}
|
}
|
||||||
public override void OnRefresh()
|
public override void OnRefresh()
|
||||||
{
|
{
|
||||||
@@ -22,6 +31,11 @@ public class UIAboutWindow : UIWindow
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void _handle_Completed(RawFileOperationHandle obj)
|
||||||
|
{
|
||||||
|
_info.text = _handle.GetRawFileText();
|
||||||
|
}
|
||||||
|
|
||||||
private void OnClicMaskBtn()
|
private void OnClicMaskBtn()
|
||||||
{
|
{
|
||||||
UniWindow.CloseWindow<UIAboutWindow>();
|
UniWindow.CloseWindow<UIAboutWindow>();
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "com.tuyoogame.yooasset",
|
"name": "com.tuyoogame.yooasset",
|
||||||
"displayName": "YooAsset",
|
"displayName": "YooAsset",
|
||||||
"version": "1.4.7",
|
"version": "1.4.8",
|
||||||
"unity": "2019.4",
|
"unity": "2019.4",
|
||||||
"description": "unity3d resources management system.",
|
"description": "unity3d resources management system.",
|
||||||
"author": {
|
"author": {
|
||||||
|
|||||||
Reference in New Issue
Block a user