Compare commits

...

19 Commits
1.3.1 ... 1.3.2

Author SHA1 Message Date
hevinci
92e7ec9682 Update CHANGELOG.md 2022-10-22 10:03:41 +08:00
hevinci
32b7ff1b36 Update package.json 2022-10-22 10:03:16 +08:00
hevinci
5a68ef558f Update YooAssets.cs 2022-10-22 10:03:12 +08:00
hevinci
18d48ae963 update collector window
点击修复按钮后自动刷新界面
2022-10-21 18:46:04 +08:00
hevinci
d61c723933 update basic sample 2022-10-21 18:36:28 +08:00
hevinci
bb64ff7278 update runtime code
移除了ILocationServices接口类。
增加了bool CheckLocationValid(string location)方法。
2022-10-21 18:36:03 +08:00
hevinci
d7760cd34d update diagnostic system 2022-10-21 16:49:58 +08:00
hevinci
f9ecad1cf0 Update download system
增加证书认证方法
2022-10-21 15:18:16 +08:00
hevinci
a6de89ab74 Update runtime code 2022-10-19 19:30:50 +08:00
hevinci
e663dcf83b Update document 2022-10-19 19:12:22 +08:00
hevinci
88e8e5cd54 Update AssetBundleCollector 2022-10-19 19:11:57 +08:00
hevinci
9b43d36793 Update basic sample 2022-10-19 18:57:38 +08:00
hevinci
794314a8e1 Update AssetBundleCollector 2022-10-19 18:57:00 +08:00
hevinci
0a1c40cee5 Update download system
增加SetDownloadSystemClearFileResponseCode()新方法
2022-10-19 18:18:32 +08:00
hevinci
958cdd25a5 Update AssetBundleBuilder 2022-10-19 15:54:59 +08:00
hevinci
2fb77c1bf8 Update ShaderVariantCollector 2022-10-19 15:52:46 +08:00
hevinci
3aa46664f7 Update AssetBundleReporter 2022-10-19 15:52:32 +08:00
hevinci
8389ce5793 Update AssetBundleCollector 2022-10-19 15:52:16 +08:00
hevinci
5199430766 Update document 2022-10-18 19:27:47 +08:00
68 changed files with 508 additions and 243 deletions

View File

@@ -2,6 +2,61 @@
All notable changes to this package will be documented in this file.
## [1.3.2] - 2022-10-22
### Fixed
- 修复了AssetBundleCollector界面点击修复按钮界面没有刷新的问题。
### Added
- 新增了自定义证书认证方法。
````c#
public static class YooAssets
{
/// <summary>
/// 设置下载系统参数,自定义的证书认证实例
/// </summary>
public static void SetDownloadSystemCertificateHandler(UnityEngine.Networking.CertificateHandler instance)
}
````
- 新增了下载失败后清理文件的方法。
````c#
public static class YooAssets
{
/// <summary>
/// 设置下载系统参数下载失败后清理文件的HTTP错误码
/// </summary>
public static void SetDownloadSystemClearFileResponseCode(List<long> codes)
}
````
- 新增了检查资源定位地址是否有效的方法。
```c#
public class AssetsPackage
{
/// <summary>
/// 检查资源定位地址是否有效
/// </summary>
/// <param name="location">资源的定位地址</param>
public bool CheckLocationValid(string location)
}
```
### Removed
- 移除了ILocationServices接口类和初始化字段。
- 移除了AssetPackage.GetAssetPath(string location)方法。
- 移除了BuildParameters.EnableAddressable字段。
### Changed
- AssetBundleCollector配置增加了UniqueBundleName设置用于解决不同包裹之间Bundle名称冲突的问题。
## [1.3.1] - 2022-10-18
### Fixed

View File

@@ -257,7 +257,6 @@ namespace YooAsset.Editor
buildParameters.BuildMode = AssetBundleBuilderSettingData.Setting.BuildMode;
buildParameters.BuildPackage = AssetBundleBuilderSettingData.Setting.BuildPackage;
buildParameters.VerifyBuildingResult = true;
buildParameters.EnableAddressable = AssetBundleCollectorSettingData.Setting.EnableAddressable;
buildParameters.EncryptionServices = CreateEncryptionServicesInstance();
buildParameters.CompressOption = AssetBundleBuilderSettingData.Setting.CompressOption;
buildParameters.OutputNameStyle = AssetBundleBuilderSettingData.Setting.OutputNameStyle;

View File

@@ -15,7 +15,6 @@ namespace YooAsset.Editor
buildParameters.BuildTarget = EditorUserBuildSettings.activeBuildTarget;
buildParameters.BuildMode = EBuildMode.SimulateBuild;
buildParameters.BuildPackage = packageName;
buildParameters.EnableAddressable = AssetBundleCollectorSettingData.Setting.EnableAddressable;
AssetBundleBuilder builder = new AssetBundleBuilder();
var buildResult = builder.Run(buildParameters);

View File

@@ -166,7 +166,7 @@ namespace YooAsset.Editor
/// <summary>
/// 计算主资源或共享资源的完整包名
/// </summary>
public void CalculateFullBundleName()
public void CalculateFullBundleName(bool uniqueBundleName, string packageName)
{
if (CollectorType == ECollectorType.None)
{
@@ -177,15 +177,22 @@ namespace YooAsset.Editor
{
string shareBundleName = YooAssetSettingsData.GetUnityShadersBundleFullName();
_shareBundleName = EditorTools.GetRegularPath(shareBundleName).ToLower();
return;
}
else
{
if (_referenceBundleNames.Count > 1)
{
IPackRule packRule = PackDirectory.StaticPackRule;
var bundleName = packRule.GetBundleName(new PackRuleData(AssetPath));
var shareBundleName = $"share_{bundleName}.{YooAssetSettingsData.Setting.AssetBundleFileVariant}";
_shareBundleName = EditorTools.GetRegularPath(shareBundleName).ToLower();
}
}
if (_referenceBundleNames.Count > 1)
if (uniqueBundleName)
{
IPackRule packRule = PackDirectory.StaticPackRule;
var bundleName = packRule.GetBundleName(new PackRuleData(AssetPath));
var shareBundleName = $"share_{bundleName}.{YooAssetSettingsData.Setting.AssetBundleFileVariant}";
_shareBundleName = EditorTools.GetRegularPath(shareBundleName).ToLower();
if (string.IsNullOrEmpty(_shareBundleName) == false)
_shareBundleName = $"{packageName.ToLower()}_{_shareBundleName}";
}
}
else

View File

@@ -14,6 +14,16 @@ namespace YooAsset.Editor
/// </summary>
public int AssetFileCount;
/// <summary>
/// 是否启用可寻址资源定位
/// </summary>
public bool EnableAddressable;
/// <summary>
/// 资源包名唯一化
/// </summary>
public bool UniqueBundleName;
/// <summary>
/// 资源包列表
/// </summary>

View File

@@ -19,7 +19,8 @@ namespace YooAsset.Editor
AssetBundleCollectorSettingData.Setting.CheckConfigError();
// 2. 获取所有收集器收集的资源
List<CollectAssetInfo> allCollectAssets = AssetBundleCollectorSettingData.Setting.GetPackageAssets(buildMode, packageName);
var buildResult = AssetBundleCollectorSettingData.Setting.GetPackageAssets(buildMode, packageName);
List<CollectAssetInfo> allCollectAssets = buildResult.CollectAssets;
// 3. 剔除未被引用的依赖资源
List<CollectAssetInfo> removeDependList = new List<CollectAssetInfo>();
@@ -72,9 +73,13 @@ namespace YooAsset.Editor
}
}
}
context.AssetFileCount = buildAssetDic.Count;
// 6. 填充主动收集资源的依赖列表
// 6. 记录关键信息
context.AssetFileCount = buildAssetDic.Count;
context.EnableAddressable = buildResult.EnableAddressable;
context.UniqueBundleName = buildResult.UniqueBundleName;
// 7. 填充主动收集资源的依赖列表
foreach (var collectAssetInfo in allCollectAssets)
{
var dependAssetInfos = new List<BuildAssetInfo>(collectAssetInfo.DependAssets.Count);
@@ -88,13 +93,13 @@ namespace YooAsset.Editor
buildAssetDic[collectAssetInfo.AssetPath].SetAllDependAssetInfos(dependAssetInfos);
}
// 7. 计算完整的资源包名
// 8. 计算完整的资源包名
foreach (KeyValuePair<string, BuildAssetInfo> pair in buildAssetDic)
{
pair.Value.CalculateFullBundleName();
pair.Value.CalculateFullBundleName(buildResult.UniqueBundleName, buildResult.PackageName);
}
// 8. 移除不参与构建的资源
// 9. 移除不参与构建的资源
List<BuildAssetInfo> removeBuildList = new List<BuildAssetInfo>();
foreach (KeyValuePair<string, BuildAssetInfo> pair in buildAssetDic)
{
@@ -107,7 +112,7 @@ namespace YooAsset.Editor
buildAssetDic.Remove(removeValue.AssetPath);
}
// 9. 构建资源包
// 10. 构建资源包
var allBuildinAssets = buildAssetDic.Values.ToList();
if (allBuildinAssets.Count == 0)
throw new Exception("构建的资源列表不能为空");

View File

@@ -71,12 +71,7 @@ namespace YooAsset.Editor
/// 验证构建结果
/// </summary>
public bool VerifyBuildingResult = false;
/// <summary>
/// 启用可寻址资源定位
/// </summary>
public bool EnableAddressable = false;
/// <summary>
/// 加密类
/// </summary>

View File

@@ -53,6 +53,11 @@ namespace YooAsset.Editor
/// </summary>
public bool EnableAddressable;
/// <summary>
/// 资源包名唯一化
/// </summary>
public bool UniqueBundleName;
/// <summary>
/// 加密服务类名称
/// </summary>

View File

@@ -21,6 +21,7 @@ namespace YooAsset.Editor
/// </summary>
private void CreatePatchManifestFile(BuildContext context)
{
var buildMapContext = context.GetContextObject<BuildMapContext>();
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
var buildParameters = buildParametersContext.Parameters;
string pipelineOutputDirectory = buildParametersContext.GetPipelineOutputDirectory();
@@ -28,7 +29,7 @@ namespace YooAsset.Editor
// 创建新补丁清单
PatchManifest patchManifest = new PatchManifest();
patchManifest.FileVersion = YooAssetSettings.PatchManifestFileVersion;
patchManifest.EnableAddressable = buildParameters.EnableAddressable;
patchManifest.EnableAddressable = buildMapContext.EnableAddressable;
patchManifest.OutputNameStyle = (int)buildParameters.OutputNameStyle;
patchManifest.PackageName = buildParameters.BuildPackage;
patchManifest.HumanReadableVersion = buildParameters.HumanReadableVersion;
@@ -125,7 +126,6 @@ namespace YooAsset.Editor
/// </summary>
private List<PatchAsset> GetAllPatchAsset(BuildContext context, PatchManifest patchManifest)
{
var buildParameters = context.GetContextObject<BuildParametersContext>();
var buildMapContext = context.GetContextObject<BuildMapContext>();
List<PatchAsset> result = new List<PatchAsset>(1000);
@@ -135,7 +135,7 @@ namespace YooAsset.Editor
foreach (var assetInfo in assetInfos)
{
PatchAsset patchAsset = new PatchAsset();
if (buildParameters.Parameters.EnableAddressable)
if (buildMapContext.EnableAddressable)
patchAsset.Address = assetInfo.Address;
else
patchAsset.Address = string.Empty;

View File

@@ -46,7 +46,9 @@ namespace YooAsset.Editor
buildReport.Summary.BuildPipeline = buildParameters.BuildPipeline;
buildReport.Summary.BuildMode = buildParameters.BuildMode;
buildReport.Summary.BuildPackage = buildParameters.BuildPackage;
buildReport.Summary.EnableAddressable = buildParameters.EnableAddressable;
buildReport.Summary.EnableAddressable = buildMapContext.EnableAddressable;
buildReport.Summary.UniqueBundleName = buildMapContext.UniqueBundleName;
buildReport.Summary.EncryptionServicesClassName = buildParameters.EncryptionServices == null ?
"null" : buildParameters.EncryptionServices.GetType().FullName;

View File

@@ -132,10 +132,10 @@ namespace YooAsset.Editor
/// <summary>
/// 获取打包收集的资源文件
/// </summary>
public List<CollectAssetInfo> GetAllCollectAssets(EBuildMode buildMode, bool enableAddressable, AssetBundleCollectorGroup group)
public List<CollectAssetInfo> GetAllCollectAssets(CollectCommand command, AssetBundleCollectorGroup group)
{
// 注意:模拟构建模式下只收集主资源
if (buildMode == EBuildMode.SimulateBuild)
if (command.BuildMode == EBuildMode.SimulateBuild)
{
if (CollectorType != ECollectorType.MainAssetCollector)
return new List<CollectAssetInfo>();
@@ -162,7 +162,7 @@ namespace YooAsset.Editor
{
if (result.ContainsKey(assetPath) == false)
{
var collectAssetInfo = CreateCollectAssetInfo(buildMode, group, assetPath, isRawAsset);
var collectAssetInfo = CreateCollectAssetInfo(command, group, assetPath, isRawAsset);
result.Add(assetPath, collectAssetInfo);
}
else
@@ -177,7 +177,7 @@ namespace YooAsset.Editor
string assetPath = CollectPath;
if (IsValidateAsset(assetPath) && IsCollectAsset(assetPath))
{
var collectAssetInfo = CreateCollectAssetInfo(buildMode, group, assetPath, isRawAsset);
var collectAssetInfo = CreateCollectAssetInfo(command, group, assetPath, isRawAsset);
result.Add(assetPath, collectAssetInfo);
}
else
@@ -187,7 +187,7 @@ namespace YooAsset.Editor
}
// 检测可寻址地址是否重复
if (enableAddressable)
if (command.EnableAddressable)
{
HashSet<string> adressTemper = new HashSet<string>();
foreach (var collectInfoPair in result)
@@ -207,7 +207,7 @@ namespace YooAsset.Editor
return result.Values.ToList();
}
private CollectAssetInfo CreateCollectAssetInfo(EBuildMode buildMode, AssetBundleCollectorGroup group, string assetPath, bool isRawAsset)
private CollectAssetInfo CreateCollectAssetInfo(CollectCommand command, AssetBundleCollectorGroup group, string assetPath, bool isRawAsset)
{
string address = GetAddress(group, assetPath);
string bundleName = GetBundleName(group, assetPath);
@@ -215,7 +215,7 @@ namespace YooAsset.Editor
CollectAssetInfo collectAssetInfo = new CollectAssetInfo(CollectorType, bundleName, address, assetPath, assetTags, isRawAsset);
// 注意:模拟构建模式下不需要收集依赖资源
if (buildMode == EBuildMode.SimulateBuild)
if (command.BuildMode == EBuildMode.SimulateBuild)
collectAssetInfo.DependAssets = new List<string>();
else
collectAssetInfo.DependAssets = GetAllDependencies(assetPath);

View File

@@ -10,11 +10,12 @@ namespace YooAsset.Editor
{
public class AssetBundleCollectorConfig
{
public const string ConfigVersion = "2.0";
public const string ConfigVersion = "2.1";
public const string XmlVersion = "Version";
public const string XmlCommon = "Common";
public const string XmlEnableAddressable = "AutoAddressable";
public const string XmlUniqueBundleName = "UniqueBundleName";
public const string XmlShowPackageView = "ShowPackageView";
public const string XmlPackage = "Package";
@@ -62,6 +63,7 @@ namespace YooAsset.Editor
// 读取公共配置
bool enableAddressable = false;
bool uniqueBundleName = false;
bool showPackageView = false;
var commonNodeList = root.GetElementsByTagName(XmlCommon);
if (commonNodeList.Count > 0)
@@ -69,10 +71,13 @@ namespace YooAsset.Editor
XmlElement commonElement = commonNodeList[0] as XmlElement;
if (commonElement.HasAttribute(XmlEnableAddressable) == false)
throw new Exception($"Not found attribute {XmlEnableAddressable} in {XmlCommon}");
if (commonElement.HasAttribute(XmlUniqueBundleName) == false)
throw new Exception($"Not found attribute {XmlUniqueBundleName} in {XmlCommon}");
if (commonElement.HasAttribute(XmlShowPackageView) == false)
throw new Exception($"Not found attribute {XmlShowPackageView} in {XmlCommon}");
enableAddressable = commonElement.GetAttribute(XmlEnableAddressable) == "True" ? true : false;
uniqueBundleName = commonElement.GetAttribute(XmlUniqueBundleName) == "True" ? true : false;
showPackageView = commonElement.GetAttribute(XmlShowPackageView) == "True" ? true : false;
}
@@ -146,6 +151,7 @@ namespace YooAsset.Editor
// 保存配置数据
AssetBundleCollectorSettingData.ClearAll();
AssetBundleCollectorSettingData.Setting.EnableAddressable = enableAddressable;
AssetBundleCollectorSettingData.Setting.UniqueBundleName = uniqueBundleName;
AssetBundleCollectorSettingData.Setting.ShowPackageView = showPackageView;
AssetBundleCollectorSettingData.Setting.Packages.AddRange(packages);
AssetBundleCollectorSettingData.SaveFile();
@@ -175,6 +181,7 @@ namespace YooAsset.Editor
// 设置公共配置
var commonElement = xmlDoc.CreateElement(XmlCommon);
commonElement.SetAttribute(XmlEnableAddressable, AssetBundleCollectorSettingData.Setting.EnableAddressable.ToString());
commonElement.SetAttribute(XmlUniqueBundleName, AssetBundleCollectorSettingData.Setting.UniqueBundleName.ToString());
commonElement.SetAttribute(XmlShowPackageView, AssetBundleCollectorSettingData.Setting.ShowPackageView.ToString());
root.AppendChild(commonElement);
@@ -269,7 +276,23 @@ namespace YooAsset.Editor
// 更新版本
root.SetAttribute(XmlVersion, "2.0");
return UpdateXmlConfig(xmlDoc);
}
// 2.0 -> 2.1
if (configVersion == "2.0")
{
// 添加公共元素属性
var commonNodeList = root.GetElementsByTagName(XmlCommon);
if (commonNodeList.Count > 0)
{
XmlElement commonElement = commonNodeList[0] as XmlElement;
if (commonElement.HasAttribute(XmlUniqueBundleName) == false)
commonElement.SetAttribute(XmlUniqueBundleName, "False");
}
// 更新版本
root.SetAttribute(XmlVersion, "2.1");
return UpdateXmlConfig(xmlDoc);
}

View File

@@ -69,7 +69,7 @@ namespace YooAsset.Editor
/// <summary>
/// 获取打包收集的资源文件
/// </summary>
public List<CollectAssetInfo> GetAllCollectAssets(EBuildMode buildMode, bool enableAddressable)
public List<CollectAssetInfo> GetAllCollectAssets(CollectCommand command)
{
Dictionary<string, CollectAssetInfo> result = new Dictionary<string, CollectAssetInfo>(10000);
@@ -83,7 +83,7 @@ namespace YooAsset.Editor
// 收集打包资源
foreach (var collector in Collectors)
{
var temper = collector.GetAllCollectAssets(buildMode, enableAddressable, this);
var temper = collector.GetAllCollectAssets(command, this);
foreach (var assetInfo in temper)
{
if (result.ContainsKey(assetInfo.AssetPath) == false)
@@ -94,7 +94,7 @@ namespace YooAsset.Editor
}
// 检测可寻址地址是否重复
if (enableAddressable)
if (command.EnableAddressable)
{
HashSet<string> adressTemper = new HashSet<string>();
foreach (var collectInfoPair in result)

View File

@@ -56,14 +56,14 @@ namespace YooAsset.Editor
/// <summary>
/// 获取打包收集的资源文件
/// </summary>
public List<CollectAssetInfo> GetAllCollectAssets(EBuildMode buildMode, bool enableAddressable)
public List<CollectAssetInfo> GetAllCollectAssets(CollectCommand command)
{
Dictionary<string, CollectAssetInfo> result = new Dictionary<string, CollectAssetInfo>(10000);
// 收集打包资源
foreach (var group in Groups)
{
var temper = group.GetAllCollectAssets(buildMode, enableAddressable);
var temper = group.GetAllCollectAssets(command);
foreach (var assetInfo in temper)
{
if (result.ContainsKey(assetInfo.AssetPath) == false)
@@ -74,7 +74,7 @@ namespace YooAsset.Editor
}
// 检测可寻址地址是否重复
if (enableAddressable)
if (command.EnableAddressable)
{
HashSet<string> adressTemper = new HashSet<string>();
foreach (var collectInfoPair in result)

View File

@@ -9,7 +9,7 @@ namespace YooAsset.Editor
public class AssetBundleCollectorSetting : ScriptableObject
{
/// <summary>
/// 是否显示包裹视图
/// 是否显示包裹列表视图
/// </summary>
public bool ShowPackageView = false;
@@ -18,6 +18,11 @@ namespace YooAsset.Editor
/// </summary>
public bool EnableAddressable = false;
/// <summary>
/// 资源包名唯一化
/// </summary>
public bool UniqueBundleName = false;
/// <summary>
/// 包裹列表
/// </summary>
@@ -76,37 +81,43 @@ namespace YooAsset.Editor
Debug.LogWarning($"Not found package : {packageName}");
return new List<string>();
}
/// <summary>
/// 获取包裹收集的资源文件
/// </summary>
public List<CollectAssetInfo> GetPackageAssets(EBuildMode buildMode, string packageName)
public CollectResult GetPackageAssets(EBuildMode buildMode, string packageName)
{
if (string.IsNullOrEmpty(packageName))
throw new Exception("Build Package name is null or mepty !");
throw new Exception("Build package name is null or mepty !");
foreach (var package in Packages)
{
if (package.PackageName == packageName)
{
return package.GetAllCollectAssets(buildMode, EnableAddressable);
CollectCommand command = new CollectCommand(buildMode, EnableAddressable);
CollectResult collectResult = new CollectResult(package.PackageName, EnableAddressable, UniqueBundleName);
collectResult.SetCollectAssets(package.GetAllCollectAssets(command));
return collectResult;
}
}
throw new Exception($"Not found collector pacakge : {packageName}");
}
/// <summary>
/// 获取所有包裹收集的资源文件
/// </summary>
public List<CollectAssetInfo> GetAllPackageAssets(EBuildMode buildMode)
public List<CollectResult> GetAllPackageAssets(EBuildMode buildMode)
{
List<CollectAssetInfo> result = new List<CollectAssetInfo>(1000);
List<CollectResult> collectResultList = new List<CollectResult>(1000);
foreach (var package in Packages)
{
var temper = package.GetAllCollectAssets(buildMode, EnableAddressable);
result.AddRange(temper);
CollectCommand command = new CollectCommand(buildMode, EnableAddressable);
CollectResult collectResult = new CollectResult(package.PackageName, EnableAddressable, UniqueBundleName);
collectResult.SetCollectAssets(package.GetAllCollectAssets(command));
collectResultList.Add(collectResult);
}
return result;
return collectResultList;
}
}
}

View File

@@ -347,14 +347,20 @@ namespace YooAsset.Editor
Setting.EnableAddressable = enableAddressable;
IsDirty = true;
}
public static void ModifyUniqueBundleName(bool uniqueBundleName)
{
Setting.UniqueBundleName = uniqueBundleName;
IsDirty = true;
}
// 资源包裹编辑相关
public static void CreatePackage(string packageName)
public static AssetBundleCollectorPackage CreatePackage(string packageName)
{
AssetBundleCollectorPackage package = new AssetBundleCollectorPackage();
package.PackageName = packageName;
Setting.Packages.Add(package);
IsDirty = true;
return package;
}
public static void RemovePackage(AssetBundleCollectorPackage package)
{
@@ -376,12 +382,13 @@ namespace YooAsset.Editor
}
// 资源分组编辑相关
public static void CreateGroup(AssetBundleCollectorPackage package, string groupName)
public static AssetBundleCollectorGroup CreateGroup(AssetBundleCollectorPackage package, string groupName)
{
AssetBundleCollectorGroup group = new AssetBundleCollectorGroup();
group.GroupName = groupName;
package.Groups.Add(group);
IsDirty = true;
return group;
}
public static void RemoveGroup(AssetBundleCollectorPackage package, AssetBundleCollectorGroup group)
{

View File

@@ -27,6 +27,7 @@ namespace YooAsset.Editor
private Toggle _showPackageToogle;
private Toggle _enableAddressableToogle;
private Toggle _uniqueBundleNameToogle;
private VisualElement _packageContainer;
private ListView _packageListView;
@@ -87,6 +88,12 @@ namespace YooAsset.Editor
AssetBundleCollectorSettingData.ModifyAddressable(evt.newValue);
RefreshWindow();
});
_uniqueBundleNameToogle = root.Q<Toggle>("UniqueBundleName");
_uniqueBundleNameToogle.RegisterValueChangedCallback(evt =>
{
AssetBundleCollectorSettingData.ModifyUniqueBundleName(evt.newValue);
RefreshWindow();
});
// 配置修复按钮
var fixBtn = root.Q<Button>("FixButton");
@@ -289,6 +296,7 @@ namespace YooAsset.Editor
private void FixBtn_clicked()
{
AssetBundleCollectorSettingData.FixFile();
RefreshWindow();
}
private void ExportBtn_clicked()
{
@@ -733,8 +741,8 @@ namespace YooAsset.Editor
try
{
bool enableAdressable = AssetBundleCollectorSettingData.Setting.EnableAddressable;
collectAssetInfos = collector.GetAllCollectAssets(EBuildMode.DryRunBuild, enableAdressable, group);
CollectCommand command = new CollectCommand(EBuildMode.DryRunBuild, _enableAddressableToogle.value);
collectAssetInfos = collector.GetAllCollectAssets(command, group);
}
catch (System.Exception e)
{

View File

@@ -8,6 +8,7 @@
<ui:VisualElement name="PublicContainer" style="height: 30px; background-color: rgb(67, 67, 67); flex-direction: row; border-left-width: 5px; border-right-width: 5px; border-top-width: 5px; border-bottom-width: 5px;">
<ui:Toggle label="Show Packages" name="ShowPackages" style="width: 196px; -unity-text-align: middle-left;" />
<ui:Toggle label="Enable Addressable" name="EnableAddressable" style="width: 196px; -unity-text-align: middle-left;" />
<ui:Toggle label="Unique Bundle Name" name="UniqueBundleName" style="width: 196px; -unity-text-align: middle-left;" />
</ui:VisualElement>
<ui:VisualElement name="ContentContainer" style="flex-grow: 1; flex-direction: row;">
<ui:VisualElement name="PackageContainer" style="width: 200px; flex-grow: 0; background-color: rgb(67, 67, 67); border-left-width: 5px; border-right-width: 5px; border-top-width: 5px; border-bottom-width: 5px;">

View File

@@ -50,5 +50,13 @@ namespace YooAsset.Editor
AssetTags = assetTags;
IsRawAsset = isRawAsset;
}
/// <summary>
/// 资源包名称追加包裹名
/// </summary>
public void BundleNameAppendPackageName(string packageName)
{
BundleName = $"{packageName.ToLower()}_{BundleName}";
}
}
}

View File

@@ -0,0 +1,22 @@

namespace YooAsset.Editor
{
public class CollectCommand
{
/// <summary>
/// 构建模式
/// </summary>
public EBuildMode BuildMode { private set; get; }
/// <summary>
/// 是否启用可寻址资源定位
/// </summary>
public bool EnableAddressable { private set; get; }
public CollectCommand(EBuildMode buildMode, bool enableAddressable)
{
BuildMode = buildMode;
EnableAddressable = enableAddressable;
}
}
}

View File

@@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: a8d6592eded144142afcf85c79cf1ce4
guid: b1741e85d76b28d41a4da3cd0e3e6f20
MonoImporter:
externalObjects: {}
serializedVersion: 2

View File

@@ -0,0 +1,49 @@
using System.Collections;
using System.Collections.Generic;
namespace YooAsset.Editor
{
public class CollectResult
{
/// <summary>
/// 包裹名称
/// </summary>
public string PackageName { private set; get; }
/// <summary>
/// 是否启用可寻址资源定位
/// </summary>
public bool EnableAddressable { private set; get; }
/// <summary>
/// 资源包名唯一化
/// </summary>
public bool UniqueBundleName { private set; get; }
/// <summary>
/// 收集的资源信息列表
/// </summary>
public List<CollectAssetInfo> CollectAssets { private set; get; }
public CollectResult(string packageName, bool enableAddressable, bool uniqueBundleName)
{
PackageName = packageName;
EnableAddressable = enableAddressable;
UniqueBundleName = uniqueBundleName;
}
public void SetCollectAssets(List<CollectAssetInfo> collectAssets)
{
CollectAssets = collectAssets;
if (UniqueBundleName)
{
foreach (var collectAsset in CollectAssets)
{
collectAsset.BundleNameAppendPackageName(PackageName);
}
}
}
}
}

View File

@@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: cfc81e18e5b5f6f4b821c7427b34d349
guid: dbbd465f929ee33408441b62d19c7d10
MonoImporter:
externalObjects: {}
serializedVersion: 2

View File

@@ -40,7 +40,7 @@ namespace YooAsset.Editor
_visualAsset = EditorHelper.LoadWindowUXML<ReporterSummaryViewer>();
if (_visualAsset == null)
return;
_root = _visualAsset.CloneTree();
_root.style.flexGrow = 1f;
@@ -56,7 +56,7 @@ namespace YooAsset.Editor
public void FillViewData(BuildReport buildReport)
{
_buildReport = buildReport;
_items.Clear();
_items.Add(new ItemWrapper("YooAsset版本", buildReport.Summary.YooVersion));
@@ -69,6 +69,7 @@ namespace YooAsset.Editor
_items.Add(new ItemWrapper("构建包裹", $"{buildReport.Summary.BuildPackage}"));
_items.Add(new ItemWrapper("启用可寻址资源定位", $"{buildReport.Summary.EnableAddressable}"));
_items.Add(new ItemWrapper("资源包名唯一化", $"{buildReport.Summary.UniqueBundleName}"));
_items.Add(new ItemWrapper("加密服务类名称", $"{buildReport.Summary.EncryptionServicesClassName}"));
_items.Add(new ItemWrapper(string.Empty, string.Empty));

View File

@@ -52,7 +52,7 @@ namespace YooAsset.Editor
throw new System.Exception("Shader variant file extension is invalid.");
// 注意先删除再保存否则ShaderVariantCollection内容将无法及时刷新
AssetDatabase.DeleteAsset(ShaderVariantCollectorSettingData.Setting.SavePath);
AssetDatabase.DeleteAsset(ShaderVariantCollectorSettingData.Setting.SavePath);
EditorTools.CreateFileDirectory(saveFilePath);
_saveFilePath = saveFilePath;
_completedCallback = completedCallback;
@@ -87,9 +87,14 @@ namespace YooAsset.Editor
List<string> allAssets = new List<string>(1000);
// 获取所有打包的资源
List<CollectAssetInfo> allCollectInfos = AssetBundleCollectorSettingData.Setting.GetAllPackageAssets(EBuildMode.DryRunBuild);
List<string> collectAssets = allCollectInfos.Select(t => t.AssetPath).ToList();
foreach (var assetPath in collectAssets)
List<CollectAssetInfo> allCollectAssetInfos = new List<CollectAssetInfo>();
List<CollectResult> collectResults = AssetBundleCollectorSettingData.Setting.GetAllPackageAssets(EBuildMode.DryRunBuild);
foreach (var collectResult in collectResults)
{
allCollectAssetInfos.AddRange(collectResult.CollectAssets);
}
List<string> allAssetPath = allCollectAssetInfos.Select(t => t.AssetPath).ToList();
foreach (var assetPath in allAssetPath)
{
string[] depends = AssetDatabase.GetDependencies(assetPath, true);
foreach (var depend in depends)
@@ -97,7 +102,7 @@ namespace YooAsset.Editor
if (allAssets.Contains(depend) == false)
allAssets.Add(depend);
}
EditorTools.DisplayProgressBar("获取所有打包资源", ++progressValue, collectAssets.Count);
EditorTools.DisplayProgressBar("获取所有打包资源", ++progressValue, allAssetPath.Count);
}
EditorTools.ClearProgressBar();

View File

@@ -142,6 +142,7 @@ namespace YooAsset
{
if (assetInfo.IsInvalid)
{
YooLogger.Error($"Failed to load scene. {assetInfo.Error}");
CompletedProvider completedProvider = new CompletedProvider(assetInfo);
completedProvider.SetCompleted(assetInfo.Error);
return completedProvider.CreateHandle<SceneOperationHandle>();
@@ -190,6 +191,7 @@ namespace YooAsset
{
if (assetInfo.IsInvalid)
{
YooLogger.Error($"Failed to load asset. {assetInfo.Error}");
CompletedProvider completedProvider = new CompletedProvider(assetInfo);
completedProvider.SetCompleted(assetInfo.Error);
return completedProvider.CreateHandle<AssetOperationHandle>();
@@ -216,6 +218,7 @@ namespace YooAsset
{
if (assetInfo.IsInvalid)
{
YooLogger.Error($"Failed to load sub assets. {assetInfo.Error}");
CompletedProvider completedProvider = new CompletedProvider(assetInfo);
completedProvider.SetCompleted(assetInfo.Error);
return completedProvider.CreateHandle<SubAssetsOperationHandle>();

View File

@@ -13,7 +13,6 @@ namespace YooAsset
private EOperationStatus _initializeStatus = EOperationStatus.None;
private EPlayMode _playMode;
private IBundleServices _bundleServices;
private ILocationServices _locationServices;
private AssetSystemImpl _assetSystemImpl;
private EditorSimulateModeImpl _editorSimulateModeImpl;
private OfflinePlayModeImpl _offlinePlayModeImpl;
@@ -33,7 +32,7 @@ namespace YooAsset
}
internal AssetsPackage()
private AssetsPackage()
{
}
internal AssetsPackage(string packageName)
@@ -62,7 +61,6 @@ namespace YooAsset
_initializeStatus = EOperationStatus.None;
_bundleServices = null;
_locationServices = null;
_editorSimulateModeImpl = null;
_offlinePlayModeImpl = null;
_hostPlayModeImpl = null;
@@ -72,8 +70,6 @@ namespace YooAsset
_assetSystemImpl.DestroyAll();
_assetSystemImpl = null;
}
YooLogger.Log("YooAssets destroy all !");
}
}
@@ -87,7 +83,6 @@ namespace YooAsset
// 初始化资源系统
InitializationOperation initializeOperation;
_locationServices = parameters.LocationServices;
_assetSystemImpl = new AssetSystemImpl();
if (_playMode == EPlayMode.EditorSimulateMode)
{
@@ -143,14 +138,11 @@ namespace YooAsset
throw new Exception($"Editor simulate mode only support unity editor.");
#endif
if (parameters.LocationServices == null)
throw new Exception($"{nameof(ILocationServices)} is null.");
if (parameters is EditorSimulateModeParameters)
{
var editorSimulateModeParameters = parameters as EditorSimulateModeParameters;
if (string.IsNullOrEmpty(editorSimulateModeParameters.SimulatePatchManifestPath))
throw new Exception($"${editorSimulateModeParameters.SimulatePatchManifestPath} is null or empty.");
throw new Exception($"{nameof(editorSimulateModeParameters.SimulatePatchManifestPath)} is null or empty.");
}
if (parameters is HostPlayModeParameters)
@@ -335,7 +327,10 @@ namespace YooAsset
DebugCheckInitialize();
AssetInfo assetInfo = ConvertLocationToAssetInfo(location, null);
if (assetInfo.IsInvalid)
{
YooLogger.Warning(assetInfo.Error);
return false;
}
BundleInfo bundleInfo = _bundleServices.GetBundleInfo(assetInfo);
if (bundleInfo.LoadMode == BundleInfo.ELoadMode.LoadFromRemote)
@@ -397,14 +392,14 @@ namespace YooAsset
}
/// <summary>
/// 获取资源路径
/// 检查资源定位地址是否有效
/// </summary>
/// <param name="location">资源的定位地址</param>
/// <returns>如果location地址无效则返回空字符串</returns>
public string GetAssetPath(string location)
public bool CheckLocationValid(string location)
{
DebugCheckInitialize();
return _locationServices.ConvertLocationToAssetPath(this, location);
string assetPath = _bundleServices.TryMappingToAssetPath(location);
return string.IsNullOrEmpty(assetPath) == false;
}
#endregion
@@ -429,8 +424,6 @@ namespace YooAsset
public RawFileOperation GetRawFileAsync(AssetInfo assetInfo, string copyPath = null)
{
DebugCheckInitialize();
if (assetInfo.IsInvalid)
YooLogger.Warning(assetInfo.Error);
return GetRawFileInternal(assetInfo, copyPath);
}
@@ -439,6 +432,7 @@ namespace YooAsset
{
if (assetInfo.IsInvalid)
{
YooLogger.Error($"Failed to get raw file. {assetInfo.Error}");
RawFileOperation operation = new CompletedRawFileOperation(assetInfo.Error, copyPath);
OperationSystem.StartOperation(operation);
return operation;
@@ -508,8 +502,6 @@ namespace YooAsset
public SceneOperationHandle LoadSceneAsync(AssetInfo assetInfo, LoadSceneMode sceneMode = LoadSceneMode.Single, bool activateOnLoad = true, int priority = 100)
{
DebugCheckInitialize();
if (assetInfo.IsInvalid)
YooLogger.Warning(assetInfo.Error);
var handle = _assetSystemImpl.LoadSceneAsync(assetInfo, sceneMode, activateOnLoad, priority);
return handle;
}
@@ -523,8 +515,6 @@ namespace YooAsset
public AssetOperationHandle LoadAssetSync(AssetInfo assetInfo)
{
DebugCheckInitialize();
if (assetInfo.IsInvalid)
YooLogger.Warning(assetInfo.Error);
return LoadAssetInternal(assetInfo, true);
}
@@ -560,8 +550,6 @@ namespace YooAsset
public AssetOperationHandle LoadAssetAsync(AssetInfo assetInfo)
{
DebugCheckInitialize();
if (assetInfo.IsInvalid)
YooLogger.Warning(assetInfo.Error);
return LoadAssetInternal(assetInfo, false);
}
@@ -593,14 +581,17 @@ namespace YooAsset
private AssetOperationHandle LoadAssetInternal(AssetInfo assetInfo, bool waitForAsyncComplete)
{
#if UNITY_EDITOR
BundleInfo bundleInfo = _bundleServices.GetBundleInfo(assetInfo);
if (bundleInfo.Bundle.IsRawFile)
if (assetInfo.IsInvalid == false)
{
string error = $"Cannot load raw file using LoadAsset method !";
YooLogger.Error(error);
CompletedProvider completedProvider = new CompletedProvider(assetInfo);
completedProvider.SetCompleted(error);
return completedProvider.CreateHandle<AssetOperationHandle>();
BundleInfo bundleInfo = _bundleServices.GetBundleInfo(assetInfo);
if (bundleInfo.Bundle.IsRawFile)
{
string error = $"Cannot load raw file using LoadAsset method !";
YooLogger.Error(error);
CompletedProvider completedProvider = new CompletedProvider(assetInfo);
completedProvider.SetCompleted(error);
return completedProvider.CreateHandle<AssetOperationHandle>();
}
}
#endif
@@ -619,8 +610,6 @@ namespace YooAsset
public SubAssetsOperationHandle LoadSubAssetsSync(AssetInfo assetInfo)
{
DebugCheckInitialize();
if (assetInfo.IsInvalid)
YooLogger.Warning(assetInfo.Error);
return LoadSubAssetsInternal(assetInfo, true);
}
@@ -656,8 +645,6 @@ namespace YooAsset
public SubAssetsOperationHandle LoadSubAssetsAsync(AssetInfo assetInfo)
{
DebugCheckInitialize();
if (assetInfo.IsInvalid)
YooLogger.Warning(assetInfo.Error);
return LoadSubAssetsInternal(assetInfo, false);
}
@@ -689,14 +676,17 @@ namespace YooAsset
private SubAssetsOperationHandle LoadSubAssetsInternal(AssetInfo assetInfo, bool waitForAsyncComplete)
{
#if UNITY_EDITOR
BundleInfo bundleInfo = _bundleServices.GetBundleInfo(assetInfo);
if (bundleInfo.Bundle.IsRawFile)
if (assetInfo.IsInvalid == false)
{
string error = $"Cannot load raw file using LoadSubAssets method !";
YooLogger.Error(error);
CompletedProvider completedProvider = new CompletedProvider(assetInfo);
completedProvider.SetCompleted(error);
return completedProvider.CreateHandle<SubAssetsOperationHandle>();
BundleInfo bundleInfo = _bundleServices.GetBundleInfo(assetInfo);
if (bundleInfo.Bundle.IsRawFile)
{
string error = $"Cannot load raw file using LoadSubAssets method !";
YooLogger.Error(error);
CompletedProvider completedProvider = new CompletedProvider(assetInfo);
completedProvider.SetCompleted(error);
return completedProvider.CreateHandle<SubAssetsOperationHandle>();
}
}
#endif
@@ -940,14 +930,6 @@ namespace YooAsset
#endregion
#region
/// <summary>
/// 资源定位地址转换为资源完整路径
/// </summary>
internal string MappingToAssetPath(string location)
{
return _bundleServices.MappingToAssetPath(location);
}
/// <summary>
/// 是否包含资源文件
/// </summary>
@@ -1014,7 +996,7 @@ namespace YooAsset
private AssetInfo ConvertLocationToAssetInfo(string location, System.Type assetType)
{
DebugCheckLocation(location);
string assetPath = _locationServices.ConvertLocationToAssetPath(this, location);
string assetPath = _bundleServices.MappingToAssetPath(location);
PatchAsset patchAsset = _bundleServices.TryGetPatchAsset(assetPath);
if (patchAsset != null)
{
@@ -1028,7 +1010,6 @@ namespace YooAsset
error = $"The location is null or empty !";
else
error = $"The location is invalid : {location}";
YooLogger.Error(error);
AssetInfo assetInfo = new AssetInfo(error);
return assetInfo;
}

View File

@@ -2,6 +2,7 @@
using System.IO;
using System.Collections;
using System.Collections.Generic;
using UnityEngine.Networking;
namespace YooAsset
{
@@ -15,11 +16,22 @@ namespace YooAsset
private static readonly Dictionary<string, DownloaderBase> _downloaderDic = new Dictionary<string, DownloaderBase>();
private static readonly List<string> _removeList = new List<string>(100);
/// <summary>
/// 启用断点续传的文件大小
/// 自定义的证书认证实例
/// </summary>
public static CertificateHandler CertificateHandlerInstance;
/// <summary>
/// 启用断点续传功能文件的最小字节数
/// </summary>
public static int BreakpointResumeFileSize { set; get; } = int.MaxValue;
/// <summary>
/// 下载失败后清理文件的HTTP错误码
/// </summary>
public static List<long> ClearFileResponseCodes { set; get; }
/// <summary>
/// 更新所有下载器
/// </summary>

View File

@@ -89,6 +89,12 @@ namespace YooAsset
_downloadHandle = handler;
#endif
if (DownloadSystem.CertificateHandlerInstance != null)
{
_webRequest.certificateHandler = DownloadSystem.CertificateHandlerInstance;
_webRequest.disposeCertificateHandlerOnDispose = false;
}
_webRequest.downloadHandler = handler;
_webRequest.disposeDownloadHandlerOnDispose = true;
if (fileLength > 0)
@@ -156,13 +162,26 @@ namespace YooAsset
// 如果下载失败
if (hasError)
{
// 注意:非断点续传下载失败后删除文件
// 注意:非断点续传下载失败后删除文件
if (_breakResume == false)
{
string cacheFilePath = _bundleInfo.Bundle.CachedFilePath;
if (File.Exists(cacheFilePath))
File.Delete(cacheFilePath);
}
else
{
// 注意:下载断点续传文件发生特殊错误码之后删除文件
if (DownloadSystem.ClearFileResponseCodes != null)
{
if (DownloadSystem.ClearFileResponseCodes.Contains(_webRequest.responseCode))
{
string cacheFilePath = _bundleInfo.Bundle.CachedFilePath;
if (File.Exists(cacheFilePath))
File.Delete(cacheFilePath);
}
}
}
// 失败后重新尝试
if (_failedTryAgain > 0)

View File

@@ -33,11 +33,6 @@ namespace YooAsset
/// </summary>
public bool LocationToLower = false;
/// <summary>
/// 资源定位服务接口
/// </summary>
public ILocationServices LocationServices = null;
/// <summary>
/// 文件解密服务接口
/// </summary>

View File

@@ -147,6 +147,23 @@ namespace YooAsset
}
}
/// <summary>
/// 尝试映射为资源路径
/// </summary>
public string TryMappingToAssetPath(string location)
{
if (string.IsNullOrEmpty(location))
return string.Empty;
if (_locationToLower)
location = location.ToLower();
if (AssetPathMapping.TryGetValue(location, out string assetPath))
return assetPath;
else
return string.Empty;
}
/// <summary>
/// 获取主资源包
/// 注意:传入的资源路径一定合法有效!

View File

@@ -66,6 +66,10 @@ namespace YooAsset
{
return _simulatePatchManifest.MappingToAssetPath(location);
}
string IBundleServices.TryMappingToAssetPath(string location)
{
return _simulatePatchManifest.TryMappingToAssetPath(location);
}
string IBundleServices.GetPackageName()
{
return _simulatePatchManifest.PackageName;

View File

@@ -392,6 +392,10 @@ namespace YooAsset
{
return LocalPatchManifest.MappingToAssetPath(location);
}
string IBundleServices.TryMappingToAssetPath(string location)
{
return LocalPatchManifest.TryMappingToAssetPath(location);
}
string IBundleServices.GetPackageName()
{
return LocalPatchManifest.PackageName;

View File

@@ -117,6 +117,10 @@ namespace YooAsset
{
return _appPatchManifest.MappingToAssetPath(location);
}
string IBundleServices.TryMappingToAssetPath(string location)
{
return _appPatchManifest.TryMappingToAssetPath(location);
}
string IBundleServices.GetPackageName()
{
return _appPatchManifest.PackageName;

View File

@@ -28,6 +28,11 @@ namespace YooAsset
/// </summary>
string MappingToAssetPath(string location);
/// <summary>
/// 尝试映射为资源路径
/// </summary>
string TryMappingToAssetPath(string location);
/// <summary>
/// 获取所属的包裹名
/// </summary>

View File

@@ -1,11 +0,0 @@

namespace YooAsset
{
public interface ILocationServices
{
/// <summary>
/// 定位地址转换为资源路径
/// </summary>
string ConvertLocationToAssetPath(AssetsPackage package, string location);
}
}

View File

@@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: 6e400ee1e8b3556479bfa493ff7fe778
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,11 +0,0 @@

namespace YooAsset
{
public class AddressLocationServices : ILocationServices
{
string ILocationServices.ConvertLocationToAssetPath(AssetsPackage package, string location)
{
return package.MappingToAssetPath(location);
}
}
}

View File

@@ -1,27 +0,0 @@

namespace YooAsset
{
public class DefaultLocationServices : ILocationServices
{
private readonly string _resourceRoot;
public DefaultLocationServices(string resourceRoot)
{
if (string.IsNullOrEmpty(resourceRoot) == false)
_resourceRoot = PathHelper.GetRegularPath(resourceRoot);
}
string ILocationServices.ConvertLocationToAssetPath(AssetsPackage package, string location)
{
if (string.IsNullOrEmpty(_resourceRoot))
{
return package.MappingToAssetPath(location);
}
else
{
string tempLocation = $"{_resourceRoot}/{location}";
return package.MappingToAssetPath(tempLocation);
}
}
}
}

View File

@@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 8d996937ba73c9b4bb942b8ba6f43398
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -147,7 +147,7 @@ namespace YooAsset
#region
/// <summary>
/// 启用下载系统断点续传功能文件大小
/// 设置下载系统参数,启用断点续传功能文件的最小字节数
/// </summary>
public static void SetDownloadSystemBreakpointResumeFileSize(int fileBytes)
{
@@ -155,7 +155,23 @@ namespace YooAsset
}
/// <summary>
/// 设置异步系统的每帧允许运行的最大时间切片(单位:毫秒)
/// 设置下载系统参数下载失败后清理文件的HTTP错误码
/// </summary>
public static void SetDownloadSystemClearFileResponseCode(List<long> codes)
{
DownloadSystem.ClearFileResponseCodes = codes;
}
/// <summary>
/// 设置下载系统参数,自定义的证书认证实例
/// </summary>
public static void SetDownloadSystemCertificateHandler(UnityEngine.Networking.CertificateHandler instance)
{
DownloadSystem.CertificateHandlerInstance = instance;
}
/// <summary>
/// 设置异步系统参数,每帧执行消耗的最大时间切片(单位:毫秒)
/// </summary>
public static void SetOperationSystemMaxTimeSlice(long milliseconds)
{
@@ -168,7 +184,7 @@ namespace YooAsset
}
/// <summary>
/// 设置缓存系统已经缓存文件的校验等级
/// 设置缓存系统参数,已经缓存文件的校验等级
/// </summary>
public static void SetCacheSystemCachedFileVerifyLevel(EVerifyLevel verifyLevel)
{

View File

@@ -70,14 +70,13 @@ namespace YooAsset
}
/// <summary>
/// 获取资源路径
/// 检查资源定位地址是否有效
/// </summary>
/// <param name="location">资源的定位地址</param>
/// <returns>如果location地址无效则返回空字符串</returns>
public static string GetAssetPath(string location)
public static bool CheckLocationValid(string location)
{
DebugCheckDefaultPackageValid();
return _defaultPackage.GetAssetPath(location);
return _defaultPackage.CheckLocationValid(location);
}
#endregion

View File

@@ -53,7 +53,6 @@ public class BootScene : MonoBehaviour
if (PlayMode == EPlayMode.EditorSimulateMode)
{
var createParameters = new EditorSimulateModeParameters();
createParameters.LocationServices = new AddressLocationServices();
createParameters.SimulatePatchManifestPath = EditorSimulateModeHelper.SimulateBuild("DefaultPackage");
yield return defaultPackage.InitializeAsync(createParameters);
}
@@ -62,7 +61,6 @@ public class BootScene : MonoBehaviour
if (PlayMode == EPlayMode.OfflinePlayMode)
{
var createParameters = new OfflinePlayModeParameters();
createParameters.LocationServices = new AddressLocationServices();
yield return defaultPackage.InitializeAsync(createParameters);
}
@@ -70,7 +68,6 @@ public class BootScene : MonoBehaviour
if (PlayMode == EPlayMode.HostPlayMode)
{
var createParameters = new HostPlayModeParameters();
createParameters.LocationServices = new AddressLocationServices();
createParameters.QueryServices = new QueryStreamingAssetsFileServices();
createParameters.DefaultHostServer = GetHostServerURL();
createParameters.FallbackHostServer = GetHostServerURL();
@@ -111,7 +108,8 @@ public class BootScene : MonoBehaviour
{
public bool QueryStreamingAssets(string fileName)
{
return BetterStreamingAssets.FileExists($"{YooAssets.GetStreamingAssetBuildinFolderName()}/{fileName}");
string buildinFolderName = YooAssets.GetStreamingAssetBuildinFolderName();
return BetterStreamingAssets.FileExists($"{buildinFolderName}/{fileName}");
}
}
}

View File

@@ -1,25 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<root Version="2.0">
<Common AutoAddressable="True" ShowPackageView="False" />
<root Version="2.1">
<Common AutoAddressable="True" UniqueBundleName="False" ShowPackageView="False" />
<Package PackageName="DefaultPackage" PackageDesc="">
<Group GroupName="Level" GroupDesc="关卡资源" AssetTags="level">
<Collector CollectPath="Assets/YooAsset/Samples/Basic Sample/GameRes/Entity/Level1" CollectGUID="724066efe61192e43a0d7e59166b36a4" CollectType="MainAssetCollector" AddressRule="AddressByFileName" PackRule="PackSeparately" FilterRule="CollectPrefab" AssetTags="level1" />
<Collector CollectPath="Assets/YooAsset/Samples/Basic Sample/GameRes/Entity/Level2" CollectGUID="8045c1986f0ae964f8b1ea29e3522388" CollectType="MainAssetCollector" AddressRule="AddressByFileName" PackRule="PackSeparately" FilterRule="CollectPrefab" AssetTags="level2" />
<Collector CollectPath="Assets/Samples/Basic Sample/GameRes/Entity/Level1" CollectGUID="724066efe61192e43a0d7e59166b36a4" CollectType="MainAssetCollector" AddressRule="AddressByFileName" PackRule="PackSeparately" FilterRule="CollectPrefab" AssetTags="level1" />
<Collector CollectPath="Assets/Samples/Basic Sample/GameRes/Entity/Level2" CollectGUID="8045c1986f0ae964f8b1ea29e3522388" CollectType="MainAssetCollector" AddressRule="AddressByFileName" PackRule="PackSeparately" FilterRule="CollectPrefab" AssetTags="level2" />
</Group>
<Group GroupName="Buildin" GroupDesc="首包资源" AssetTags="buildin">
<Collector CollectPath="Assets/YooAsset/Samples/Basic Sample/GameRes/Scene" CollectGUID="f75e7d64104fb1a48b849b72b84ade4c" CollectType="MainAssetCollector" AddressRule="AddressByFileName" PackRule="PackSeparately" FilterRule="CollectScene" AssetTags="" />
<Collector CollectPath="Assets/YooAsset/Samples/Basic Sample/GameRes/Config" CollectGUID="44774abdee2b91b45b42f9dadf8c17a4" CollectType="MainAssetCollector" AddressRule="AddressByFileName" PackRule="PackRawFile" FilterRule="CollectAll" AssetTags="" />
<Collector CollectPath="Assets/YooAsset/Samples/Basic Sample/GameRes/Music" CollectGUID="e05b02ee4d90ae84a99871ce75288ea2" CollectType="MainAssetCollector" AddressRule="AddressByFileName" PackRule="PackDirectory" FilterRule="CollectAll" AssetTags="" />
<Collector CollectPath="Assets/Samples/Basic Sample/GameRes/Scene" CollectGUID="f75e7d64104fb1a48b849b72b84ade4c" CollectType="MainAssetCollector" AddressRule="AddressByFileName" PackRule="PackSeparately" FilterRule="CollectScene" AssetTags="" />
<Collector CollectPath="Assets/Samples/Basic Sample/GameRes/Config" CollectGUID="44774abdee2b91b45b42f9dadf8c17a4" CollectType="MainAssetCollector" AddressRule="AddressByFileName" PackRule="PackRawFile" FilterRule="CollectAll" AssetTags="" />
<Collector CollectPath="Assets/Samples/Basic Sample/GameRes/Music" CollectGUID="e05b02ee4d90ae84a99871ce75288ea2" CollectType="MainAssetCollector" AddressRule="AddressByFileName" PackRule="PackDirectory" FilterRule="CollectAll" AssetTags="" />
</Group>
<Group GroupName="Panel" GroupDesc="面板资源" AssetTags="panel">
<Collector CollectPath="Assets/YooAsset/Samples/Basic Sample/GameRes/Texture" CollectGUID="69b046f60ca75f647b2963e0113fd779" CollectType="MainAssetCollector" AddressRule="AddressByFileName" PackRule="PackCollector" FilterRule="CollectAll" AssetTags="" />
<Collector CollectPath="Assets/YooAsset/Samples/Basic Sample/GameRes/TpAtlas" CollectGUID="06e38aac2570d2b4a97c6a90223e5344" CollectType="MainAssetCollector" AddressRule="AddressByFileName" PackRule="PackDirectory" FilterRule="CollectAll" AssetTags="" />
<Collector CollectPath="Assets/YooAsset/Samples/Basic Sample/GameRes/UIPanel" CollectGUID="926d3203fcefdb947881a7491496e039" CollectType="MainAssetCollector" AddressRule="AddressByFileName" PackRule="PackDirectory" FilterRule="CollectAll" AssetTags="" />
<Collector CollectPath="Assets/YooAsset/Samples/Basic Sample/GameRes/UISprite" CollectGUID="29f27e4abf667c04b88a3996d8cdadfc" CollectType="MainAssetCollector" AddressRule="AddressByFileName" PackRule="PackDirectory" FilterRule="CollectAll" AssetTags="" />
<Collector CollectPath="Assets/Samples/Basic Sample/GameRes/Texture" CollectGUID="69b046f60ca75f647b2963e0113fd779" CollectType="MainAssetCollector" AddressRule="AddressByFileName" PackRule="PackCollector" FilterRule="CollectAll" AssetTags="" />
<Collector CollectPath="Assets/Samples/Basic Sample/GameRes/TpAtlas" CollectGUID="06e38aac2570d2b4a97c6a90223e5344" CollectType="MainAssetCollector" AddressRule="AddressByFileName" PackRule="PackDirectory" FilterRule="CollectAll" AssetTags="" />
<Collector CollectPath="Assets/Samples/Basic Sample/GameRes/UIPanel" CollectGUID="926d3203fcefdb947881a7491496e039" CollectType="MainAssetCollector" AddressRule="AddressByFileName" PackRule="PackDirectory" FilterRule="CollectAll" AssetTags="" />
<Collector CollectPath="Assets/Samples/Basic Sample/GameRes/UISprite" CollectGUID="29f27e4abf667c04b88a3996d8cdadfc" CollectType="MainAssetCollector" AddressRule="AddressByFileName" PackRule="PackDirectory" FilterRule="CollectAll" AssetTags="" />
</Group>
<Group GroupName="Art" GroupDesc="美术资源" AssetTags="">
<Collector CollectPath="Assets/YooAsset/Samples/Basic Sample/GameArt/ShaderVariants" CollectGUID="00781758c26692e40a9634ddeac838be" CollectType="StaticAssetCollector" AddressRule="AddressByFileName" PackRule="PackShaderVariants" FilterRule="CollectAll" AssetTags="" />
<Collector CollectPath="Assets/YooAsset/Samples/Basic Sample/GameArt/UIFont" CollectGUID="464727a15e4a7dc4d895346374432399" CollectType="DependAssetCollector" AddressRule="AddressByFileName" PackRule="PackDirectory" FilterRule="CollectAll" AssetTags="" />
<Collector CollectPath="Assets/Samples/Basic Sample/GameArt/ShaderVariants" CollectGUID="00781758c26692e40a9634ddeac838be" CollectType="StaticAssetCollector" AddressRule="AddressByFileName" PackRule="PackShaderVariants" FilterRule="CollectAll" AssetTags="" />
<Collector CollectPath="Assets/Samples/Basic Sample/GameArt/UIFont" CollectGUID="464727a15e4a7dc4d895346374432399" CollectType="DependAssetCollector" AddressRule="AddressByFileName" PackRule="PackDirectory" FilterRule="CollectAll" AssetTags="" />
</Group>
</Package>
</root>

View File

@@ -14,6 +14,7 @@ MonoBehaviour:
m_EditorClassIdentifier:
ShowPackageView: 0
EnableAddressable: 1
UniqueBundleName: 0
Packages:
- PackageName: DefaultPackage
PackageDesc:

View File

@@ -1,7 +1,7 @@
{
"name": "com.tuyoogame.yooasset",
"displayName": "YooAsset",
"version": "1.3.1",
"version": "1.3.2",
"unity": "2019.4",
"description": "unity3d resources management system.",
"author": {

View File

@@ -52,6 +52,20 @@
(4) BundleName_HashName_Extension资源包名+哈希值+后缀名
- **Copy Buildin File Option**
首包资源文件的拷贝方式
(1) None不拷贝任何文件
(2) ClearAndCopyAll先清空已有文件然后拷贝所有文件
(3) ClearAndCopyByTags先清空已有文件然后按照资源标签拷贝文件
(4) OnlyCopyAll不清空已有文件直接拷贝所有文件
(5) OnlyCopyByTags不清空已有文件直接按照资源标签拷贝文件
- **构建**
点击构建按钮会开始构建流程,构建流程分为多个节点顺序执行,如果某个节点发生错误,会导致构建失败。错误信息可以在控制台查看。
@@ -121,11 +135,12 @@ private static void BuildInternal(BuildTarget buildTarget)
buildParameters.BuildPipeline = EBuildPipeline.BuiltinBuildPipeline;
buildParameters.BuildMode = EBuildMode.ForceRebuild;
buildParameters.BuildPackage = "DefaultPackage";
buildParameters.HumanReadableVersion = "v1.0";
buildParameters.VerifyBuildingResult = true;
buildParameters.EnableAddressable = true;
buildParameters.EncryptionServices = new GameEncryption();
buildParameters.CompressOption = ECompressOption.LZ4;
buildParameters.OutputNameStyle = EOutputNameStyle.HashName_Extension;
buildParameters.CopyBuildinFileOption = ECopyBuildinFileOption.None;
// 执行构建
AssetBundleBuilder builder = new AssetBundleBuilder();

View File

@@ -10,9 +10,17 @@
#### 公共设置
- Show Packages
是否展示资源包列表视图。
- Enable Addressable
启用可寻址资源定位系统。
- Unique Bundle Name
资源包名追加PackageName作为前缀。
#### 资源分组

View File

@@ -3,7 +3,14 @@
初始化资源系统
```c#
// 初始化资源系统
YooAssets.Initialize();
// 创建默认的资源包
var defaultPackage = YooAssets.CreateAssetsPackage("DefaultPackage");
// 设置该资源包为默认的资源包可以使用YooAssets相关加载接口加载该资源包内容。
YooAssets.SetDefaultAssetsPackage(defaultPackage);
```
资源系统的运行模式支持三种:编辑器模拟模式,单机运行模式,联机运行模式。
@@ -17,10 +24,10 @@ YooAssets.Initialize();
````c#
private IEnumerator InitializeYooAsset()
{
var initParameters = new YooAssets.EditorSimulateModeParameters();
var initParameters = new EditorSimulateModeParameters();
initParameters.LocationServices = new DefaultLocationServices("Assets/GameRes");
initParameters.SimulatePatchManifestPath = EditorSimulateModeHelper.SimulateBuild("DefaultPackage", false);
yield return YooAssets.InitializeAsync(initParameters);
initParameters.SimulatePatchManifestPath = EditorSimulateModeHelper.SimulateBuild("DefaultPackage");
yield return defaultPackage.InitializeAsync(initParameters);
}
````
@@ -33,9 +40,9 @@ private IEnumerator InitializeYooAsset()
````c#
private IEnumerator InitializeYooAsset()
{
var initParameters = new YooAssets.OfflinePlayModeParameters();
var initParameters = new OfflinePlayModeParameters();
initParameters.LocationServices = new DefaultLocationServices("Assets/GameRes");
yield return YooAssets.InitializeAsync(initParameters);
yield return defaultPackage.InitializeAsync(initParameters);
}
````
@@ -55,22 +62,22 @@ private IEnumerator InitializeYooAsset()
- DecryptionServices : 如果资源包在构建的时候有加密需要提供实现IDecryptionServices接口的实例类。
- QueryServices内置资源查询服务接口。
- DefaultHostServer : 默认的资源服务器IP地址。
- FallbackHostServer : 备用的资源服务器IP地址。
- VerifyLevel : 下载文件校验等级
````c#
private IEnumerator InitializeYooAsset()
{
var initParameters = new YooAssets.HostPlayModeParameters();
var initParameters = new HostPlayModeParameters();
initParameters.LocationServices = new DefaultLocationServices("Assets/GameRes");
initParameters.DecryptionServices = new BundleDecryptionServices();
initParameters.QueryServices = new QueryStreamingAssetsServices();
initParameters.DefaultHostServer = "http://127.0.0.1/CDN1/Android/v1.0";
initParameters.FallbackHostServer = "http://127.0.0.1/CDN2/Android/v1.0";
yield return YooAssets.InitializeAsync(initParameters);
yield return defaultPackage.InitializeAsync(initParameters);
}
// 文件解密服务类
@@ -88,7 +95,8 @@ private class QueryStreamingAssetsServices : IQueryServices
public bool QueryStreamingAssets(string fileName)
{
// 注意使用了BetterStreamingAssets插件
return BetterStreamingAssets.FileExists($"YooAssets/{fileName}");
string buildinFolderName = YooAssets.GetStreamingAssetBuildinFolderName();
return BetterStreamingAssets.FileExists($"{buildinFolderName}/{fileName}");
}
}
````

View File

@@ -9,7 +9,8 @@
````c#
private IEnumerator UpdateStaticVersion()
{
UpdateStaticVersionOperation operation = YooAssets.UpdateStaticVersionAsync();
var package = YooAssets.GetAssetsPackage("DefaultPackage");
UpdateStaticVersionOperation operation = package.UpdateStaticVersionAsync();
yield return operation;
if (operation.Status == EOperationStatus.Succeed)
@@ -33,7 +34,8 @@ private IEnumerator UpdateStaticVersion()
````c#
private IEnumerator UpdatePatchManifest()
{
UpdateManifestOperation operation = YooAssets.UpdateManifestAsync(packageCRC);
var package = YooAssets.GetAssetsPackage("DefaultPackage");
UpdateManifestOperation operation = package.UpdateManifestAsync(packageCRC);
yield return operation;
if (operation.Status == EOperationStatus.Succeed)
@@ -56,15 +58,15 @@ private IEnumerator UpdatePatchManifest()
补丁包下载接口:
- YooAssets.CreatePatchDownloader(int downloadingMaxNumber, int failedTryAgain)
- YooAssets.CreatePatchDownloader(int downloadingMaxNumber, int failedTryAgain, int timeout)
用于下载更新当前资源版本所有的资源包文件。
- YooAssets.CreatePatchDownloader(string[] tags, int downloadingMaxNumber, int failedTryAgain)
- YooAssets.CreatePatchDownloader(string[] tags, int downloadingMaxNumber, int failedTryAgain, int timeout)
用于下载更新资源标签指定的资源包文件。
- YooAssets.CreateBundleDownloader(string[] locations, int downloadingMaxNumber, int failedTryAgain)
- YooAssets.CreateBundleDownloader(string[] locations, int downloadingMaxNumber, int failedTryAgain, int timeout)
用于下载更新指定的资源列表依赖的资源包文件。
@@ -73,7 +75,8 @@ IEnumerator Download()
{
int downloadingMaxNum = 10;
int failedTryAgain = 3;
DownloaderOperation downloader = YooAssets.CreatePatchDownloader(downloadingMaxNum, failedTryAgain);
int timeout = 60;
var downloader = YooAssets.CreatePatchDownloader(downloadingMaxNum, failedTryAgain, timeout);
//没有需要下载的资源
if (downloader.TotalDownloadCount == 0)
@@ -114,7 +117,8 @@ IEnumerator Download()
````c#
private IEnumerator UpdateStaticVersion()
{
UpdateStaticVersionOperation operation = YooAssets.UpdateStaticVersionAsync(10);
var package = YooAssets.GetAssetsPackage("DefaultPackage");
UpdateStaticVersionOperation operation = package.UpdateStaticVersionAsync(10);
yield return operation;
if (operation.Status == EOperationStatus.Succeed)
{
@@ -135,7 +139,7 @@ private IEnumerator UpdateStaticVersion()
}
// 在弱联网情况下更新补丁清单
UpdateManifestOperation operation2 = YooAssets.WeaklyUpdateManifestAsync(packageCRC);
UpdateManifestOperation operation2 = package.WeaklyUpdateManifestAsync(packageCRC);
yield return operation2;
if (operation2.Status == EOperationStatus.Succeed)
{

View File

@@ -18,9 +18,9 @@
```c#
// 以工程内的音频文件为例:"Assets/GameRes/Audio/bgMusic.mp3"
// 设定资源路径的根目录为:"Assets/GameRes",后续加载的资源定位地址填写相对路径:"Audio/bgMusic"
var createParameters = new YooAssets.EditorSimulateModeParameters();
var createParameters = new EditorSimulateModeParameters();
createParameters.LocationServices = new DefaultLocationServices("Assets/GameRes");
yield return YooAssets.InitializeAsync(createParameters);
yield return defaultPackage.InitializeAsync(createParameters);
......
YooAssets.LoadAssetAsync<AudioClip>("Audio/bgMusic");
```
@@ -31,9 +31,9 @@ YooAssets.LoadAssetAsync<AudioClip>("Audio/bgMusic");
// 以工程内的音频文件为例:"Assets/GameRes/Audio/bgMusic.mp3"
// 需要在资源配置界面启用可寻址功能Enable Addressable
// 配置界面的可寻址规则为AddressByFileName那么资源定位地址填写文件名称"bgMusic"
var createParameters = new YooAssets.EditorSimulateModeParameters();
var createParameters = new EditorSimulateModeParameters();
createParameters.LocationServices = new AddressLocationServices();
yield return YooAssets.InitializeAsync(createParameters);
yield return defaultPackage.InitializeAsync(createParameters);
......
YooAssets.LoadAssetAsync<AudioClip>("bgMusic");
````
@@ -104,7 +104,8 @@ IEnumerator Start()
````c#
private void UnloadAssets()
{
YooAssets.UnloadUnusedAssets();
var package = YooAssets.GetAssetsPackage("DefaultPackage");
package.UnloadUnusedAssets();
}
````

View File

@@ -65,7 +65,7 @@ go.transform.localScale = Vector3.one;
在运行游戏之前,请保证资源包可以构建成功!
```c#
public static YooAssetPackage AssetPackage;
public static AssetPackage DefaultPackage;
IEnumerator Start()
{
@@ -73,24 +73,24 @@ IEnumerator Start()
YooAssets.Initialize();
// 创建资源包实例
AssetPackage = YooAssets.CreateAssetPackage("DefaultPackage");
DefaultPackage = YooAssets.CreateAssetPackage("DefaultPackage");
// 初始化资源包
......
yield return AssetPackage.InitializeAsync(createParameters);
yield return DefaultPackage.InitializeAsync(createParameters);
// 更新资源包版本
......
var operation = AssetPackage.UpdateManifestAsync(packageCRC);
var operation = DefaultPackage.UpdateManifestAsync(packageCRC);
yield return operation;
// 下载更新文件
var downloader = AssetPackage.CreatePatchDownloader(downloadingMaxNum, failedTryAgain);
var downloader = DefaultPackage.CreatePatchDownloader(downloadingMaxNum, failedTryAgain);
downloader.BeginDownload();
yield return downloader;
// 加载资源对象
var assetHandle = AssetPackage.LoadAssetAsync("Assets/GameRes/npc.prefab");
var assetHandle = DefaultPackage.LoadAssetAsync("Assets/GameRes/npc.prefab");
yield return assetHandle;
......
}

View File

@@ -17,6 +17,33 @@ windows平台添加命令: **-force-gles**
YooAsset依赖于ScriptBuildPipelineSBP在PackageManager里找到SBP插件安装就可以了。
#### 问题使用FileZilla等FTP上传工具后文件下载总是验证失败
把传输类型修改为二进制就可以了。
#### 问题ClearCacheWhenDirty参数没了吗
不是很必须的一个功能,已经移除了。可以使用以下方法代替:
````c#
// 参考DEMO的代码
internal class FsmClearCache : IFsmNode
{
void IFsmNode.OnEnter()
{
Debug.Log("清理未使用的缓存文件!");
var operation = YooAsset.YooAssets.ClearUnusedCacheFiles();
operation.Completed += Operation_Completed;
}
private void Operation_Completed(YooAsset.AsyncOperationBase obj)
{
Debug.Log("开始游戏!");
......
}
}
````
#### 问题YooAsset支持Unity2018吗
YooAsset分俩部分编辑器代码和运行时代码。因为工具界面是使用UIElements编写的所以在Unity2019以前的版本是使用不了界面化工具。但是这并没有影响我们使用YooAsset以下提供一种解决方案。

Binary file not shown.

Before

Width:  |  Height:  |  Size: 38 KiB

After

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 129 KiB

After

Width:  |  Height:  |  Size: 88 KiB