mirror of
https://github.com/tuyoogame/YooAsset.git
synced 2026-05-20 23:30:08 +00:00
Compare commits
19 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
92e7ec9682 | ||
|
|
32b7ff1b36 | ||
|
|
5a68ef558f | ||
|
|
18d48ae963 | ||
|
|
d61c723933 | ||
|
|
bb64ff7278 | ||
|
|
d7760cd34d | ||
|
|
f9ecad1cf0 | ||
|
|
a6de89ab74 | ||
|
|
e663dcf83b | ||
|
|
88e8e5cd54 | ||
|
|
9b43d36793 | ||
|
|
794314a8e1 | ||
|
|
0a1c40cee5 | ||
|
|
958cdd25a5 | ||
|
|
2fb77c1bf8 | ||
|
|
3aa46664f7 | ||
|
|
8389ce5793 | ||
|
|
5199430766 |
@@ -2,6 +2,61 @@
|
|||||||
|
|
||||||
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.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
|
## [1.3.1] - 2022-10-18
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|||||||
@@ -257,7 +257,6 @@ namespace YooAsset.Editor
|
|||||||
buildParameters.BuildMode = AssetBundleBuilderSettingData.Setting.BuildMode;
|
buildParameters.BuildMode = AssetBundleBuilderSettingData.Setting.BuildMode;
|
||||||
buildParameters.BuildPackage = AssetBundleBuilderSettingData.Setting.BuildPackage;
|
buildParameters.BuildPackage = AssetBundleBuilderSettingData.Setting.BuildPackage;
|
||||||
buildParameters.VerifyBuildingResult = true;
|
buildParameters.VerifyBuildingResult = true;
|
||||||
buildParameters.EnableAddressable = AssetBundleCollectorSettingData.Setting.EnableAddressable;
|
|
||||||
buildParameters.EncryptionServices = CreateEncryptionServicesInstance();
|
buildParameters.EncryptionServices = CreateEncryptionServicesInstance();
|
||||||
buildParameters.CompressOption = AssetBundleBuilderSettingData.Setting.CompressOption;
|
buildParameters.CompressOption = AssetBundleBuilderSettingData.Setting.CompressOption;
|
||||||
buildParameters.OutputNameStyle = AssetBundleBuilderSettingData.Setting.OutputNameStyle;
|
buildParameters.OutputNameStyle = AssetBundleBuilderSettingData.Setting.OutputNameStyle;
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ namespace YooAsset.Editor
|
|||||||
buildParameters.BuildTarget = EditorUserBuildSettings.activeBuildTarget;
|
buildParameters.BuildTarget = EditorUserBuildSettings.activeBuildTarget;
|
||||||
buildParameters.BuildMode = EBuildMode.SimulateBuild;
|
buildParameters.BuildMode = EBuildMode.SimulateBuild;
|
||||||
buildParameters.BuildPackage = packageName;
|
buildParameters.BuildPackage = packageName;
|
||||||
buildParameters.EnableAddressable = AssetBundleCollectorSettingData.Setting.EnableAddressable;
|
|
||||||
|
|
||||||
AssetBundleBuilder builder = new AssetBundleBuilder();
|
AssetBundleBuilder builder = new AssetBundleBuilder();
|
||||||
var buildResult = builder.Run(buildParameters);
|
var buildResult = builder.Run(buildParameters);
|
||||||
|
|||||||
@@ -166,7 +166,7 @@ namespace YooAsset.Editor
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 计算主资源或共享资源的完整包名
|
/// 计算主资源或共享资源的完整包名
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void CalculateFullBundleName()
|
public void CalculateFullBundleName(bool uniqueBundleName, string packageName)
|
||||||
{
|
{
|
||||||
if (CollectorType == ECollectorType.None)
|
if (CollectorType == ECollectorType.None)
|
||||||
{
|
{
|
||||||
@@ -177,15 +177,22 @@ namespace YooAsset.Editor
|
|||||||
{
|
{
|
||||||
string shareBundleName = YooAssetSettingsData.GetUnityShadersBundleFullName();
|
string shareBundleName = YooAssetSettingsData.GetUnityShadersBundleFullName();
|
||||||
_shareBundleName = EditorTools.GetRegularPath(shareBundleName).ToLower();
|
_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;
|
if (string.IsNullOrEmpty(_shareBundleName) == false)
|
||||||
var bundleName = packRule.GetBundleName(new PackRuleData(AssetPath));
|
_shareBundleName = $"{packageName.ToLower()}_{_shareBundleName}";
|
||||||
var shareBundleName = $"share_{bundleName}.{YooAssetSettingsData.Setting.AssetBundleFileVariant}";
|
|
||||||
_shareBundleName = EditorTools.GetRegularPath(shareBundleName).ToLower();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -14,6 +14,16 @@ namespace YooAsset.Editor
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public int AssetFileCount;
|
public int AssetFileCount;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 是否启用可寻址资源定位
|
||||||
|
/// </summary>
|
||||||
|
public bool EnableAddressable;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 资源包名唯一化
|
||||||
|
/// </summary>
|
||||||
|
public bool UniqueBundleName;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 资源包列表
|
/// 资源包列表
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -19,7 +19,8 @@ namespace YooAsset.Editor
|
|||||||
AssetBundleCollectorSettingData.Setting.CheckConfigError();
|
AssetBundleCollectorSettingData.Setting.CheckConfigError();
|
||||||
|
|
||||||
// 2. 获取所有收集器收集的资源
|
// 2. 获取所有收集器收集的资源
|
||||||
List<CollectAssetInfo> allCollectAssets = AssetBundleCollectorSettingData.Setting.GetPackageAssets(buildMode, packageName);
|
var buildResult = AssetBundleCollectorSettingData.Setting.GetPackageAssets(buildMode, packageName);
|
||||||
|
List<CollectAssetInfo> allCollectAssets = buildResult.CollectAssets;
|
||||||
|
|
||||||
// 3. 剔除未被引用的依赖资源
|
// 3. 剔除未被引用的依赖资源
|
||||||
List<CollectAssetInfo> removeDependList = new List<CollectAssetInfo>();
|
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)
|
foreach (var collectAssetInfo in allCollectAssets)
|
||||||
{
|
{
|
||||||
var dependAssetInfos = new List<BuildAssetInfo>(collectAssetInfo.DependAssets.Count);
|
var dependAssetInfos = new List<BuildAssetInfo>(collectAssetInfo.DependAssets.Count);
|
||||||
@@ -88,13 +93,13 @@ namespace YooAsset.Editor
|
|||||||
buildAssetDic[collectAssetInfo.AssetPath].SetAllDependAssetInfos(dependAssetInfos);
|
buildAssetDic[collectAssetInfo.AssetPath].SetAllDependAssetInfos(dependAssetInfos);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 7. 计算完整的资源包名
|
// 8. 计算完整的资源包名
|
||||||
foreach (KeyValuePair<string, BuildAssetInfo> pair in buildAssetDic)
|
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>();
|
List<BuildAssetInfo> removeBuildList = new List<BuildAssetInfo>();
|
||||||
foreach (KeyValuePair<string, BuildAssetInfo> pair in buildAssetDic)
|
foreach (KeyValuePair<string, BuildAssetInfo> pair in buildAssetDic)
|
||||||
{
|
{
|
||||||
@@ -107,7 +112,7 @@ namespace YooAsset.Editor
|
|||||||
buildAssetDic.Remove(removeValue.AssetPath);
|
buildAssetDic.Remove(removeValue.AssetPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 9. 构建资源包
|
// 10. 构建资源包
|
||||||
var allBuildinAssets = buildAssetDic.Values.ToList();
|
var allBuildinAssets = buildAssetDic.Values.ToList();
|
||||||
if (allBuildinAssets.Count == 0)
|
if (allBuildinAssets.Count == 0)
|
||||||
throw new Exception("构建的资源列表不能为空");
|
throw new Exception("构建的资源列表不能为空");
|
||||||
|
|||||||
@@ -71,12 +71,7 @@ namespace YooAsset.Editor
|
|||||||
/// 验证构建结果
|
/// 验证构建结果
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool VerifyBuildingResult = false;
|
public bool VerifyBuildingResult = false;
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 启用可寻址资源定位
|
|
||||||
/// </summary>
|
|
||||||
public bool EnableAddressable = false;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 加密类
|
/// 加密类
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -53,6 +53,11 @@ namespace YooAsset.Editor
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public bool EnableAddressable;
|
public bool EnableAddressable;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 资源包名唯一化
|
||||||
|
/// </summary>
|
||||||
|
public bool UniqueBundleName;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 加密服务类名称
|
/// 加密服务类名称
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ namespace YooAsset.Editor
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private void CreatePatchManifestFile(BuildContext context)
|
private void CreatePatchManifestFile(BuildContext context)
|
||||||
{
|
{
|
||||||
|
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
||||||
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||||
var buildParameters = buildParametersContext.Parameters;
|
var buildParameters = buildParametersContext.Parameters;
|
||||||
string pipelineOutputDirectory = buildParametersContext.GetPipelineOutputDirectory();
|
string pipelineOutputDirectory = buildParametersContext.GetPipelineOutputDirectory();
|
||||||
@@ -28,7 +29,7 @@ namespace YooAsset.Editor
|
|||||||
// 创建新补丁清单
|
// 创建新补丁清单
|
||||||
PatchManifest patchManifest = new PatchManifest();
|
PatchManifest patchManifest = new PatchManifest();
|
||||||
patchManifest.FileVersion = YooAssetSettings.PatchManifestFileVersion;
|
patchManifest.FileVersion = YooAssetSettings.PatchManifestFileVersion;
|
||||||
patchManifest.EnableAddressable = buildParameters.EnableAddressable;
|
patchManifest.EnableAddressable = buildMapContext.EnableAddressable;
|
||||||
patchManifest.OutputNameStyle = (int)buildParameters.OutputNameStyle;
|
patchManifest.OutputNameStyle = (int)buildParameters.OutputNameStyle;
|
||||||
patchManifest.PackageName = buildParameters.BuildPackage;
|
patchManifest.PackageName = buildParameters.BuildPackage;
|
||||||
patchManifest.HumanReadableVersion = buildParameters.HumanReadableVersion;
|
patchManifest.HumanReadableVersion = buildParameters.HumanReadableVersion;
|
||||||
@@ -125,7 +126,6 @@ namespace YooAsset.Editor
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private List<PatchAsset> GetAllPatchAsset(BuildContext context, PatchManifest patchManifest)
|
private List<PatchAsset> GetAllPatchAsset(BuildContext context, PatchManifest patchManifest)
|
||||||
{
|
{
|
||||||
var buildParameters = context.GetContextObject<BuildParametersContext>();
|
|
||||||
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
||||||
|
|
||||||
List<PatchAsset> result = new List<PatchAsset>(1000);
|
List<PatchAsset> result = new List<PatchAsset>(1000);
|
||||||
@@ -135,7 +135,7 @@ namespace YooAsset.Editor
|
|||||||
foreach (var assetInfo in assetInfos)
|
foreach (var assetInfo in assetInfos)
|
||||||
{
|
{
|
||||||
PatchAsset patchAsset = new PatchAsset();
|
PatchAsset patchAsset = new PatchAsset();
|
||||||
if (buildParameters.Parameters.EnableAddressable)
|
if (buildMapContext.EnableAddressable)
|
||||||
patchAsset.Address = assetInfo.Address;
|
patchAsset.Address = assetInfo.Address;
|
||||||
else
|
else
|
||||||
patchAsset.Address = string.Empty;
|
patchAsset.Address = string.Empty;
|
||||||
|
|||||||
@@ -46,7 +46,9 @@ namespace YooAsset.Editor
|
|||||||
buildReport.Summary.BuildPipeline = buildParameters.BuildPipeline;
|
buildReport.Summary.BuildPipeline = buildParameters.BuildPipeline;
|
||||||
buildReport.Summary.BuildMode = buildParameters.BuildMode;
|
buildReport.Summary.BuildMode = buildParameters.BuildMode;
|
||||||
buildReport.Summary.BuildPackage = buildParameters.BuildPackage;
|
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 ?
|
buildReport.Summary.EncryptionServicesClassName = buildParameters.EncryptionServices == null ?
|
||||||
"null" : buildParameters.EncryptionServices.GetType().FullName;
|
"null" : buildParameters.EncryptionServices.GetType().FullName;
|
||||||
|
|
||||||
|
|||||||
@@ -132,10 +132,10 @@ namespace YooAsset.Editor
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取打包收集的资源文件
|
/// 获取打包收集的资源文件
|
||||||
/// </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)
|
if (CollectorType != ECollectorType.MainAssetCollector)
|
||||||
return new List<CollectAssetInfo>();
|
return new List<CollectAssetInfo>();
|
||||||
@@ -162,7 +162,7 @@ namespace YooAsset.Editor
|
|||||||
{
|
{
|
||||||
if (result.ContainsKey(assetPath) == false)
|
if (result.ContainsKey(assetPath) == false)
|
||||||
{
|
{
|
||||||
var collectAssetInfo = CreateCollectAssetInfo(buildMode, group, assetPath, isRawAsset);
|
var collectAssetInfo = CreateCollectAssetInfo(command, group, assetPath, isRawAsset);
|
||||||
result.Add(assetPath, collectAssetInfo);
|
result.Add(assetPath, collectAssetInfo);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -177,7 +177,7 @@ namespace YooAsset.Editor
|
|||||||
string assetPath = CollectPath;
|
string assetPath = CollectPath;
|
||||||
if (IsValidateAsset(assetPath) && IsCollectAsset(assetPath))
|
if (IsValidateAsset(assetPath) && IsCollectAsset(assetPath))
|
||||||
{
|
{
|
||||||
var collectAssetInfo = CreateCollectAssetInfo(buildMode, group, assetPath, isRawAsset);
|
var collectAssetInfo = CreateCollectAssetInfo(command, group, assetPath, isRawAsset);
|
||||||
result.Add(assetPath, collectAssetInfo);
|
result.Add(assetPath, collectAssetInfo);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -187,7 +187,7 @@ namespace YooAsset.Editor
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 检测可寻址地址是否重复
|
// 检测可寻址地址是否重复
|
||||||
if (enableAddressable)
|
if (command.EnableAddressable)
|
||||||
{
|
{
|
||||||
HashSet<string> adressTemper = new HashSet<string>();
|
HashSet<string> adressTemper = new HashSet<string>();
|
||||||
foreach (var collectInfoPair in result)
|
foreach (var collectInfoPair in result)
|
||||||
@@ -207,7 +207,7 @@ namespace YooAsset.Editor
|
|||||||
return result.Values.ToList();
|
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 address = GetAddress(group, assetPath);
|
||||||
string bundleName = GetBundleName(group, assetPath);
|
string bundleName = GetBundleName(group, assetPath);
|
||||||
@@ -215,7 +215,7 @@ namespace YooAsset.Editor
|
|||||||
CollectAssetInfo collectAssetInfo = new CollectAssetInfo(CollectorType, bundleName, address, assetPath, assetTags, isRawAsset);
|
CollectAssetInfo collectAssetInfo = new CollectAssetInfo(CollectorType, bundleName, address, assetPath, assetTags, isRawAsset);
|
||||||
|
|
||||||
// 注意:模拟构建模式下不需要收集依赖资源
|
// 注意:模拟构建模式下不需要收集依赖资源
|
||||||
if (buildMode == EBuildMode.SimulateBuild)
|
if (command.BuildMode == EBuildMode.SimulateBuild)
|
||||||
collectAssetInfo.DependAssets = new List<string>();
|
collectAssetInfo.DependAssets = new List<string>();
|
||||||
else
|
else
|
||||||
collectAssetInfo.DependAssets = GetAllDependencies(assetPath);
|
collectAssetInfo.DependAssets = GetAllDependencies(assetPath);
|
||||||
|
|||||||
@@ -10,11 +10,12 @@ namespace YooAsset.Editor
|
|||||||
{
|
{
|
||||||
public class AssetBundleCollectorConfig
|
public class AssetBundleCollectorConfig
|
||||||
{
|
{
|
||||||
public const string ConfigVersion = "2.0";
|
public const string ConfigVersion = "2.1";
|
||||||
|
|
||||||
public const string XmlVersion = "Version";
|
public const string XmlVersion = "Version";
|
||||||
public const string XmlCommon = "Common";
|
public const string XmlCommon = "Common";
|
||||||
public const string XmlEnableAddressable = "AutoAddressable";
|
public const string XmlEnableAddressable = "AutoAddressable";
|
||||||
|
public const string XmlUniqueBundleName = "UniqueBundleName";
|
||||||
public const string XmlShowPackageView = "ShowPackageView";
|
public const string XmlShowPackageView = "ShowPackageView";
|
||||||
|
|
||||||
public const string XmlPackage = "Package";
|
public const string XmlPackage = "Package";
|
||||||
@@ -62,6 +63,7 @@ namespace YooAsset.Editor
|
|||||||
|
|
||||||
// 读取公共配置
|
// 读取公共配置
|
||||||
bool enableAddressable = false;
|
bool enableAddressable = false;
|
||||||
|
bool uniqueBundleName = false;
|
||||||
bool showPackageView = false;
|
bool showPackageView = false;
|
||||||
var commonNodeList = root.GetElementsByTagName(XmlCommon);
|
var commonNodeList = root.GetElementsByTagName(XmlCommon);
|
||||||
if (commonNodeList.Count > 0)
|
if (commonNodeList.Count > 0)
|
||||||
@@ -69,10 +71,13 @@ namespace YooAsset.Editor
|
|||||||
XmlElement commonElement = commonNodeList[0] as XmlElement;
|
XmlElement commonElement = commonNodeList[0] as XmlElement;
|
||||||
if (commonElement.HasAttribute(XmlEnableAddressable) == false)
|
if (commonElement.HasAttribute(XmlEnableAddressable) == false)
|
||||||
throw new Exception($"Not found attribute {XmlEnableAddressable} in {XmlCommon}");
|
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)
|
if (commonElement.HasAttribute(XmlShowPackageView) == false)
|
||||||
throw new Exception($"Not found attribute {XmlShowPackageView} in {XmlCommon}");
|
throw new Exception($"Not found attribute {XmlShowPackageView} in {XmlCommon}");
|
||||||
|
|
||||||
enableAddressable = commonElement.GetAttribute(XmlEnableAddressable) == "True" ? true : false;
|
enableAddressable = commonElement.GetAttribute(XmlEnableAddressable) == "True" ? true : false;
|
||||||
|
uniqueBundleName = commonElement.GetAttribute(XmlUniqueBundleName) == "True" ? true : false;
|
||||||
showPackageView = commonElement.GetAttribute(XmlShowPackageView) == "True" ? true : false;
|
showPackageView = commonElement.GetAttribute(XmlShowPackageView) == "True" ? true : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -146,6 +151,7 @@ namespace YooAsset.Editor
|
|||||||
// 保存配置数据
|
// 保存配置数据
|
||||||
AssetBundleCollectorSettingData.ClearAll();
|
AssetBundleCollectorSettingData.ClearAll();
|
||||||
AssetBundleCollectorSettingData.Setting.EnableAddressable = enableAddressable;
|
AssetBundleCollectorSettingData.Setting.EnableAddressable = enableAddressable;
|
||||||
|
AssetBundleCollectorSettingData.Setting.UniqueBundleName = uniqueBundleName;
|
||||||
AssetBundleCollectorSettingData.Setting.ShowPackageView = showPackageView;
|
AssetBundleCollectorSettingData.Setting.ShowPackageView = showPackageView;
|
||||||
AssetBundleCollectorSettingData.Setting.Packages.AddRange(packages);
|
AssetBundleCollectorSettingData.Setting.Packages.AddRange(packages);
|
||||||
AssetBundleCollectorSettingData.SaveFile();
|
AssetBundleCollectorSettingData.SaveFile();
|
||||||
@@ -175,6 +181,7 @@ namespace YooAsset.Editor
|
|||||||
// 设置公共配置
|
// 设置公共配置
|
||||||
var commonElement = xmlDoc.CreateElement(XmlCommon);
|
var commonElement = xmlDoc.CreateElement(XmlCommon);
|
||||||
commonElement.SetAttribute(XmlEnableAddressable, AssetBundleCollectorSettingData.Setting.EnableAddressable.ToString());
|
commonElement.SetAttribute(XmlEnableAddressable, AssetBundleCollectorSettingData.Setting.EnableAddressable.ToString());
|
||||||
|
commonElement.SetAttribute(XmlUniqueBundleName, AssetBundleCollectorSettingData.Setting.UniqueBundleName.ToString());
|
||||||
commonElement.SetAttribute(XmlShowPackageView, AssetBundleCollectorSettingData.Setting.ShowPackageView.ToString());
|
commonElement.SetAttribute(XmlShowPackageView, AssetBundleCollectorSettingData.Setting.ShowPackageView.ToString());
|
||||||
root.AppendChild(commonElement);
|
root.AppendChild(commonElement);
|
||||||
|
|
||||||
@@ -269,7 +276,23 @@ namespace YooAsset.Editor
|
|||||||
|
|
||||||
// 更新版本
|
// 更新版本
|
||||||
root.SetAttribute(XmlVersion, "2.0");
|
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);
|
return UpdateXmlConfig(xmlDoc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ namespace YooAsset.Editor
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取打包收集的资源文件
|
/// 获取打包收集的资源文件
|
||||||
/// </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);
|
Dictionary<string, CollectAssetInfo> result = new Dictionary<string, CollectAssetInfo>(10000);
|
||||||
|
|
||||||
@@ -83,7 +83,7 @@ namespace YooAsset.Editor
|
|||||||
// 收集打包资源
|
// 收集打包资源
|
||||||
foreach (var collector in Collectors)
|
foreach (var collector in Collectors)
|
||||||
{
|
{
|
||||||
var temper = collector.GetAllCollectAssets(buildMode, enableAddressable, this);
|
var temper = collector.GetAllCollectAssets(command, this);
|
||||||
foreach (var assetInfo in temper)
|
foreach (var assetInfo in temper)
|
||||||
{
|
{
|
||||||
if (result.ContainsKey(assetInfo.AssetPath) == false)
|
if (result.ContainsKey(assetInfo.AssetPath) == false)
|
||||||
@@ -94,7 +94,7 @@ namespace YooAsset.Editor
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 检测可寻址地址是否重复
|
// 检测可寻址地址是否重复
|
||||||
if (enableAddressable)
|
if (command.EnableAddressable)
|
||||||
{
|
{
|
||||||
HashSet<string> adressTemper = new HashSet<string>();
|
HashSet<string> adressTemper = new HashSet<string>();
|
||||||
foreach (var collectInfoPair in result)
|
foreach (var collectInfoPair in result)
|
||||||
|
|||||||
@@ -56,14 +56,14 @@ namespace YooAsset.Editor
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取打包收集的资源文件
|
/// 获取打包收集的资源文件
|
||||||
/// </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);
|
Dictionary<string, CollectAssetInfo> result = new Dictionary<string, CollectAssetInfo>(10000);
|
||||||
|
|
||||||
// 收集打包资源
|
// 收集打包资源
|
||||||
foreach (var group in Groups)
|
foreach (var group in Groups)
|
||||||
{
|
{
|
||||||
var temper = group.GetAllCollectAssets(buildMode, enableAddressable);
|
var temper = group.GetAllCollectAssets(command);
|
||||||
foreach (var assetInfo in temper)
|
foreach (var assetInfo in temper)
|
||||||
{
|
{
|
||||||
if (result.ContainsKey(assetInfo.AssetPath) == false)
|
if (result.ContainsKey(assetInfo.AssetPath) == false)
|
||||||
@@ -74,7 +74,7 @@ namespace YooAsset.Editor
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 检测可寻址地址是否重复
|
// 检测可寻址地址是否重复
|
||||||
if (enableAddressable)
|
if (command.EnableAddressable)
|
||||||
{
|
{
|
||||||
HashSet<string> adressTemper = new HashSet<string>();
|
HashSet<string> adressTemper = new HashSet<string>();
|
||||||
foreach (var collectInfoPair in result)
|
foreach (var collectInfoPair in result)
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ namespace YooAsset.Editor
|
|||||||
public class AssetBundleCollectorSetting : ScriptableObject
|
public class AssetBundleCollectorSetting : ScriptableObject
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 是否显示包裹视图
|
/// 是否显示包裹列表视图
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool ShowPackageView = false;
|
public bool ShowPackageView = false;
|
||||||
|
|
||||||
@@ -18,6 +18,11 @@ namespace YooAsset.Editor
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public bool EnableAddressable = false;
|
public bool EnableAddressable = false;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 资源包名唯一化
|
||||||
|
/// </summary>
|
||||||
|
public bool UniqueBundleName = false;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 包裹列表
|
/// 包裹列表
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -76,37 +81,43 @@ namespace YooAsset.Editor
|
|||||||
Debug.LogWarning($"Not found package : {packageName}");
|
Debug.LogWarning($"Not found package : {packageName}");
|
||||||
return new List<string>();
|
return new List<string>();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取包裹收集的资源文件
|
/// 获取包裹收集的资源文件
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public List<CollectAssetInfo> GetPackageAssets(EBuildMode buildMode, string packageName)
|
public CollectResult GetPackageAssets(EBuildMode buildMode, string packageName)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(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)
|
foreach (var package in Packages)
|
||||||
{
|
{
|
||||||
if (package.PackageName == packageName)
|
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}");
|
throw new Exception($"Not found collector pacakge : {packageName}");
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取所有包裹收集的资源文件
|
/// 获取所有包裹收集的资源文件
|
||||||
/// </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)
|
foreach (var package in Packages)
|
||||||
{
|
{
|
||||||
var temper = package.GetAllCollectAssets(buildMode, EnableAddressable);
|
CollectCommand command = new CollectCommand(buildMode, EnableAddressable);
|
||||||
result.AddRange(temper);
|
CollectResult collectResult = new CollectResult(package.PackageName, EnableAddressable, UniqueBundleName);
|
||||||
|
collectResult.SetCollectAssets(package.GetAllCollectAssets(command));
|
||||||
|
collectResultList.Add(collectResult);
|
||||||
}
|
}
|
||||||
return result;
|
return collectResultList;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -347,14 +347,20 @@ namespace YooAsset.Editor
|
|||||||
Setting.EnableAddressable = enableAddressable;
|
Setting.EnableAddressable = enableAddressable;
|
||||||
IsDirty = true;
|
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();
|
AssetBundleCollectorPackage package = new AssetBundleCollectorPackage();
|
||||||
package.PackageName = packageName;
|
package.PackageName = packageName;
|
||||||
Setting.Packages.Add(package);
|
Setting.Packages.Add(package);
|
||||||
IsDirty = true;
|
IsDirty = true;
|
||||||
|
return package;
|
||||||
}
|
}
|
||||||
public static void RemovePackage(AssetBundleCollectorPackage 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();
|
AssetBundleCollectorGroup group = new AssetBundleCollectorGroup();
|
||||||
group.GroupName = groupName;
|
group.GroupName = groupName;
|
||||||
package.Groups.Add(group);
|
package.Groups.Add(group);
|
||||||
IsDirty = true;
|
IsDirty = true;
|
||||||
|
return group;
|
||||||
}
|
}
|
||||||
public static void RemoveGroup(AssetBundleCollectorPackage package, AssetBundleCollectorGroup group)
|
public static void RemoveGroup(AssetBundleCollectorPackage package, AssetBundleCollectorGroup group)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ namespace YooAsset.Editor
|
|||||||
|
|
||||||
private Toggle _showPackageToogle;
|
private Toggle _showPackageToogle;
|
||||||
private Toggle _enableAddressableToogle;
|
private Toggle _enableAddressableToogle;
|
||||||
|
private Toggle _uniqueBundleNameToogle;
|
||||||
|
|
||||||
private VisualElement _packageContainer;
|
private VisualElement _packageContainer;
|
||||||
private ListView _packageListView;
|
private ListView _packageListView;
|
||||||
@@ -87,6 +88,12 @@ namespace YooAsset.Editor
|
|||||||
AssetBundleCollectorSettingData.ModifyAddressable(evt.newValue);
|
AssetBundleCollectorSettingData.ModifyAddressable(evt.newValue);
|
||||||
RefreshWindow();
|
RefreshWindow();
|
||||||
});
|
});
|
||||||
|
_uniqueBundleNameToogle = root.Q<Toggle>("UniqueBundleName");
|
||||||
|
_uniqueBundleNameToogle.RegisterValueChangedCallback(evt =>
|
||||||
|
{
|
||||||
|
AssetBundleCollectorSettingData.ModifyUniqueBundleName(evt.newValue);
|
||||||
|
RefreshWindow();
|
||||||
|
});
|
||||||
|
|
||||||
// 配置修复按钮
|
// 配置修复按钮
|
||||||
var fixBtn = root.Q<Button>("FixButton");
|
var fixBtn = root.Q<Button>("FixButton");
|
||||||
@@ -289,6 +296,7 @@ namespace YooAsset.Editor
|
|||||||
private void FixBtn_clicked()
|
private void FixBtn_clicked()
|
||||||
{
|
{
|
||||||
AssetBundleCollectorSettingData.FixFile();
|
AssetBundleCollectorSettingData.FixFile();
|
||||||
|
RefreshWindow();
|
||||||
}
|
}
|
||||||
private void ExportBtn_clicked()
|
private void ExportBtn_clicked()
|
||||||
{
|
{
|
||||||
@@ -733,8 +741,8 @@ namespace YooAsset.Editor
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
bool enableAdressable = AssetBundleCollectorSettingData.Setting.EnableAddressable;
|
CollectCommand command = new CollectCommand(EBuildMode.DryRunBuild, _enableAddressableToogle.value);
|
||||||
collectAssetInfos = collector.GetAllCollectAssets(EBuildMode.DryRunBuild, enableAdressable, group);
|
collectAssetInfos = collector.GetAllCollectAssets(command, group);
|
||||||
}
|
}
|
||||||
catch (System.Exception e)
|
catch (System.Exception e)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -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: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="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="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>
|
||||||
<ui:VisualElement name="ContentContainer" style="flex-grow: 1; flex-direction: row;">
|
<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;">
|
<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;">
|
||||||
|
|||||||
@@ -50,5 +50,13 @@ namespace YooAsset.Editor
|
|||||||
AssetTags = assetTags;
|
AssetTags = assetTags;
|
||||||
IsRawAsset = isRawAsset;
|
IsRawAsset = isRawAsset;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 资源包名称追加包裹名
|
||||||
|
/// </summary>
|
||||||
|
public void BundleNameAppendPackageName(string packageName)
|
||||||
|
{
|
||||||
|
BundleName = $"{packageName.ToLower()}_{BundleName}";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: a8d6592eded144142afcf85c79cf1ce4
|
guid: b1741e85d76b28d41a4da3cd0e3e6f20
|
||||||
MonoImporter:
|
MonoImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
49
Assets/YooAsset/Editor/AssetBundleCollector/CollectResult.cs
Normal file
49
Assets/YooAsset/Editor/AssetBundleCollector/CollectResult.cs
Normal 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: cfc81e18e5b5f6f4b821c7427b34d349
|
guid: dbbd465f929ee33408441b62d19c7d10
|
||||||
MonoImporter:
|
MonoImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
@@ -40,7 +40,7 @@ namespace YooAsset.Editor
|
|||||||
_visualAsset = EditorHelper.LoadWindowUXML<ReporterSummaryViewer>();
|
_visualAsset = EditorHelper.LoadWindowUXML<ReporterSummaryViewer>();
|
||||||
if (_visualAsset == null)
|
if (_visualAsset == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
_root = _visualAsset.CloneTree();
|
_root = _visualAsset.CloneTree();
|
||||||
_root.style.flexGrow = 1f;
|
_root.style.flexGrow = 1f;
|
||||||
|
|
||||||
@@ -56,7 +56,7 @@ namespace YooAsset.Editor
|
|||||||
public void FillViewData(BuildReport buildReport)
|
public void FillViewData(BuildReport buildReport)
|
||||||
{
|
{
|
||||||
_buildReport = buildReport;
|
_buildReport = buildReport;
|
||||||
|
|
||||||
_items.Clear();
|
_items.Clear();
|
||||||
|
|
||||||
_items.Add(new ItemWrapper("YooAsset版本", buildReport.Summary.YooVersion));
|
_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.BuildPackage}"));
|
||||||
|
|
||||||
_items.Add(new ItemWrapper("启用可寻址资源定位", $"{buildReport.Summary.EnableAddressable}"));
|
_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("加密服务类名称", $"{buildReport.Summary.EncryptionServicesClassName}"));
|
||||||
|
|
||||||
_items.Add(new ItemWrapper(string.Empty, string.Empty));
|
_items.Add(new ItemWrapper(string.Empty, string.Empty));
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ namespace YooAsset.Editor
|
|||||||
throw new System.Exception("Shader variant file extension is invalid.");
|
throw new System.Exception("Shader variant file extension is invalid.");
|
||||||
|
|
||||||
// 注意:先删除再保存,否则ShaderVariantCollection内容将无法及时刷新
|
// 注意:先删除再保存,否则ShaderVariantCollection内容将无法及时刷新
|
||||||
AssetDatabase.DeleteAsset(ShaderVariantCollectorSettingData.Setting.SavePath);
|
AssetDatabase.DeleteAsset(ShaderVariantCollectorSettingData.Setting.SavePath);
|
||||||
EditorTools.CreateFileDirectory(saveFilePath);
|
EditorTools.CreateFileDirectory(saveFilePath);
|
||||||
_saveFilePath = saveFilePath;
|
_saveFilePath = saveFilePath;
|
||||||
_completedCallback = completedCallback;
|
_completedCallback = completedCallback;
|
||||||
@@ -87,9 +87,14 @@ namespace YooAsset.Editor
|
|||||||
List<string> allAssets = new List<string>(1000);
|
List<string> allAssets = new List<string>(1000);
|
||||||
|
|
||||||
// 获取所有打包的资源
|
// 获取所有打包的资源
|
||||||
List<CollectAssetInfo> allCollectInfos = AssetBundleCollectorSettingData.Setting.GetAllPackageAssets(EBuildMode.DryRunBuild);
|
List<CollectAssetInfo> allCollectAssetInfos = new List<CollectAssetInfo>();
|
||||||
List<string> collectAssets = allCollectInfos.Select(t => t.AssetPath).ToList();
|
List<CollectResult> collectResults = AssetBundleCollectorSettingData.Setting.GetAllPackageAssets(EBuildMode.DryRunBuild);
|
||||||
foreach (var assetPath in collectAssets)
|
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);
|
string[] depends = AssetDatabase.GetDependencies(assetPath, true);
|
||||||
foreach (var depend in depends)
|
foreach (var depend in depends)
|
||||||
@@ -97,7 +102,7 @@ namespace YooAsset.Editor
|
|||||||
if (allAssets.Contains(depend) == false)
|
if (allAssets.Contains(depend) == false)
|
||||||
allAssets.Add(depend);
|
allAssets.Add(depend);
|
||||||
}
|
}
|
||||||
EditorTools.DisplayProgressBar("获取所有打包资源", ++progressValue, collectAssets.Count);
|
EditorTools.DisplayProgressBar("获取所有打包资源", ++progressValue, allAssetPath.Count);
|
||||||
}
|
}
|
||||||
EditorTools.ClearProgressBar();
|
EditorTools.ClearProgressBar();
|
||||||
|
|
||||||
|
|||||||
@@ -142,6 +142,7 @@ namespace YooAsset
|
|||||||
{
|
{
|
||||||
if (assetInfo.IsInvalid)
|
if (assetInfo.IsInvalid)
|
||||||
{
|
{
|
||||||
|
YooLogger.Error($"Failed to load scene. {assetInfo.Error}");
|
||||||
CompletedProvider completedProvider = new CompletedProvider(assetInfo);
|
CompletedProvider completedProvider = new CompletedProvider(assetInfo);
|
||||||
completedProvider.SetCompleted(assetInfo.Error);
|
completedProvider.SetCompleted(assetInfo.Error);
|
||||||
return completedProvider.CreateHandle<SceneOperationHandle>();
|
return completedProvider.CreateHandle<SceneOperationHandle>();
|
||||||
@@ -190,6 +191,7 @@ namespace YooAsset
|
|||||||
{
|
{
|
||||||
if (assetInfo.IsInvalid)
|
if (assetInfo.IsInvalid)
|
||||||
{
|
{
|
||||||
|
YooLogger.Error($"Failed to load asset. {assetInfo.Error}");
|
||||||
CompletedProvider completedProvider = new CompletedProvider(assetInfo);
|
CompletedProvider completedProvider = new CompletedProvider(assetInfo);
|
||||||
completedProvider.SetCompleted(assetInfo.Error);
|
completedProvider.SetCompleted(assetInfo.Error);
|
||||||
return completedProvider.CreateHandle<AssetOperationHandle>();
|
return completedProvider.CreateHandle<AssetOperationHandle>();
|
||||||
@@ -216,6 +218,7 @@ namespace YooAsset
|
|||||||
{
|
{
|
||||||
if (assetInfo.IsInvalid)
|
if (assetInfo.IsInvalid)
|
||||||
{
|
{
|
||||||
|
YooLogger.Error($"Failed to load sub assets. {assetInfo.Error}");
|
||||||
CompletedProvider completedProvider = new CompletedProvider(assetInfo);
|
CompletedProvider completedProvider = new CompletedProvider(assetInfo);
|
||||||
completedProvider.SetCompleted(assetInfo.Error);
|
completedProvider.SetCompleted(assetInfo.Error);
|
||||||
return completedProvider.CreateHandle<SubAssetsOperationHandle>();
|
return completedProvider.CreateHandle<SubAssetsOperationHandle>();
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ namespace YooAsset
|
|||||||
private EOperationStatus _initializeStatus = EOperationStatus.None;
|
private EOperationStatus _initializeStatus = EOperationStatus.None;
|
||||||
private EPlayMode _playMode;
|
private EPlayMode _playMode;
|
||||||
private IBundleServices _bundleServices;
|
private IBundleServices _bundleServices;
|
||||||
private ILocationServices _locationServices;
|
|
||||||
private AssetSystemImpl _assetSystemImpl;
|
private AssetSystemImpl _assetSystemImpl;
|
||||||
private EditorSimulateModeImpl _editorSimulateModeImpl;
|
private EditorSimulateModeImpl _editorSimulateModeImpl;
|
||||||
private OfflinePlayModeImpl _offlinePlayModeImpl;
|
private OfflinePlayModeImpl _offlinePlayModeImpl;
|
||||||
@@ -33,7 +32,7 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
internal AssetsPackage()
|
private AssetsPackage()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
internal AssetsPackage(string packageName)
|
internal AssetsPackage(string packageName)
|
||||||
@@ -62,7 +61,6 @@ namespace YooAsset
|
|||||||
_initializeStatus = EOperationStatus.None;
|
_initializeStatus = EOperationStatus.None;
|
||||||
|
|
||||||
_bundleServices = null;
|
_bundleServices = null;
|
||||||
_locationServices = null;
|
|
||||||
_editorSimulateModeImpl = null;
|
_editorSimulateModeImpl = null;
|
||||||
_offlinePlayModeImpl = null;
|
_offlinePlayModeImpl = null;
|
||||||
_hostPlayModeImpl = null;
|
_hostPlayModeImpl = null;
|
||||||
@@ -72,8 +70,6 @@ namespace YooAsset
|
|||||||
_assetSystemImpl.DestroyAll();
|
_assetSystemImpl.DestroyAll();
|
||||||
_assetSystemImpl = null;
|
_assetSystemImpl = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
YooLogger.Log("YooAssets destroy all !");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -87,7 +83,6 @@ namespace YooAsset
|
|||||||
|
|
||||||
// 初始化资源系统
|
// 初始化资源系统
|
||||||
InitializationOperation initializeOperation;
|
InitializationOperation initializeOperation;
|
||||||
_locationServices = parameters.LocationServices;
|
|
||||||
_assetSystemImpl = new AssetSystemImpl();
|
_assetSystemImpl = new AssetSystemImpl();
|
||||||
if (_playMode == EPlayMode.EditorSimulateMode)
|
if (_playMode == EPlayMode.EditorSimulateMode)
|
||||||
{
|
{
|
||||||
@@ -143,14 +138,11 @@ namespace YooAsset
|
|||||||
throw new Exception($"Editor simulate mode only support unity editor.");
|
throw new Exception($"Editor simulate mode only support unity editor.");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (parameters.LocationServices == null)
|
|
||||||
throw new Exception($"{nameof(ILocationServices)} is null.");
|
|
||||||
|
|
||||||
if (parameters is EditorSimulateModeParameters)
|
if (parameters is EditorSimulateModeParameters)
|
||||||
{
|
{
|
||||||
var editorSimulateModeParameters = parameters as EditorSimulateModeParameters;
|
var editorSimulateModeParameters = parameters as EditorSimulateModeParameters;
|
||||||
if (string.IsNullOrEmpty(editorSimulateModeParameters.SimulatePatchManifestPath))
|
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)
|
if (parameters is HostPlayModeParameters)
|
||||||
@@ -335,7 +327,10 @@ namespace YooAsset
|
|||||||
DebugCheckInitialize();
|
DebugCheckInitialize();
|
||||||
AssetInfo assetInfo = ConvertLocationToAssetInfo(location, null);
|
AssetInfo assetInfo = ConvertLocationToAssetInfo(location, null);
|
||||||
if (assetInfo.IsInvalid)
|
if (assetInfo.IsInvalid)
|
||||||
|
{
|
||||||
|
YooLogger.Warning(assetInfo.Error);
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
BundleInfo bundleInfo = _bundleServices.GetBundleInfo(assetInfo);
|
BundleInfo bundleInfo = _bundleServices.GetBundleInfo(assetInfo);
|
||||||
if (bundleInfo.LoadMode == BundleInfo.ELoadMode.LoadFromRemote)
|
if (bundleInfo.LoadMode == BundleInfo.ELoadMode.LoadFromRemote)
|
||||||
@@ -397,14 +392,14 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取资源路径
|
/// 检查资源定位地址是否有效
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="location">资源的定位地址</param>
|
/// <param name="location">资源的定位地址</param>
|
||||||
/// <returns>如果location地址无效,则返回空字符串</returns>
|
public bool CheckLocationValid(string location)
|
||||||
public string GetAssetPath(string location)
|
|
||||||
{
|
{
|
||||||
DebugCheckInitialize();
|
DebugCheckInitialize();
|
||||||
return _locationServices.ConvertLocationToAssetPath(this, location);
|
string assetPath = _bundleServices.TryMappingToAssetPath(location);
|
||||||
|
return string.IsNullOrEmpty(assetPath) == false;
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
@@ -429,8 +424,6 @@ namespace YooAsset
|
|||||||
public RawFileOperation GetRawFileAsync(AssetInfo assetInfo, string copyPath = null)
|
public RawFileOperation GetRawFileAsync(AssetInfo assetInfo, string copyPath = null)
|
||||||
{
|
{
|
||||||
DebugCheckInitialize();
|
DebugCheckInitialize();
|
||||||
if (assetInfo.IsInvalid)
|
|
||||||
YooLogger.Warning(assetInfo.Error);
|
|
||||||
return GetRawFileInternal(assetInfo, copyPath);
|
return GetRawFileInternal(assetInfo, copyPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -439,6 +432,7 @@ namespace YooAsset
|
|||||||
{
|
{
|
||||||
if (assetInfo.IsInvalid)
|
if (assetInfo.IsInvalid)
|
||||||
{
|
{
|
||||||
|
YooLogger.Error($"Failed to get raw file. {assetInfo.Error}");
|
||||||
RawFileOperation operation = new CompletedRawFileOperation(assetInfo.Error, copyPath);
|
RawFileOperation operation = new CompletedRawFileOperation(assetInfo.Error, copyPath);
|
||||||
OperationSystem.StartOperation(operation);
|
OperationSystem.StartOperation(operation);
|
||||||
return operation;
|
return operation;
|
||||||
@@ -508,8 +502,6 @@ namespace YooAsset
|
|||||||
public SceneOperationHandle LoadSceneAsync(AssetInfo assetInfo, LoadSceneMode sceneMode = LoadSceneMode.Single, bool activateOnLoad = true, int priority = 100)
|
public SceneOperationHandle LoadSceneAsync(AssetInfo assetInfo, LoadSceneMode sceneMode = LoadSceneMode.Single, bool activateOnLoad = true, int priority = 100)
|
||||||
{
|
{
|
||||||
DebugCheckInitialize();
|
DebugCheckInitialize();
|
||||||
if (assetInfo.IsInvalid)
|
|
||||||
YooLogger.Warning(assetInfo.Error);
|
|
||||||
var handle = _assetSystemImpl.LoadSceneAsync(assetInfo, sceneMode, activateOnLoad, priority);
|
var handle = _assetSystemImpl.LoadSceneAsync(assetInfo, sceneMode, activateOnLoad, priority);
|
||||||
return handle;
|
return handle;
|
||||||
}
|
}
|
||||||
@@ -523,8 +515,6 @@ namespace YooAsset
|
|||||||
public AssetOperationHandle LoadAssetSync(AssetInfo assetInfo)
|
public AssetOperationHandle LoadAssetSync(AssetInfo assetInfo)
|
||||||
{
|
{
|
||||||
DebugCheckInitialize();
|
DebugCheckInitialize();
|
||||||
if (assetInfo.IsInvalid)
|
|
||||||
YooLogger.Warning(assetInfo.Error);
|
|
||||||
return LoadAssetInternal(assetInfo, true);
|
return LoadAssetInternal(assetInfo, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -560,8 +550,6 @@ namespace YooAsset
|
|||||||
public AssetOperationHandle LoadAssetAsync(AssetInfo assetInfo)
|
public AssetOperationHandle LoadAssetAsync(AssetInfo assetInfo)
|
||||||
{
|
{
|
||||||
DebugCheckInitialize();
|
DebugCheckInitialize();
|
||||||
if (assetInfo.IsInvalid)
|
|
||||||
YooLogger.Warning(assetInfo.Error);
|
|
||||||
return LoadAssetInternal(assetInfo, false);
|
return LoadAssetInternal(assetInfo, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -593,14 +581,17 @@ namespace YooAsset
|
|||||||
private AssetOperationHandle LoadAssetInternal(AssetInfo assetInfo, bool waitForAsyncComplete)
|
private AssetOperationHandle LoadAssetInternal(AssetInfo assetInfo, bool waitForAsyncComplete)
|
||||||
{
|
{
|
||||||
#if UNITY_EDITOR
|
#if UNITY_EDITOR
|
||||||
BundleInfo bundleInfo = _bundleServices.GetBundleInfo(assetInfo);
|
if (assetInfo.IsInvalid == false)
|
||||||
if (bundleInfo.Bundle.IsRawFile)
|
|
||||||
{
|
{
|
||||||
string error = $"Cannot load raw file using LoadAsset method !";
|
BundleInfo bundleInfo = _bundleServices.GetBundleInfo(assetInfo);
|
||||||
YooLogger.Error(error);
|
if (bundleInfo.Bundle.IsRawFile)
|
||||||
CompletedProvider completedProvider = new CompletedProvider(assetInfo);
|
{
|
||||||
completedProvider.SetCompleted(error);
|
string error = $"Cannot load raw file using LoadAsset method !";
|
||||||
return completedProvider.CreateHandle<AssetOperationHandle>();
|
YooLogger.Error(error);
|
||||||
|
CompletedProvider completedProvider = new CompletedProvider(assetInfo);
|
||||||
|
completedProvider.SetCompleted(error);
|
||||||
|
return completedProvider.CreateHandle<AssetOperationHandle>();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -619,8 +610,6 @@ namespace YooAsset
|
|||||||
public SubAssetsOperationHandle LoadSubAssetsSync(AssetInfo assetInfo)
|
public SubAssetsOperationHandle LoadSubAssetsSync(AssetInfo assetInfo)
|
||||||
{
|
{
|
||||||
DebugCheckInitialize();
|
DebugCheckInitialize();
|
||||||
if (assetInfo.IsInvalid)
|
|
||||||
YooLogger.Warning(assetInfo.Error);
|
|
||||||
return LoadSubAssetsInternal(assetInfo, true);
|
return LoadSubAssetsInternal(assetInfo, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -656,8 +645,6 @@ namespace YooAsset
|
|||||||
public SubAssetsOperationHandle LoadSubAssetsAsync(AssetInfo assetInfo)
|
public SubAssetsOperationHandle LoadSubAssetsAsync(AssetInfo assetInfo)
|
||||||
{
|
{
|
||||||
DebugCheckInitialize();
|
DebugCheckInitialize();
|
||||||
if (assetInfo.IsInvalid)
|
|
||||||
YooLogger.Warning(assetInfo.Error);
|
|
||||||
return LoadSubAssetsInternal(assetInfo, false);
|
return LoadSubAssetsInternal(assetInfo, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -689,14 +676,17 @@ namespace YooAsset
|
|||||||
private SubAssetsOperationHandle LoadSubAssetsInternal(AssetInfo assetInfo, bool waitForAsyncComplete)
|
private SubAssetsOperationHandle LoadSubAssetsInternal(AssetInfo assetInfo, bool waitForAsyncComplete)
|
||||||
{
|
{
|
||||||
#if UNITY_EDITOR
|
#if UNITY_EDITOR
|
||||||
BundleInfo bundleInfo = _bundleServices.GetBundleInfo(assetInfo);
|
if (assetInfo.IsInvalid == false)
|
||||||
if (bundleInfo.Bundle.IsRawFile)
|
|
||||||
{
|
{
|
||||||
string error = $"Cannot load raw file using LoadSubAssets method !";
|
BundleInfo bundleInfo = _bundleServices.GetBundleInfo(assetInfo);
|
||||||
YooLogger.Error(error);
|
if (bundleInfo.Bundle.IsRawFile)
|
||||||
CompletedProvider completedProvider = new CompletedProvider(assetInfo);
|
{
|
||||||
completedProvider.SetCompleted(error);
|
string error = $"Cannot load raw file using LoadSubAssets method !";
|
||||||
return completedProvider.CreateHandle<SubAssetsOperationHandle>();
|
YooLogger.Error(error);
|
||||||
|
CompletedProvider completedProvider = new CompletedProvider(assetInfo);
|
||||||
|
completedProvider.SetCompleted(error);
|
||||||
|
return completedProvider.CreateHandle<SubAssetsOperationHandle>();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -940,14 +930,6 @@ namespace YooAsset
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region 内部方法
|
#region 内部方法
|
||||||
/// <summary>
|
|
||||||
/// 资源定位地址转换为资源完整路径
|
|
||||||
/// </summary>
|
|
||||||
internal string MappingToAssetPath(string location)
|
|
||||||
{
|
|
||||||
return _bundleServices.MappingToAssetPath(location);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 是否包含资源文件
|
/// 是否包含资源文件
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -1014,7 +996,7 @@ namespace YooAsset
|
|||||||
private AssetInfo ConvertLocationToAssetInfo(string location, System.Type assetType)
|
private AssetInfo ConvertLocationToAssetInfo(string location, System.Type assetType)
|
||||||
{
|
{
|
||||||
DebugCheckLocation(location);
|
DebugCheckLocation(location);
|
||||||
string assetPath = _locationServices.ConvertLocationToAssetPath(this, location);
|
string assetPath = _bundleServices.MappingToAssetPath(location);
|
||||||
PatchAsset patchAsset = _bundleServices.TryGetPatchAsset(assetPath);
|
PatchAsset patchAsset = _bundleServices.TryGetPatchAsset(assetPath);
|
||||||
if (patchAsset != null)
|
if (patchAsset != null)
|
||||||
{
|
{
|
||||||
@@ -1028,7 +1010,6 @@ namespace YooAsset
|
|||||||
error = $"The location is null or empty !";
|
error = $"The location is null or empty !";
|
||||||
else
|
else
|
||||||
error = $"The location is invalid : {location}";
|
error = $"The location is invalid : {location}";
|
||||||
YooLogger.Error(error);
|
|
||||||
AssetInfo assetInfo = new AssetInfo(error);
|
AssetInfo assetInfo = new AssetInfo(error);
|
||||||
return assetInfo;
|
return assetInfo;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine.Networking;
|
||||||
|
|
||||||
namespace YooAsset
|
namespace YooAsset
|
||||||
{
|
{
|
||||||
@@ -15,11 +16,22 @@ 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>
|
||||||
/// 启用断点续传的文件大小
|
/// 自定义的证书认证实例
|
||||||
|
/// </summary>
|
||||||
|
public static CertificateHandler CertificateHandlerInstance;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 启用断点续传功能文件的最小字节数
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static int BreakpointResumeFileSize { set; get; } = int.MaxValue;
|
public static int BreakpointResumeFileSize { set; get; } = int.MaxValue;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 下载失败后清理文件的HTTP错误码
|
||||||
|
/// </summary>
|
||||||
|
public static List<long> ClearFileResponseCodes { set; get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 更新所有下载器
|
/// 更新所有下载器
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -89,6 +89,12 @@ namespace YooAsset
|
|||||||
_downloadHandle = handler;
|
_downloadHandle = handler;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if (DownloadSystem.CertificateHandlerInstance != null)
|
||||||
|
{
|
||||||
|
_webRequest.certificateHandler = DownloadSystem.CertificateHandlerInstance;
|
||||||
|
_webRequest.disposeCertificateHandlerOnDispose = false;
|
||||||
|
}
|
||||||
|
|
||||||
_webRequest.downloadHandler = handler;
|
_webRequest.downloadHandler = handler;
|
||||||
_webRequest.disposeDownloadHandlerOnDispose = true;
|
_webRequest.disposeDownloadHandlerOnDispose = true;
|
||||||
if (fileLength > 0)
|
if (fileLength > 0)
|
||||||
@@ -156,13 +162,26 @@ namespace YooAsset
|
|||||||
// 如果下载失败
|
// 如果下载失败
|
||||||
if (hasError)
|
if (hasError)
|
||||||
{
|
{
|
||||||
// 注意:非断点续传下载失败后删除文件
|
// 注意:非断点续传下载失败之后删除文件
|
||||||
if (_breakResume == false)
|
if (_breakResume == false)
|
||||||
{
|
{
|
||||||
string cacheFilePath = _bundleInfo.Bundle.CachedFilePath;
|
string cacheFilePath = _bundleInfo.Bundle.CachedFilePath;
|
||||||
if (File.Exists(cacheFilePath))
|
if (File.Exists(cacheFilePath))
|
||||||
File.Delete(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)
|
if (_failedTryAgain > 0)
|
||||||
|
|||||||
@@ -33,11 +33,6 @@ namespace YooAsset
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public bool LocationToLower = false;
|
public bool LocationToLower = false;
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 资源定位服务接口
|
|
||||||
/// </summary>
|
|
||||||
public ILocationServices LocationServices = null;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 文件解密服务接口
|
/// 文件解密服务接口
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -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>
|
/// <summary>
|
||||||
/// 获取主资源包
|
/// 获取主资源包
|
||||||
/// 注意:传入的资源路径一定合法有效!
|
/// 注意:传入的资源路径一定合法有效!
|
||||||
|
|||||||
@@ -66,6 +66,10 @@ namespace YooAsset
|
|||||||
{
|
{
|
||||||
return _simulatePatchManifest.MappingToAssetPath(location);
|
return _simulatePatchManifest.MappingToAssetPath(location);
|
||||||
}
|
}
|
||||||
|
string IBundleServices.TryMappingToAssetPath(string location)
|
||||||
|
{
|
||||||
|
return _simulatePatchManifest.TryMappingToAssetPath(location);
|
||||||
|
}
|
||||||
string IBundleServices.GetPackageName()
|
string IBundleServices.GetPackageName()
|
||||||
{
|
{
|
||||||
return _simulatePatchManifest.PackageName;
|
return _simulatePatchManifest.PackageName;
|
||||||
|
|||||||
@@ -392,6 +392,10 @@ namespace YooAsset
|
|||||||
{
|
{
|
||||||
return LocalPatchManifest.MappingToAssetPath(location);
|
return LocalPatchManifest.MappingToAssetPath(location);
|
||||||
}
|
}
|
||||||
|
string IBundleServices.TryMappingToAssetPath(string location)
|
||||||
|
{
|
||||||
|
return LocalPatchManifest.TryMappingToAssetPath(location);
|
||||||
|
}
|
||||||
string IBundleServices.GetPackageName()
|
string IBundleServices.GetPackageName()
|
||||||
{
|
{
|
||||||
return LocalPatchManifest.PackageName;
|
return LocalPatchManifest.PackageName;
|
||||||
|
|||||||
@@ -117,6 +117,10 @@ namespace YooAsset
|
|||||||
{
|
{
|
||||||
return _appPatchManifest.MappingToAssetPath(location);
|
return _appPatchManifest.MappingToAssetPath(location);
|
||||||
}
|
}
|
||||||
|
string IBundleServices.TryMappingToAssetPath(string location)
|
||||||
|
{
|
||||||
|
return _appPatchManifest.TryMappingToAssetPath(location);
|
||||||
|
}
|
||||||
string IBundleServices.GetPackageName()
|
string IBundleServices.GetPackageName()
|
||||||
{
|
{
|
||||||
return _appPatchManifest.PackageName;
|
return _appPatchManifest.PackageName;
|
||||||
|
|||||||
@@ -28,6 +28,11 @@ namespace YooAsset
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
string MappingToAssetPath(string location);
|
string MappingToAssetPath(string location);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 尝试映射为资源路径
|
||||||
|
/// </summary>
|
||||||
|
string TryMappingToAssetPath(string location);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取所属的包裹名
|
/// 获取所属的包裹名
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -1,11 +0,0 @@
|
|||||||
|
|
||||||
namespace YooAsset
|
|
||||||
{
|
|
||||||
public interface ILocationServices
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// 定位地址转换为资源路径
|
|
||||||
/// </summary>
|
|
||||||
string ConvertLocationToAssetPath(AssetsPackage package, string location);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 6e400ee1e8b3556479bfa493ff7fe778
|
|
||||||
folderAsset: yes
|
|
||||||
DefaultImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
|
|
||||||
namespace YooAsset
|
|
||||||
{
|
|
||||||
public class AddressLocationServices : ILocationServices
|
|
||||||
{
|
|
||||||
string ILocationServices.ConvertLocationToAssetPath(AssetsPackage package, string location)
|
|
||||||
{
|
|
||||||
return package.MappingToAssetPath(location);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 8d996937ba73c9b4bb942b8ba6f43398
|
|
||||||
MonoImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
serializedVersion: 2
|
|
||||||
defaultReferences: []
|
|
||||||
executionOrder: 0
|
|
||||||
icon: {instanceID: 0}
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
||||||
@@ -147,7 +147,7 @@ namespace YooAsset
|
|||||||
|
|
||||||
#region 系统参数
|
#region 系统参数
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 启用下载系统的断点续传功能的文件大小
|
/// 设置下载系统参数,启用断点续传功能文件的最小字节数
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static void SetDownloadSystemBreakpointResumeFileSize(int fileBytes)
|
public static void SetDownloadSystemBreakpointResumeFileSize(int fileBytes)
|
||||||
{
|
{
|
||||||
@@ -155,7 +155,23 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <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>
|
/// </summary>
|
||||||
public static void SetOperationSystemMaxTimeSlice(long milliseconds)
|
public static void SetOperationSystemMaxTimeSlice(long milliseconds)
|
||||||
{
|
{
|
||||||
@@ -168,7 +184,7 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 设置缓存系统的已经缓存文件的校验等级
|
/// 设置缓存系统参数,已经缓存文件的校验等级
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static void SetCacheSystemCachedFileVerifyLevel(EVerifyLevel verifyLevel)
|
public static void SetCacheSystemCachedFileVerifyLevel(EVerifyLevel verifyLevel)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -70,14 +70,13 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取资源路径
|
/// 检查资源定位地址是否有效
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="location">资源的定位地址</param>
|
/// <param name="location">资源的定位地址</param>
|
||||||
/// <returns>如果location地址无效,则返回空字符串</returns>
|
public static bool CheckLocationValid(string location)
|
||||||
public static string GetAssetPath(string location)
|
|
||||||
{
|
{
|
||||||
DebugCheckDefaultPackageValid();
|
DebugCheckDefaultPackageValid();
|
||||||
return _defaultPackage.GetAssetPath(location);
|
return _defaultPackage.CheckLocationValid(location);
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|||||||
@@ -53,7 +53,6 @@ public class BootScene : MonoBehaviour
|
|||||||
if (PlayMode == EPlayMode.EditorSimulateMode)
|
if (PlayMode == EPlayMode.EditorSimulateMode)
|
||||||
{
|
{
|
||||||
var createParameters = new EditorSimulateModeParameters();
|
var createParameters = new EditorSimulateModeParameters();
|
||||||
createParameters.LocationServices = new AddressLocationServices();
|
|
||||||
createParameters.SimulatePatchManifestPath = EditorSimulateModeHelper.SimulateBuild("DefaultPackage");
|
createParameters.SimulatePatchManifestPath = EditorSimulateModeHelper.SimulateBuild("DefaultPackage");
|
||||||
yield return defaultPackage.InitializeAsync(createParameters);
|
yield return defaultPackage.InitializeAsync(createParameters);
|
||||||
}
|
}
|
||||||
@@ -62,7 +61,6 @@ public class BootScene : MonoBehaviour
|
|||||||
if (PlayMode == EPlayMode.OfflinePlayMode)
|
if (PlayMode == EPlayMode.OfflinePlayMode)
|
||||||
{
|
{
|
||||||
var createParameters = new OfflinePlayModeParameters();
|
var createParameters = new OfflinePlayModeParameters();
|
||||||
createParameters.LocationServices = new AddressLocationServices();
|
|
||||||
yield return defaultPackage.InitializeAsync(createParameters);
|
yield return defaultPackage.InitializeAsync(createParameters);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -70,7 +68,6 @@ public class BootScene : MonoBehaviour
|
|||||||
if (PlayMode == EPlayMode.HostPlayMode)
|
if (PlayMode == EPlayMode.HostPlayMode)
|
||||||
{
|
{
|
||||||
var createParameters = new HostPlayModeParameters();
|
var createParameters = new HostPlayModeParameters();
|
||||||
createParameters.LocationServices = new AddressLocationServices();
|
|
||||||
createParameters.QueryServices = new QueryStreamingAssetsFileServices();
|
createParameters.QueryServices = new QueryStreamingAssetsFileServices();
|
||||||
createParameters.DefaultHostServer = GetHostServerURL();
|
createParameters.DefaultHostServer = GetHostServerURL();
|
||||||
createParameters.FallbackHostServer = GetHostServerURL();
|
createParameters.FallbackHostServer = GetHostServerURL();
|
||||||
@@ -111,7 +108,8 @@ public class BootScene : MonoBehaviour
|
|||||||
{
|
{
|
||||||
public bool QueryStreamingAssets(string fileName)
|
public bool QueryStreamingAssets(string fileName)
|
||||||
{
|
{
|
||||||
return BetterStreamingAssets.FileExists($"{YooAssets.GetStreamingAssetBuildinFolderName()}/{fileName}");
|
string buildinFolderName = YooAssets.GetStreamingAssetBuildinFolderName();
|
||||||
|
return BetterStreamingAssets.FileExists($"{buildinFolderName}/{fileName}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,25 +1,25 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<root Version="2.0">
|
<root Version="2.1">
|
||||||
<Common AutoAddressable="True" ShowPackageView="False" />
|
<Common AutoAddressable="True" UniqueBundleName="False" ShowPackageView="False" />
|
||||||
<Package PackageName="DefaultPackage" PackageDesc="">
|
<Package PackageName="DefaultPackage" PackageDesc="">
|
||||||
<Group GroupName="Level" GroupDesc="关卡资源" AssetTags="level">
|
<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/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/Level2" CollectGUID="8045c1986f0ae964f8b1ea29e3522388" CollectType="MainAssetCollector" AddressRule="AddressByFileName" PackRule="PackSeparately" FilterRule="CollectPrefab" AssetTags="level2" />
|
||||||
</Group>
|
</Group>
|
||||||
<Group GroupName="Buildin" GroupDesc="首包资源" AssetTags="buildin">
|
<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/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/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/Music" CollectGUID="e05b02ee4d90ae84a99871ce75288ea2" CollectType="MainAssetCollector" AddressRule="AddressByFileName" PackRule="PackDirectory" FilterRule="CollectAll" AssetTags="" />
|
||||||
</Group>
|
</Group>
|
||||||
<Group GroupName="Panel" GroupDesc="面板资源" AssetTags="panel">
|
<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/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/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/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/UISprite" CollectGUID="29f27e4abf667c04b88a3996d8cdadfc" CollectType="MainAssetCollector" AddressRule="AddressByFileName" PackRule="PackDirectory" FilterRule="CollectAll" AssetTags="" />
|
||||||
</Group>
|
</Group>
|
||||||
<Group GroupName="Art" GroupDesc="美术资源" AssetTags="">
|
<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/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/UIFont" CollectGUID="464727a15e4a7dc4d895346374432399" CollectType="DependAssetCollector" AddressRule="AddressByFileName" PackRule="PackDirectory" FilterRule="CollectAll" AssetTags="" />
|
||||||
</Group>
|
</Group>
|
||||||
</Package>
|
</Package>
|
||||||
</root>
|
</root>
|
||||||
@@ -14,6 +14,7 @@ MonoBehaviour:
|
|||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
ShowPackageView: 0
|
ShowPackageView: 0
|
||||||
EnableAddressable: 1
|
EnableAddressable: 1
|
||||||
|
UniqueBundleName: 0
|
||||||
Packages:
|
Packages:
|
||||||
- PackageName: DefaultPackage
|
- PackageName: DefaultPackage
|
||||||
PackageDesc:
|
PackageDesc:
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "com.tuyoogame.yooasset",
|
"name": "com.tuyoogame.yooasset",
|
||||||
"displayName": "YooAsset",
|
"displayName": "YooAsset",
|
||||||
"version": "1.3.1",
|
"version": "1.3.2",
|
||||||
"unity": "2019.4",
|
"unity": "2019.4",
|
||||||
"description": "unity3d resources management system.",
|
"description": "unity3d resources management system.",
|
||||||
"author": {
|
"author": {
|
||||||
|
|||||||
@@ -52,6 +52,20 @@
|
|||||||
|
|
||||||
(4) BundleName_HashName_Extension:资源包名+哈希值+后缀名
|
(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.BuildPipeline = EBuildPipeline.BuiltinBuildPipeline;
|
||||||
buildParameters.BuildMode = EBuildMode.ForceRebuild;
|
buildParameters.BuildMode = EBuildMode.ForceRebuild;
|
||||||
buildParameters.BuildPackage = "DefaultPackage";
|
buildParameters.BuildPackage = "DefaultPackage";
|
||||||
|
buildParameters.HumanReadableVersion = "v1.0";
|
||||||
buildParameters.VerifyBuildingResult = true;
|
buildParameters.VerifyBuildingResult = true;
|
||||||
buildParameters.EnableAddressable = true;
|
|
||||||
buildParameters.EncryptionServices = new GameEncryption();
|
buildParameters.EncryptionServices = new GameEncryption();
|
||||||
buildParameters.CompressOption = ECompressOption.LZ4;
|
buildParameters.CompressOption = ECompressOption.LZ4;
|
||||||
buildParameters.OutputNameStyle = EOutputNameStyle.HashName_Extension;
|
buildParameters.OutputNameStyle = EOutputNameStyle.HashName_Extension;
|
||||||
|
buildParameters.CopyBuildinFileOption = ECopyBuildinFileOption.None;
|
||||||
|
|
||||||
// 执行构建
|
// 执行构建
|
||||||
AssetBundleBuilder builder = new AssetBundleBuilder();
|
AssetBundleBuilder builder = new AssetBundleBuilder();
|
||||||
|
|||||||
@@ -10,9 +10,17 @@
|
|||||||
|
|
||||||
#### 公共设置
|
#### 公共设置
|
||||||
|
|
||||||
|
- Show Packages
|
||||||
|
|
||||||
|
是否展示资源包列表视图。
|
||||||
|
|
||||||
- Enable Addressable
|
- Enable Addressable
|
||||||
|
|
||||||
启用可寻址资源定位系统。
|
启用可寻址资源定位系统。
|
||||||
|
|
||||||
|
- Unique Bundle Name
|
||||||
|
|
||||||
|
资源包名追加PackageName作为前缀。
|
||||||
|
|
||||||
#### 资源分组
|
#### 资源分组
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,14 @@
|
|||||||
初始化资源系统
|
初始化资源系统
|
||||||
|
|
||||||
```c#
|
```c#
|
||||||
|
// 初始化资源系统
|
||||||
YooAssets.Initialize();
|
YooAssets.Initialize();
|
||||||
|
|
||||||
|
// 创建默认的资源包
|
||||||
|
var defaultPackage = YooAssets.CreateAssetsPackage("DefaultPackage");
|
||||||
|
|
||||||
|
// 设置该资源包为默认的资源包,可以使用YooAssets相关加载接口加载该资源包内容。
|
||||||
|
YooAssets.SetDefaultAssetsPackage(defaultPackage);
|
||||||
```
|
```
|
||||||
|
|
||||||
资源系统的运行模式支持三种:编辑器模拟模式,单机运行模式,联机运行模式。
|
资源系统的运行模式支持三种:编辑器模拟模式,单机运行模式,联机运行模式。
|
||||||
@@ -17,10 +24,10 @@ YooAssets.Initialize();
|
|||||||
````c#
|
````c#
|
||||||
private IEnumerator InitializeYooAsset()
|
private IEnumerator InitializeYooAsset()
|
||||||
{
|
{
|
||||||
var initParameters = new YooAssets.EditorSimulateModeParameters();
|
var initParameters = new EditorSimulateModeParameters();
|
||||||
initParameters.LocationServices = new DefaultLocationServices("Assets/GameRes");
|
initParameters.LocationServices = new DefaultLocationServices("Assets/GameRes");
|
||||||
initParameters.SimulatePatchManifestPath = EditorSimulateModeHelper.SimulateBuild("DefaultPackage", false);
|
initParameters.SimulatePatchManifestPath = EditorSimulateModeHelper.SimulateBuild("DefaultPackage");
|
||||||
yield return YooAssets.InitializeAsync(initParameters);
|
yield return defaultPackage.InitializeAsync(initParameters);
|
||||||
}
|
}
|
||||||
````
|
````
|
||||||
|
|
||||||
@@ -33,9 +40,9 @@ private IEnumerator InitializeYooAsset()
|
|||||||
````c#
|
````c#
|
||||||
private IEnumerator InitializeYooAsset()
|
private IEnumerator InitializeYooAsset()
|
||||||
{
|
{
|
||||||
var initParameters = new YooAssets.OfflinePlayModeParameters();
|
var initParameters = new OfflinePlayModeParameters();
|
||||||
initParameters.LocationServices = new DefaultLocationServices("Assets/GameRes");
|
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接口的实例类。
|
- DecryptionServices : 如果资源包在构建的时候有加密,需要提供实现IDecryptionServices接口的实例类。
|
||||||
|
|
||||||
|
- QueryServices:内置资源查询服务接口。
|
||||||
|
|
||||||
- DefaultHostServer : 默认的资源服务器IP地址。
|
- DefaultHostServer : 默认的资源服务器IP地址。
|
||||||
|
|
||||||
- FallbackHostServer : 备用的资源服务器IP地址。
|
- FallbackHostServer : 备用的资源服务器IP地址。
|
||||||
|
|
||||||
- VerifyLevel : 下载文件校验等级
|
|
||||||
|
|
||||||
````c#
|
````c#
|
||||||
private IEnumerator InitializeYooAsset()
|
private IEnumerator InitializeYooAsset()
|
||||||
{
|
{
|
||||||
var initParameters = new YooAssets.HostPlayModeParameters();
|
var initParameters = new HostPlayModeParameters();
|
||||||
initParameters.LocationServices = new DefaultLocationServices("Assets/GameRes");
|
initParameters.LocationServices = new DefaultLocationServices("Assets/GameRes");
|
||||||
initParameters.DecryptionServices = new BundleDecryptionServices();
|
initParameters.DecryptionServices = new BundleDecryptionServices();
|
||||||
initParameters.QueryServices = new QueryStreamingAssetsServices();
|
initParameters.QueryServices = new QueryStreamingAssetsServices();
|
||||||
initParameters.DefaultHostServer = "http://127.0.0.1/CDN1/Android/v1.0";
|
initParameters.DefaultHostServer = "http://127.0.0.1/CDN1/Android/v1.0";
|
||||||
initParameters.FallbackHostServer = "http://127.0.0.1/CDN2/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)
|
public bool QueryStreamingAssets(string fileName)
|
||||||
{
|
{
|
||||||
// 注意:使用了BetterStreamingAssets插件
|
// 注意:使用了BetterStreamingAssets插件
|
||||||
return BetterStreamingAssets.FileExists($"YooAssets/{fileName}");
|
string buildinFolderName = YooAssets.GetStreamingAssetBuildinFolderName();
|
||||||
|
return BetterStreamingAssets.FileExists($"{buildinFolderName}/{fileName}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
````
|
````
|
||||||
|
|||||||
@@ -9,7 +9,8 @@
|
|||||||
````c#
|
````c#
|
||||||
private IEnumerator UpdateStaticVersion()
|
private IEnumerator UpdateStaticVersion()
|
||||||
{
|
{
|
||||||
UpdateStaticVersionOperation operation = YooAssets.UpdateStaticVersionAsync();
|
var package = YooAssets.GetAssetsPackage("DefaultPackage");
|
||||||
|
UpdateStaticVersionOperation operation = package.UpdateStaticVersionAsync();
|
||||||
yield return operation;
|
yield return operation;
|
||||||
|
|
||||||
if (operation.Status == EOperationStatus.Succeed)
|
if (operation.Status == EOperationStatus.Succeed)
|
||||||
@@ -33,7 +34,8 @@ private IEnumerator UpdateStaticVersion()
|
|||||||
````c#
|
````c#
|
||||||
private IEnumerator UpdatePatchManifest()
|
private IEnumerator UpdatePatchManifest()
|
||||||
{
|
{
|
||||||
UpdateManifestOperation operation = YooAssets.UpdateManifestAsync(packageCRC);
|
var package = YooAssets.GetAssetsPackage("DefaultPackage");
|
||||||
|
UpdateManifestOperation operation = package.UpdateManifestAsync(packageCRC);
|
||||||
yield return operation;
|
yield return operation;
|
||||||
|
|
||||||
if (operation.Status == EOperationStatus.Succeed)
|
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 downloadingMaxNum = 10;
|
||||||
int failedTryAgain = 3;
|
int failedTryAgain = 3;
|
||||||
DownloaderOperation downloader = YooAssets.CreatePatchDownloader(downloadingMaxNum, failedTryAgain);
|
int timeout = 60;
|
||||||
|
var downloader = YooAssets.CreatePatchDownloader(downloadingMaxNum, failedTryAgain, timeout);
|
||||||
|
|
||||||
//没有需要下载的资源
|
//没有需要下载的资源
|
||||||
if (downloader.TotalDownloadCount == 0)
|
if (downloader.TotalDownloadCount == 0)
|
||||||
@@ -114,7 +117,8 @@ IEnumerator Download()
|
|||||||
````c#
|
````c#
|
||||||
private IEnumerator UpdateStaticVersion()
|
private IEnumerator UpdateStaticVersion()
|
||||||
{
|
{
|
||||||
UpdateStaticVersionOperation operation = YooAssets.UpdateStaticVersionAsync(10);
|
var package = YooAssets.GetAssetsPackage("DefaultPackage");
|
||||||
|
UpdateStaticVersionOperation operation = package.UpdateStaticVersionAsync(10);
|
||||||
yield return operation;
|
yield return operation;
|
||||||
if (operation.Status == EOperationStatus.Succeed)
|
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;
|
yield return operation2;
|
||||||
if (operation2.Status == EOperationStatus.Succeed)
|
if (operation2.Status == EOperationStatus.Succeed)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -18,9 +18,9 @@
|
|||||||
```c#
|
```c#
|
||||||
// 以工程内的音频文件为例:"Assets/GameRes/Audio/bgMusic.mp3"
|
// 以工程内的音频文件为例:"Assets/GameRes/Audio/bgMusic.mp3"
|
||||||
// 设定资源路径的根目录为:"Assets/GameRes",后续加载的资源定位地址填写相对路径:"Audio/bgMusic"
|
// 设定资源路径的根目录为:"Assets/GameRes",后续加载的资源定位地址填写相对路径:"Audio/bgMusic"
|
||||||
var createParameters = new YooAssets.EditorSimulateModeParameters();
|
var createParameters = new EditorSimulateModeParameters();
|
||||||
createParameters.LocationServices = new DefaultLocationServices("Assets/GameRes");
|
createParameters.LocationServices = new DefaultLocationServices("Assets/GameRes");
|
||||||
yield return YooAssets.InitializeAsync(createParameters);
|
yield return defaultPackage.InitializeAsync(createParameters);
|
||||||
......
|
......
|
||||||
YooAssets.LoadAssetAsync<AudioClip>("Audio/bgMusic");
|
YooAssets.LoadAssetAsync<AudioClip>("Audio/bgMusic");
|
||||||
```
|
```
|
||||||
@@ -31,9 +31,9 @@ YooAssets.LoadAssetAsync<AudioClip>("Audio/bgMusic");
|
|||||||
// 以工程内的音频文件为例:"Assets/GameRes/Audio/bgMusic.mp3"
|
// 以工程内的音频文件为例:"Assets/GameRes/Audio/bgMusic.mp3"
|
||||||
// 需要在资源配置界面启用可寻址功能(Enable Addressable)。
|
// 需要在资源配置界面启用可寻址功能(Enable Addressable)。
|
||||||
// 配置界面的可寻址规则为AddressByFileName,那么资源定位地址填写文件名称:"bgMusic"
|
// 配置界面的可寻址规则为AddressByFileName,那么资源定位地址填写文件名称:"bgMusic"
|
||||||
var createParameters = new YooAssets.EditorSimulateModeParameters();
|
var createParameters = new EditorSimulateModeParameters();
|
||||||
createParameters.LocationServices = new AddressLocationServices();
|
createParameters.LocationServices = new AddressLocationServices();
|
||||||
yield return YooAssets.InitializeAsync(createParameters);
|
yield return defaultPackage.InitializeAsync(createParameters);
|
||||||
......
|
......
|
||||||
YooAssets.LoadAssetAsync<AudioClip>("bgMusic");
|
YooAssets.LoadAssetAsync<AudioClip>("bgMusic");
|
||||||
````
|
````
|
||||||
@@ -104,7 +104,8 @@ IEnumerator Start()
|
|||||||
````c#
|
````c#
|
||||||
private void UnloadAssets()
|
private void UnloadAssets()
|
||||||
{
|
{
|
||||||
YooAssets.UnloadUnusedAssets();
|
var package = YooAssets.GetAssetsPackage("DefaultPackage");
|
||||||
|
package.UnloadUnusedAssets();
|
||||||
}
|
}
|
||||||
````
|
````
|
||||||
|
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ go.transform.localScale = Vector3.one;
|
|||||||
在运行游戏之前,请保证资源包可以构建成功!
|
在运行游戏之前,请保证资源包可以构建成功!
|
||||||
|
|
||||||
```c#
|
```c#
|
||||||
public static YooAssetPackage AssetPackage;
|
public static AssetPackage DefaultPackage;
|
||||||
|
|
||||||
IEnumerator Start()
|
IEnumerator Start()
|
||||||
{
|
{
|
||||||
@@ -73,24 +73,24 @@ IEnumerator Start()
|
|||||||
YooAssets.Initialize();
|
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;
|
yield return operation;
|
||||||
|
|
||||||
// 下载更新文件
|
// 下载更新文件
|
||||||
var downloader = AssetPackage.CreatePatchDownloader(downloadingMaxNum, failedTryAgain);
|
var downloader = DefaultPackage.CreatePatchDownloader(downloadingMaxNum, failedTryAgain);
|
||||||
downloader.BeginDownload();
|
downloader.BeginDownload();
|
||||||
yield return downloader;
|
yield return downloader;
|
||||||
|
|
||||||
// 加载资源对象
|
// 加载资源对象
|
||||||
var assetHandle = AssetPackage.LoadAssetAsync("Assets/GameRes/npc.prefab");
|
var assetHandle = DefaultPackage.LoadAssetAsync("Assets/GameRes/npc.prefab");
|
||||||
yield return assetHandle;
|
yield return assetHandle;
|
||||||
......
|
......
|
||||||
}
|
}
|
||||||
|
|||||||
27
Docs/FAQ.md
27
Docs/FAQ.md
@@ -17,6 +17,33 @@ windows平台添加命令: **-force-gles**
|
|||||||
|
|
||||||
YooAsset依赖于ScriptBuildPipeline(SBP),在PackageManager里找到SBP插件安装就可以了。
|
YooAsset依赖于ScriptBuildPipeline(SBP),在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支持Unity2018吗
|
||||||
|
|
||||||
YooAsset分俩部分,编辑器代码和运行时代码。因为工具界面是使用UIElements编写的,所以在Unity2019以前的版本是使用不了界面化工具。但是这并没有影响我们使用YooAsset,以下提供一种解决方案。
|
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 |
Reference in New Issue
Block a user