mirror of
https://github.com/tuyoogame/YooAsset.git
synced 2026-05-14 19:40:47 +00:00
Compare commits
17 Commits
4c717b69db
...
1.5.6-prev
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ca89113c67 | ||
|
|
29d840b168 | ||
|
|
41d1586109 | ||
|
|
8d6a1d0066 | ||
|
|
bdfaaa0973 | ||
|
|
30854e4b93 | ||
|
|
54d89d957a | ||
|
|
ade97605f9 | ||
|
|
bcb6443300 | ||
|
|
11386a7ec2 | ||
|
|
6fc45a758c | ||
|
|
dcdf41b7c2 | ||
|
|
1aaf569396 | ||
|
|
101960f6d8 | ||
|
|
49b188964c | ||
|
|
5539d81c93 | ||
|
|
ac3154e2ae |
@@ -2,6 +2,56 @@
|
|||||||
|
|
||||||
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.5.6-preview] - 2023-09-26
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- (#172) 修复包裹初始化后,package的状态不正确的问题。
|
||||||
|
|
||||||
|
## [1.5.5-preview] - 2023-09-25
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- (#96) 修复了异步操作任务的完成回调在业务层触发异常时无法正常完成的问题。
|
||||||
|
- (#156) 修复了多个Package存在时,服务器请求地址请求顺序不对的问题。
|
||||||
|
- (#163) 修复了Unity2019版本编译报错的问题。
|
||||||
|
- (#167) 修复了初始化时每次都会提示文件验证失败日志。
|
||||||
|
- (#171) 修复了IsNeedDownloadFromRemote里缺少判断依赖的资源是否下载 。
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- 资源收集器里增加了AddressDisable规则。
|
||||||
|
|
||||||
|
- 资源收集器里FilterRuleData结构体增加了多个备选字段。
|
||||||
|
|
||||||
|
```c#
|
||||||
|
public struct FilterRuleData
|
||||||
|
{
|
||||||
|
public string AssetPath;
|
||||||
|
public string CollectPath;
|
||||||
|
public string GroupName;
|
||||||
|
public string UserData;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- 可以设置自定义参数DefaultYooFolderName。
|
||||||
|
|
||||||
|
- 资源配置界面的分组不激活时,不再进行配置检测。
|
||||||
|
|
||||||
|
- SBP构建管线增加新构建参数用于修复图集资源冗余问题。
|
||||||
|
|
||||||
|
```c#
|
||||||
|
public class SBPBuildParameters
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 修复图集资源冗余问题
|
||||||
|
/// </summary>
|
||||||
|
public bool FixSpriteAtlasRedundancy = false;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
## [1.5.4-preview] - 2023-08-25
|
## [1.5.4-preview] - 2023-08-25
|
||||||
|
|
||||||
优化了资源清单文件构建速度(极大提升构建体验)(感谢yingnierxiao同学)。
|
优化了资源清单文件构建速度(极大提升构建体验)(感谢yingnierxiao同学)。
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ namespace YooAsset.Editor
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public static string GetDefaultStreamingAssetsRoot()
|
public static string GetDefaultStreamingAssetsRoot()
|
||||||
{
|
{
|
||||||
return $"{Application.dataPath}/StreamingAssets/{YooAssetSettings.DefaultYooFolderName}/";
|
return $"{Application.dataPath}/StreamingAssets/{YooAssetSettingsData.Setting.DefaultYooFolderName}/";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -28,6 +28,11 @@ namespace YooAsset.Editor
|
|||||||
/// 缓存服务器端口
|
/// 缓存服务器端口
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int CacheServerPort;
|
public int CacheServerPort;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 修复图集资源冗余问题
|
||||||
|
/// </summary>
|
||||||
|
public bool FixSpriteAtlasRedundancy = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -8,63 +8,61 @@ using System.Linq;
|
|||||||
|
|
||||||
namespace UnityEditor.Build.Pipeline.Tasks
|
namespace UnityEditor.Build.Pipeline.Tasks
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Ref https://zhuanlan.zhihu.com/p/586918159
|
/// Ref https://zhuanlan.zhihu.com/p/586918159
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class RemoveSpriteAtlasRedundancy : IBuildTask
|
public class RemoveSpriteAtlasRedundancy : IBuildTask
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
public int Version => 1;
|
||||||
public int Version => 1;
|
|
||||||
|
|
||||||
[InjectContext]
|
[InjectContext]
|
||||||
IBundleWriteData writeDataParam;
|
IBundleWriteData writeDataParam;
|
||||||
|
|
||||||
/// <inheritdoc />
|
public ReturnCode Run()
|
||||||
public ReturnCode Run()
|
{
|
||||||
{
|
#if UNITY_2020_3_OR_NEWER
|
||||||
BundleWriteData writeData = (BundleWriteData)writeDataParam;
|
BundleWriteData writeData = (BundleWriteData)writeDataParam;
|
||||||
|
|
||||||
// 所有图集散图的 guid 集合
|
// 图集引用的精灵图片集合
|
||||||
HashSet<GUID> spriteGuids = new HashSet<GUID>();
|
HashSet<GUID> spriteGuids = new HashSet<GUID>();
|
||||||
|
foreach (var pair in writeData.FileToObjects)
|
||||||
|
{
|
||||||
|
foreach (ObjectIdentifier objectIdentifier in pair.Value)
|
||||||
|
{
|
||||||
|
var assetPath = AssetDatabase.GUIDToAssetPath(objectIdentifier.guid);
|
||||||
|
var assetType = AssetDatabase.GetMainAssetTypeAtPath(assetPath);
|
||||||
|
if (assetType == typeof(SpriteAtlas))
|
||||||
|
{
|
||||||
|
var spritePaths = AssetDatabase.GetDependencies(assetPath, false);
|
||||||
|
foreach (string spritePath in spritePaths)
|
||||||
|
{
|
||||||
|
GUID spriteGuild = AssetDatabase.GUIDFromAssetPath(spritePath);
|
||||||
|
spriteGuids.Add(spriteGuild);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 遍历资源包里的资源记录其中图集的散图 guid
|
// 移除图集引用的精力图片对象
|
||||||
foreach (var pair in writeData.FileToObjects)
|
foreach (var pair in writeData.FileToObjects)
|
||||||
{
|
{
|
||||||
foreach (ObjectIdentifier objectIdentifier in pair.Value)
|
List<ObjectIdentifier> objectIdentifiers = pair.Value;
|
||||||
{
|
for (int i = objectIdentifiers.Count - 1; i >= 0; i--)
|
||||||
string path = AssetDatabase.GUIDToAssetPath(objectIdentifier.guid);
|
{
|
||||||
Object asset = AssetDatabase.LoadAssetAtPath<Object>(path);
|
ObjectIdentifier objectIdentifier = objectIdentifiers[i];
|
||||||
if (asset is SpriteAtlas)
|
if (spriteGuids.Contains(objectIdentifier.guid))
|
||||||
{
|
{
|
||||||
List<string> spritePaths = AssetDatabase.GetDependencies(path, false).ToList();
|
if (objectIdentifier.localIdentifierInFile == 2800000)
|
||||||
foreach (string spritePath in spritePaths)
|
{
|
||||||
{
|
// 删除图集散图的冗余纹理
|
||||||
GUID spriteGuild = AssetDatabase.GUIDFromAssetPath(spritePath);
|
objectIdentifiers.RemoveAt(i);
|
||||||
spriteGuids.Add(spriteGuild);
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
#endif
|
||||||
|
|
||||||
// 将 writeData.FileToObjects 包含的图集散图的 texture 删掉避免冗余
|
return ReturnCode.Success;
|
||||||
foreach (var pair in writeData.FileToObjects)
|
}
|
||||||
{
|
}
|
||||||
List<ObjectIdentifier> objectIdentifiers = pair.Value;
|
|
||||||
for (int i = objectIdentifiers.Count - 1; i >= 0; i--)
|
|
||||||
{
|
|
||||||
ObjectIdentifier objectIdentifier = objectIdentifiers[i];
|
|
||||||
if (spriteGuids.Contains(objectIdentifier.guid))
|
|
||||||
{
|
|
||||||
if (objectIdentifier.localIdentifierInFile == 2800000)
|
|
||||||
{
|
|
||||||
// 删除图集散图的冗余 texture
|
|
||||||
objectIdentifiers.RemoveAt(i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return ReturnCode.Success;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -9,10 +9,10 @@ namespace UnityEditor.Build.Pipeline.Tasks
|
|||||||
{
|
{
|
||||||
public static class SBPBuildTasks
|
public static class SBPBuildTasks
|
||||||
{
|
{
|
||||||
public static IList<IBuildTask> Create(string builtInShaderBundleName)
|
public static IList<IBuildTask> Create(bool fixSpriteAtlasRedundancy, string builtInShaderBundleName)
|
||||||
{
|
{
|
||||||
var buildTasks = new List<IBuildTask>();
|
var buildTasks = new List<IBuildTask>();
|
||||||
|
|
||||||
// Setup
|
// Setup
|
||||||
buildTasks.Add(new SwitchToBuildPlatform());
|
buildTasks.Add(new SwitchToBuildPlatform());
|
||||||
buildTasks.Add(new RebuildSpriteAtlasCache());
|
buildTasks.Add(new RebuildSpriteAtlasCache());
|
||||||
@@ -33,20 +33,21 @@ namespace UnityEditor.Build.Pipeline.Tasks
|
|||||||
|
|
||||||
// Packing
|
// Packing
|
||||||
buildTasks.Add(new GenerateBundlePacking());
|
buildTasks.Add(new GenerateBundlePacking());
|
||||||
buildTasks.Add(new RemoveSpriteAtlasRedundancy()); // Fix for SpriteAtlas Redundancy
|
if (fixSpriteAtlasRedundancy)
|
||||||
|
buildTasks.Add(new RemoveSpriteAtlasRedundancy());
|
||||||
buildTasks.Add(new UpdateBundleObjectLayout());
|
buildTasks.Add(new UpdateBundleObjectLayout());
|
||||||
buildTasks.Add(new GenerateBundleCommands());
|
buildTasks.Add(new GenerateBundleCommands());
|
||||||
buildTasks.Add(new GenerateSubAssetPathMaps());
|
buildTasks.Add(new GenerateSubAssetPathMaps());
|
||||||
buildTasks.Add(new GenerateBundleMaps());
|
buildTasks.Add(new GenerateBundleMaps());
|
||||||
buildTasks.Add(new PostPackingCallback());
|
buildTasks.Add(new PostPackingCallback());
|
||||||
|
|
||||||
// Writing
|
// Writing
|
||||||
buildTasks.Add(new WriteSerializedFiles());
|
buildTasks.Add(new WriteSerializedFiles());
|
||||||
buildTasks.Add(new ArchiveAndCompressBundles());
|
buildTasks.Add(new ArchiveAndCompressBundles());
|
||||||
buildTasks.Add(new AppendBundleHash());
|
buildTasks.Add(new AppendBundleHash());
|
||||||
buildTasks.Add(new GenerateLinkXml());
|
buildTasks.Add(new GenerateLinkXml());
|
||||||
buildTasks.Add(new PostWritingCallback());
|
buildTasks.Add(new PostWritingCallback());
|
||||||
|
|
||||||
return buildTasks;
|
return buildTasks;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ namespace YooAsset.Editor
|
|||||||
// 开始构建
|
// 开始构建
|
||||||
IBundleBuildResults buildResults;
|
IBundleBuildResults buildResults;
|
||||||
var buildParameters = buildParametersContext.GetSBPBuildParameters();
|
var buildParameters = buildParametersContext.GetSBPBuildParameters();
|
||||||
var taskList = SBPBuildTasks.Create(buildMapContext.Command.ShadersBundleName);
|
var taskList = SBPBuildTasks.Create(buildParametersContext.Parameters.SBPParameters.FixSpriteAtlasRedundancy, buildMapContext.Command.ShadersBundleName);
|
||||||
ReturnCode exitCode = ContentPipeline.BuildAssetBundles(buildParameters, buildContent, out buildResults, taskList);
|
ReturnCode exitCode = ContentPipeline.BuildAssetBundles(buildParameters, buildContent, out buildResults, taskList);
|
||||||
if (exitCode < 0)
|
if (exitCode < 0)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -166,7 +166,7 @@ namespace YooAsset.Editor
|
|||||||
string[] findAssets = EditorTools.FindAssets(EAssetSearchType.All, collectDirectory);
|
string[] findAssets = EditorTools.FindAssets(EAssetSearchType.All, collectDirectory);
|
||||||
foreach (string assetPath in findAssets)
|
foreach (string assetPath in findAssets)
|
||||||
{
|
{
|
||||||
if (IsValidateAsset(assetPath, isRawFilePackRule) && IsCollectAsset(assetPath))
|
if (IsValidateAsset(assetPath, isRawFilePackRule) && IsCollectAsset(group, assetPath))
|
||||||
{
|
{
|
||||||
if (result.ContainsKey(assetPath) == false)
|
if (result.ContainsKey(assetPath) == false)
|
||||||
{
|
{
|
||||||
@@ -183,7 +183,7 @@ namespace YooAsset.Editor
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
string assetPath = CollectPath;
|
string assetPath = CollectPath;
|
||||||
if (IsValidateAsset(assetPath, isRawFilePackRule) && IsCollectAsset(assetPath))
|
if (IsValidateAsset(assetPath, isRawFilePackRule) && IsCollectAsset(group, assetPath))
|
||||||
{
|
{
|
||||||
var collectAssetInfo = CreateCollectAssetInfo(command, group, assetPath, isRawFilePackRule);
|
var collectAssetInfo = CreateCollectAssetInfo(command, group, assetPath, isRawFilePackRule);
|
||||||
result.Add(assetPath, collectAssetInfo);
|
result.Add(assetPath, collectAssetInfo);
|
||||||
@@ -204,6 +204,8 @@ namespace YooAsset.Editor
|
|||||||
{
|
{
|
||||||
string address = collectInfoPair.Value.Address;
|
string address = collectInfoPair.Value.Address;
|
||||||
string assetPath = collectInfoPair.Value.AssetPath;
|
string assetPath = collectInfoPair.Value.AssetPath;
|
||||||
|
if (string.IsNullOrEmpty(address))
|
||||||
|
continue;
|
||||||
|
|
||||||
if (address.StartsWith("Assets/") || address.StartsWith("assets/"))
|
if (address.StartsWith("Assets/") || address.StartsWith("assets/"))
|
||||||
throw new Exception($"The address can not set asset path in collector : {CollectPath} \nAssetPath: {assetPath}");
|
throw new Exception($"The address can not set asset path in collector : {CollectPath} \nAssetPath: {assetPath}");
|
||||||
@@ -292,11 +294,11 @@ namespace YooAsset.Editor
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
private bool IsCollectAsset(string assetPath)
|
private bool IsCollectAsset(AssetBundleCollectorGroup group, string assetPath)
|
||||||
{
|
{
|
||||||
// 根据规则设置过滤资源文件
|
// 根据规则设置过滤资源文件
|
||||||
IFilterRule filterRuleInstance = AssetBundleCollectorSettingData.GetFilterRuleInstance(FilterRuleName);
|
IFilterRule filterRuleInstance = AssetBundleCollectorSettingData.GetFilterRuleInstance(FilterRuleName);
|
||||||
return filterRuleInstance.IsCollectAsset(new FilterRuleData(assetPath));
|
return filterRuleInstance.IsCollectAsset(new FilterRuleData(assetPath, CollectPath, group.GroupName, UserData));
|
||||||
}
|
}
|
||||||
private string GetAddress(CollectCommand command, AssetBundleCollectorGroup group, string assetPath)
|
private string GetAddress(CollectCommand command, AssetBundleCollectorGroup group, string assetPath)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -43,7 +43,10 @@ namespace YooAsset.Editor
|
|||||||
{
|
{
|
||||||
if (AssetBundleCollectorSettingData.HasActiveRuleName(ActiveRuleName) == false)
|
if (AssetBundleCollectorSettingData.HasActiveRuleName(ActiveRuleName) == false)
|
||||||
throw new Exception($"Invalid {nameof(IActiveRule)} class type : {ActiveRuleName} in group : {GroupName}");
|
throw new Exception($"Invalid {nameof(IActiveRule)} class type : {ActiveRuleName} in group : {GroupName}");
|
||||||
|
|
||||||
|
// 当分组不是激活状态时,直接不进行检测
|
||||||
|
if (ActiveRuleName == nameof(DisableGroup)) return;
|
||||||
|
|
||||||
foreach (var collector in Collectors)
|
foreach (var collector in Collectors)
|
||||||
{
|
{
|
||||||
collector.CheckConfigError();
|
collector.CheckConfigError();
|
||||||
@@ -103,6 +106,9 @@ namespace YooAsset.Editor
|
|||||||
{
|
{
|
||||||
string address = collectInfoPair.Value.Address;
|
string address = collectInfoPair.Value.Address;
|
||||||
string assetPath = collectInfoPair.Value.AssetPath;
|
string assetPath = collectInfoPair.Value.AssetPath;
|
||||||
|
if (string.IsNullOrEmpty(address))
|
||||||
|
continue;
|
||||||
|
|
||||||
if (addressTemper.TryGetValue(address, out var existed) == false)
|
if (addressTemper.TryGetValue(address, out var existed) == false)
|
||||||
addressTemper.Add(address, assetPath);
|
addressTemper.Add(address, assetPath);
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -83,6 +83,9 @@ namespace YooAsset.Editor
|
|||||||
{
|
{
|
||||||
string address = collectInfoPair.Value.Address;
|
string address = collectInfoPair.Value.Address;
|
||||||
string assetPath = collectInfoPair.Value.AssetPath;
|
string assetPath = collectInfoPair.Value.AssetPath;
|
||||||
|
if (string.IsNullOrEmpty(address))
|
||||||
|
continue;
|
||||||
|
|
||||||
if (addressTemper.TryGetValue(address, out var existed) == false)
|
if (addressTemper.TryGetValue(address, out var existed) == false)
|
||||||
addressTemper.Add(address, assetPath);
|
addressTemper.Add(address, assetPath);
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -94,7 +94,8 @@ namespace YooAsset.Editor
|
|||||||
typeof(AddressByFileName),
|
typeof(AddressByFileName),
|
||||||
typeof(AddressByFilePath),
|
typeof(AddressByFilePath),
|
||||||
typeof(AddressByFolderAndFileName),
|
typeof(AddressByFolderAndFileName),
|
||||||
typeof(AddressByGroupAndFileName)
|
typeof(AddressByGroupAndFileName),
|
||||||
|
typeof(AddressDisable)
|
||||||
};
|
};
|
||||||
|
|
||||||
var customTypes = EditorTools.GetAssignableTypes(typeof(IAddressRule));
|
var customTypes = EditorTools.GetAssignableTypes(typeof(IAddressRule));
|
||||||
|
|||||||
@@ -333,6 +333,7 @@ namespace YooAsset.Editor
|
|||||||
_showEditorAliasToggle.SetValueWithoutNotify(AssetBundleCollectorSettingData.Setting.ShowEditorAlias);
|
_showEditorAliasToggle.SetValueWithoutNotify(AssetBundleCollectorSettingData.Setting.ShowEditorAlias);
|
||||||
|
|
||||||
// 警示框
|
// 警示框
|
||||||
|
#if UNITY_2020_3_OR_NEWER
|
||||||
_helpBoxContainer.Clear();
|
_helpBoxContainer.Clear();
|
||||||
if (_enableAddressableToogle.value && _locationToLowerToogle.value)
|
if (_enableAddressableToogle.value && _locationToLowerToogle.value)
|
||||||
{
|
{
|
||||||
@@ -348,6 +349,7 @@ namespace YooAsset.Editor
|
|||||||
_helpBoxContainer.style.display = DisplayStyle.Flex;
|
_helpBoxContainer.style.display = DisplayStyle.Flex;
|
||||||
else
|
else
|
||||||
_helpBoxContainer.style.display = DisplayStyle.None;
|
_helpBoxContainer.style.display = DisplayStyle.None;
|
||||||
|
#endif
|
||||||
|
|
||||||
// 设置栏
|
// 设置栏
|
||||||
if (_showSettings)
|
if (_showSettings)
|
||||||
|
|||||||
@@ -4,10 +4,16 @@ namespace YooAsset.Editor
|
|||||||
public struct FilterRuleData
|
public struct FilterRuleData
|
||||||
{
|
{
|
||||||
public string AssetPath;
|
public string AssetPath;
|
||||||
|
public string CollectPath;
|
||||||
public FilterRuleData(string assetPath)
|
public string GroupName;
|
||||||
|
public string UserData;
|
||||||
|
|
||||||
|
public FilterRuleData(string assetPath, string collectPath, string groupName, string userData)
|
||||||
{
|
{
|
||||||
AssetPath = assetPath;
|
AssetPath = assetPath;
|
||||||
|
CollectPath = collectPath;
|
||||||
|
GroupName = groupName;
|
||||||
|
UserData = userData;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,13 +8,6 @@ namespace YooAsset.Editor
|
|||||||
public string GroupName;
|
public string GroupName;
|
||||||
public string UserData;
|
public string UserData;
|
||||||
|
|
||||||
public PackRuleData(string assetPath)
|
|
||||||
{
|
|
||||||
AssetPath = assetPath;
|
|
||||||
CollectPath = string.Empty;
|
|
||||||
GroupName = string.Empty;
|
|
||||||
UserData = string.Empty;
|
|
||||||
}
|
|
||||||
public PackRuleData(string assetPath, string collectPath, string groupName, string userData)
|
public PackRuleData(string assetPath, string collectPath, string groupName, string userData)
|
||||||
{
|
{
|
||||||
AssetPath = assetPath;
|
AssetPath = assetPath;
|
||||||
|
|||||||
@@ -2,6 +2,15 @@
|
|||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
|
[DisplayName("定位地址: 禁用")]
|
||||||
|
public class AddressDisable : IAddressRule
|
||||||
|
{
|
||||||
|
string IAddressRule.GetAssetAddress(AddressRuleData data)
|
||||||
|
{
|
||||||
|
return string.Empty;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
[DisplayName("定位地址: 文件名")]
|
[DisplayName("定位地址: 文件名")]
|
||||||
public class AddressByFileName : IAddressRule
|
public class AddressByFileName : IAddressRule
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
private static string CreateDefaultBuildinRoot()
|
private static string CreateDefaultBuildinRoot()
|
||||||
{
|
{
|
||||||
return PathUtility.Combine(UnityEngine.Application.streamingAssetsPath, YooAssetSettings.DefaultYooFolderName);
|
return PathUtility.Combine(UnityEngine.Application.streamingAssetsPath, YooAssetSettingsData.Setting.DefaultYooFolderName);
|
||||||
}
|
}
|
||||||
private static string CreateDefaultSandboxRoot()
|
private static string CreateDefaultSandboxRoot()
|
||||||
{
|
{
|
||||||
@@ -54,11 +54,11 @@ namespace YooAsset
|
|||||||
// 注意:为了方便调试查看,编辑器下把存储目录放到项目里。
|
// 注意:为了方便调试查看,编辑器下把存储目录放到项目里。
|
||||||
string projectPath = Path.GetDirectoryName(UnityEngine.Application.dataPath);
|
string projectPath = Path.GetDirectoryName(UnityEngine.Application.dataPath);
|
||||||
projectPath = PathUtility.RegularPath(projectPath);
|
projectPath = PathUtility.RegularPath(projectPath);
|
||||||
return PathUtility.Combine(projectPath, YooAssetSettings.DefaultYooFolderName);
|
return PathUtility.Combine(projectPath, YooAssetSettingsData.Setting.DefaultYooFolderName);
|
||||||
#elif UNITY_STANDALONE
|
#elif UNITY_STANDALONE
|
||||||
return PathUtility.Combine(UnityEngine.Application.dataPath, YooAssetSettings.DefaultYooFolderName);
|
return PathUtility.Combine(UnityEngine.Application.dataPath, YooAssetSettingsData.Setting.DefaultYooFolderName);
|
||||||
#else
|
#else
|
||||||
return PathUtility.Combine(UnityEngine.Application.persistentDataPath, YooAssetSettings.DefaultYooFolderName);
|
return PathUtility.Combine(UnityEngine.Application.persistentDataPath, YooAssetSettingsData.Setting.DefaultYooFolderName);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -28,14 +28,13 @@ namespace YooAsset
|
|||||||
|
|
||||||
public void DeleteFiles()
|
public void DeleteFiles()
|
||||||
{
|
{
|
||||||
if (File.Exists(DataFilePath))
|
try
|
||||||
{
|
{
|
||||||
File.Delete(DataFilePath);
|
Directory.Delete(FileRootPath, true);
|
||||||
}
|
}
|
||||||
|
catch (System.Exception e)
|
||||||
if (File.Exists(InfoFilePath))
|
|
||||||
{
|
{
|
||||||
File.Delete(InfoFilePath);
|
YooLogger.Warning($"Failed delete cache bundle folder : {e}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
36
Assets/YooAsset/Runtime/DownloadSystem/RequestHelper.cs
Normal file
36
Assets/YooAsset/Runtime/DownloadSystem/RequestHelper.cs
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace YooAsset
|
||||||
|
{
|
||||||
|
public class RequestHelper
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 记录网络请求失败事件的次数
|
||||||
|
/// </summary>
|
||||||
|
private static readonly Dictionary<string, int> _requestFailedRecorder = new Dictionary<string, int>(1000);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 记录请求失败事件
|
||||||
|
/// </summary>
|
||||||
|
public static void RecordRequestFailed(string packageName, string eventName)
|
||||||
|
{
|
||||||
|
string key = $"{packageName}_{eventName}";
|
||||||
|
if (_requestFailedRecorder.ContainsKey(key) == false)
|
||||||
|
_requestFailedRecorder.Add(key, 0);
|
||||||
|
_requestFailedRecorder[key]++;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取请求失败的次数
|
||||||
|
/// </summary>
|
||||||
|
public static int GetRequestFailedCount(string packageName, string eventName)
|
||||||
|
{
|
||||||
|
string key = $"{packageName}_{eventName}";
|
||||||
|
if (_requestFailedRecorder.ContainsKey(key) == false)
|
||||||
|
_requestFailedRecorder.Add(key, 0);
|
||||||
|
return _requestFailedRecorder[key];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
11
Assets/YooAsset/Runtime/DownloadSystem/RequestHelper.cs.meta
Normal file
11
Assets/YooAsset/Runtime/DownloadSystem/RequestHelper.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: ca9b2c6456d21bb4e9eecd9dc820a641
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -77,7 +77,7 @@ namespace YooAsset
|
|||||||
internal void SetFinish()
|
internal void SetFinish()
|
||||||
{
|
{
|
||||||
Progress = 1f;
|
Progress = 1f;
|
||||||
_callback?.Invoke(this);
|
_callback?.Invoke(this); //注意:如果完成回调内发生异常,会导致Task无限期等待
|
||||||
if (_taskCompletionSource != null)
|
if (_taskCompletionSource != null)
|
||||||
_taskCompletionSource.TrySetResult(null);
|
_taskCompletionSource.TrySetResult(null);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,8 +7,7 @@ namespace YooAsset
|
|||||||
internal class OperationSystem
|
internal class OperationSystem
|
||||||
{
|
{
|
||||||
private static readonly List<AsyncOperationBase> _operations = new List<AsyncOperationBase>(100);
|
private static readonly List<AsyncOperationBase> _operations = new List<AsyncOperationBase>(100);
|
||||||
private static readonly List<AsyncOperationBase> _addList = new List<AsyncOperationBase>(100);
|
private static readonly List<AsyncOperationBase> _newList = new List<AsyncOperationBase>(100);
|
||||||
private static readonly List<AsyncOperationBase> _removeList = new List<AsyncOperationBase>(100);
|
|
||||||
|
|
||||||
// 计时器相关
|
// 计时器相关
|
||||||
private static Stopwatch _watch;
|
private static Stopwatch _watch;
|
||||||
@@ -47,39 +46,26 @@ namespace YooAsset
|
|||||||
_frameTime = _watch.ElapsedMilliseconds;
|
_frameTime = _watch.ElapsedMilliseconds;
|
||||||
|
|
||||||
// 添加新的异步操作
|
// 添加新的异步操作
|
||||||
if (_addList.Count > 0)
|
if (_newList.Count > 0)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < _addList.Count; i++)
|
_operations.AddRange(_newList);
|
||||||
{
|
_newList.Clear();
|
||||||
var operation = _addList[i];
|
|
||||||
_operations.Add(operation);
|
|
||||||
}
|
|
||||||
_addList.Clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 更新所有的异步操作
|
// 更新所有的异步操作
|
||||||
foreach (var operation in _operations)
|
for (int i = _operations.Count - 1; i >= 0; i--)
|
||||||
{
|
{
|
||||||
if (IsBusy)
|
if (IsBusy)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
var operation = _operations[i];
|
||||||
operation.Update();
|
operation.Update();
|
||||||
if (operation.IsDone)
|
if (operation.IsDone)
|
||||||
{
|
{
|
||||||
_removeList.Add(operation);
|
_operations.RemoveAt(i);
|
||||||
operation.SetFinish();
|
operation.SetFinish(); //注意:如果业务端发生异常,保证异步操作提前移除。
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 移除已经完成的异步操作
|
|
||||||
if (_removeList.Count > 0)
|
|
||||||
{
|
|
||||||
foreach (var operation in _removeList)
|
|
||||||
{
|
|
||||||
_operations.Remove(operation);
|
|
||||||
}
|
|
||||||
_removeList.Clear();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -88,8 +74,7 @@ namespace YooAsset
|
|||||||
public static void DestroyAll()
|
public static void DestroyAll()
|
||||||
{
|
{
|
||||||
_operations.Clear();
|
_operations.Clear();
|
||||||
_addList.Clear();
|
_newList.Clear();
|
||||||
_removeList.Clear();
|
|
||||||
_watch = null;
|
_watch = null;
|
||||||
_frameTime = 0;
|
_frameTime = 0;
|
||||||
MaxTimeSlice = long.MaxValue;
|
MaxTimeSlice = long.MaxValue;
|
||||||
@@ -100,7 +85,7 @@ namespace YooAsset
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public static void StartOperation(AsyncOperationBase operation)
|
public static void StartOperation(AsyncOperationBase operation)
|
||||||
{
|
{
|
||||||
_addList.Add(operation);
|
_newList.Add(operation);
|
||||||
operation.SetStart();
|
operation.SetStart();
|
||||||
operation.Start();
|
operation.Start();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -154,10 +154,13 @@ namespace YooAsset
|
|||||||
if (Manifest.EnableAddressable)
|
if (Manifest.EnableAddressable)
|
||||||
{
|
{
|
||||||
string location = packageAsset.Address;
|
string location = packageAsset.Address;
|
||||||
if (Manifest.AssetPathMapping1.ContainsKey(location))
|
if (string.IsNullOrEmpty(location) == false)
|
||||||
throw new System.Exception($"Location have existed : {location}");
|
{
|
||||||
else
|
if (Manifest.AssetPathMapping1.ContainsKey(location))
|
||||||
Manifest.AssetPathMapping1.Add(location, packageAsset.AssetPath);
|
throw new System.Exception($"Location have existed : {location}");
|
||||||
|
else
|
||||||
|
Manifest.AssetPathMapping1.Add(location, packageAsset.AssetPath);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 填充AssetPathMapping2
|
// 填充AssetPathMapping2
|
||||||
|
|||||||
@@ -10,8 +10,7 @@ namespace YooAsset
|
|||||||
DownloadManifestFile,
|
DownloadManifestFile,
|
||||||
Done,
|
Done,
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int RequestCount = 0;
|
|
||||||
private readonly IRemoteServices _remoteServices;
|
private readonly IRemoteServices _remoteServices;
|
||||||
private readonly string _packageName;
|
private readonly string _packageName;
|
||||||
private readonly string _packageVersion;
|
private readonly string _packageVersion;
|
||||||
@@ -19,6 +18,7 @@ namespace YooAsset
|
|||||||
private UnityWebFileRequester _downloader1;
|
private UnityWebFileRequester _downloader1;
|
||||||
private UnityWebFileRequester _downloader2;
|
private UnityWebFileRequester _downloader2;
|
||||||
private ESteps _steps = ESteps.None;
|
private ESteps _steps = ESteps.None;
|
||||||
|
private int _requestCount = 0;
|
||||||
|
|
||||||
internal DownloadManifestOperation(IRemoteServices remoteServices, string packageName, string packageVersion, int timeout)
|
internal DownloadManifestOperation(IRemoteServices remoteServices, string packageName, string packageVersion, int timeout)
|
||||||
{
|
{
|
||||||
@@ -29,7 +29,7 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
internal override void Start()
|
internal override void Start()
|
||||||
{
|
{
|
||||||
RequestCount++;
|
_requestCount = RequestHelper.GetRequestFailedCount(_packageName, nameof(DownloadManifestOperation));
|
||||||
_steps = ESteps.DownloadPackageHashFile;
|
_steps = ESteps.DownloadPackageHashFile;
|
||||||
}
|
}
|
||||||
internal override void Update()
|
internal override void Update()
|
||||||
@@ -58,6 +58,7 @@ namespace YooAsset
|
|||||||
_steps = ESteps.Done;
|
_steps = ESteps.Done;
|
||||||
Status = EOperationStatus.Failed;
|
Status = EOperationStatus.Failed;
|
||||||
Error = _downloader1.GetError();
|
Error = _downloader1.GetError();
|
||||||
|
RequestHelper.RecordRequestFailed(_packageName, nameof(DownloadManifestOperation));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -88,6 +89,7 @@ namespace YooAsset
|
|||||||
_steps = ESteps.Done;
|
_steps = ESteps.Done;
|
||||||
Status = EOperationStatus.Failed;
|
Status = EOperationStatus.Failed;
|
||||||
Error = _downloader2.GetError();
|
Error = _downloader2.GetError();
|
||||||
|
RequestHelper.RecordRequestFailed(_packageName, nameof(DownloadManifestOperation));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -102,10 +104,10 @@ namespace YooAsset
|
|||||||
private string GetDownloadRequestURL(string fileName)
|
private string GetDownloadRequestURL(string fileName)
|
||||||
{
|
{
|
||||||
// 轮流返回请求地址
|
// 轮流返回请求地址
|
||||||
if (RequestCount % 2 == 0)
|
if (_requestCount % 2 == 0)
|
||||||
return _remoteServices.GetRemoteFallbackURL(fileName);
|
|
||||||
else
|
|
||||||
return _remoteServices.GetRemoteMainURL(fileName);
|
return _remoteServices.GetRemoteMainURL(fileName);
|
||||||
|
else
|
||||||
|
return _remoteServices.GetRemoteFallbackURL(fileName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -13,7 +13,6 @@ namespace YooAsset
|
|||||||
Done,
|
Done,
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int RequestCount = 0;
|
|
||||||
private readonly IRemoteServices _remoteServices;
|
private readonly IRemoteServices _remoteServices;
|
||||||
private readonly string _packageName;
|
private readonly string _packageName;
|
||||||
private readonly string _packageVersion;
|
private readonly string _packageVersion;
|
||||||
@@ -23,6 +22,7 @@ namespace YooAsset
|
|||||||
private DeserializeManifestOperation _deserializer;
|
private DeserializeManifestOperation _deserializer;
|
||||||
private byte[] _fileData;
|
private byte[] _fileData;
|
||||||
private ESteps _steps = ESteps.None;
|
private ESteps _steps = ESteps.None;
|
||||||
|
private int _requestCount = 0;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 加载的清单实例
|
/// 加载的清单实例
|
||||||
@@ -39,7 +39,7 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
internal override void Start()
|
internal override void Start()
|
||||||
{
|
{
|
||||||
RequestCount++;
|
_requestCount = RequestHelper.GetRequestFailedCount(_packageName, nameof(LoadRemoteManifestOperation));
|
||||||
_steps = ESteps.DownloadPackageHashFile;
|
_steps = ESteps.DownloadPackageHashFile;
|
||||||
}
|
}
|
||||||
internal override void Update()
|
internal override void Update()
|
||||||
@@ -90,6 +90,7 @@ namespace YooAsset
|
|||||||
_steps = ESteps.Done;
|
_steps = ESteps.Done;
|
||||||
Status = EOperationStatus.Failed;
|
Status = EOperationStatus.Failed;
|
||||||
Error = _downloader.GetError();
|
Error = _downloader.GetError();
|
||||||
|
RequestHelper.RecordRequestFailed(_packageName, nameof(LoadRemoteManifestOperation));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -141,10 +142,10 @@ namespace YooAsset
|
|||||||
private string GetDownloadRequestURL(string fileName)
|
private string GetDownloadRequestURL(string fileName)
|
||||||
{
|
{
|
||||||
// 轮流返回请求地址
|
// 轮流返回请求地址
|
||||||
if (RequestCount % 2 == 0)
|
if (_requestCount % 2 == 0)
|
||||||
return _remoteServices.GetRemoteFallbackURL(fileName);
|
|
||||||
else
|
|
||||||
return _remoteServices.GetRemoteMainURL(fileName);
|
return _remoteServices.GetRemoteMainURL(fileName);
|
||||||
|
else
|
||||||
|
return _remoteServices.GetRemoteFallbackURL(fileName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -10,13 +10,13 @@ namespace YooAsset
|
|||||||
Done,
|
Done,
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int RequestCount = 0;
|
|
||||||
private readonly IRemoteServices _remoteServices;
|
private readonly IRemoteServices _remoteServices;
|
||||||
private readonly string _packageName;
|
private readonly string _packageName;
|
||||||
private readonly string _packageVersion;
|
private readonly string _packageVersion;
|
||||||
private readonly int _timeout;
|
private readonly int _timeout;
|
||||||
private UnityWebDataRequester _downloader;
|
private UnityWebDataRequester _downloader;
|
||||||
private ESteps _steps = ESteps.None;
|
private ESteps _steps = ESteps.None;
|
||||||
|
private int _requestCount = 0;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 包裹哈希值
|
/// 包裹哈希值
|
||||||
@@ -33,7 +33,7 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
internal override void Start()
|
internal override void Start()
|
||||||
{
|
{
|
||||||
RequestCount++;
|
_requestCount = RequestHelper.GetRequestFailedCount(_packageName, nameof(QueryRemotePackageHashOperation));
|
||||||
_steps = ESteps.DownloadPackageHash;
|
_steps = ESteps.DownloadPackageHash;
|
||||||
}
|
}
|
||||||
internal override void Update()
|
internal override void Update()
|
||||||
@@ -62,6 +62,7 @@ namespace YooAsset
|
|||||||
_steps = ESteps.Done;
|
_steps = ESteps.Done;
|
||||||
Status = EOperationStatus.Failed;
|
Status = EOperationStatus.Failed;
|
||||||
Error = _downloader.GetError();
|
Error = _downloader.GetError();
|
||||||
|
RequestHelper.RecordRequestFailed(_packageName, nameof(QueryRemotePackageHashOperation));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -88,10 +89,10 @@ namespace YooAsset
|
|||||||
string url;
|
string url;
|
||||||
|
|
||||||
// 轮流返回请求地址
|
// 轮流返回请求地址
|
||||||
if (RequestCount % 2 == 0)
|
if (_requestCount % 2 == 0)
|
||||||
url = _remoteServices.GetRemoteFallbackURL(fileName);
|
|
||||||
else
|
|
||||||
url = _remoteServices.GetRemoteMainURL(fileName);
|
url = _remoteServices.GetRemoteMainURL(fileName);
|
||||||
|
else
|
||||||
|
url = _remoteServices.GetRemoteFallbackURL(fileName);
|
||||||
|
|
||||||
return url;
|
return url;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,13 +10,13 @@ namespace YooAsset
|
|||||||
Done,
|
Done,
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int RequestCount = 0;
|
|
||||||
private readonly IRemoteServices _remoteServices;
|
private readonly IRemoteServices _remoteServices;
|
||||||
private readonly string _packageName;
|
private readonly string _packageName;
|
||||||
private readonly bool _appendTimeTicks;
|
private readonly bool _appendTimeTicks;
|
||||||
private readonly int _timeout;
|
private readonly int _timeout;
|
||||||
private UnityWebDataRequester _downloader;
|
private UnityWebDataRequester _downloader;
|
||||||
private ESteps _steps = ESteps.None;
|
private ESteps _steps = ESteps.None;
|
||||||
|
private int _requestCount = 0;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 包裹版本
|
/// 包裹版本
|
||||||
@@ -33,7 +33,7 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
internal override void Start()
|
internal override void Start()
|
||||||
{
|
{
|
||||||
RequestCount++;
|
_requestCount = RequestHelper.GetRequestFailedCount(_packageName, nameof(QueryRemotePackageVersionOperation));
|
||||||
_steps = ESteps.DownloadPackageVersion;
|
_steps = ESteps.DownloadPackageVersion;
|
||||||
}
|
}
|
||||||
internal override void Update()
|
internal override void Update()
|
||||||
@@ -62,6 +62,7 @@ namespace YooAsset
|
|||||||
_steps = ESteps.Done;
|
_steps = ESteps.Done;
|
||||||
Status = EOperationStatus.Failed;
|
Status = EOperationStatus.Failed;
|
||||||
Error = _downloader.GetError();
|
Error = _downloader.GetError();
|
||||||
|
RequestHelper.RecordRequestFailed(_packageName, nameof(QueryRemotePackageVersionOperation));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -88,10 +89,10 @@ namespace YooAsset
|
|||||||
string url;
|
string url;
|
||||||
|
|
||||||
// 轮流返回请求地址
|
// 轮流返回请求地址
|
||||||
if (RequestCount % 2 == 0)
|
if (_requestCount % 2 == 0)
|
||||||
url = _remoteServices.GetRemoteFallbackURL(fileName);
|
|
||||||
else
|
|
||||||
url = _remoteServices.GetRemoteMainURL(fileName);
|
url = _remoteServices.GetRemoteMainURL(fileName);
|
||||||
|
else
|
||||||
|
url = _remoteServices.GetRemoteFallbackURL(fileName);
|
||||||
|
|
||||||
// 在URL末尾添加时间戳
|
// 在URL末尾添加时间戳
|
||||||
if (_appendTimeTicks)
|
if (_appendTimeTicks)
|
||||||
|
|||||||
@@ -368,17 +368,7 @@ namespace YooAsset
|
|||||||
{
|
{
|
||||||
DebugCheckInitialize();
|
DebugCheckInitialize();
|
||||||
AssetInfo assetInfo = ConvertLocationToAssetInfo(location, null);
|
AssetInfo assetInfo = ConvertLocationToAssetInfo(location, null);
|
||||||
if (assetInfo.IsInvalid)
|
return IsNeedDownloadFromRemoteInternal(assetInfo);
|
||||||
{
|
|
||||||
YooLogger.Warning(assetInfo.Error);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
BundleInfo bundleInfo = _bundleServices.GetBundleInfo(assetInfo);
|
|
||||||
if (bundleInfo.LoadMode == BundleInfo.ELoadMode.LoadFromRemote)
|
|
||||||
return true;
|
|
||||||
else
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -388,17 +378,7 @@ namespace YooAsset
|
|||||||
public bool IsNeedDownloadFromRemote(AssetInfo assetInfo)
|
public bool IsNeedDownloadFromRemote(AssetInfo assetInfo)
|
||||||
{
|
{
|
||||||
DebugCheckInitialize();
|
DebugCheckInitialize();
|
||||||
if (assetInfo.IsInvalid)
|
return IsNeedDownloadFromRemoteInternal(assetInfo);
|
||||||
{
|
|
||||||
YooLogger.Warning(assetInfo.Error);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
BundleInfo bundleInfo = _bundleServices.GetBundleInfo(assetInfo);
|
|
||||||
if (bundleInfo.LoadMode == BundleInfo.ELoadMode.LoadFromRemote)
|
|
||||||
return true;
|
|
||||||
else
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -452,6 +432,28 @@ namespace YooAsset
|
|||||||
string assetPath = _playModeServices.ActiveManifest.TryMappingToAssetPath(location);
|
string assetPath = _playModeServices.ActiveManifest.TryMappingToAssetPath(location);
|
||||||
return string.IsNullOrEmpty(assetPath) == false;
|
return string.IsNullOrEmpty(assetPath) == false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private bool IsNeedDownloadFromRemoteInternal(AssetInfo assetInfo)
|
||||||
|
{
|
||||||
|
if (assetInfo.IsInvalid)
|
||||||
|
{
|
||||||
|
YooLogger.Warning(assetInfo.Error);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
BundleInfo bundleInfo = _bundleServices.GetBundleInfo(assetInfo);
|
||||||
|
if (bundleInfo.LoadMode == BundleInfo.ELoadMode.LoadFromRemote)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
BundleInfo[] depends = _bundleServices.GetAllDependBundleInfos(assetInfo);
|
||||||
|
foreach (var depend in depends)
|
||||||
|
{
|
||||||
|
if (depend.LoadMode == BundleInfo.ELoadMode.LoadFromRemote)
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region 原生文件
|
#region 原生文件
|
||||||
|
|||||||
@@ -10,6 +10,10 @@ namespace YooAsset
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public string ManifestFileName = "PackageManifest";
|
public string ManifestFileName = "PackageManifest";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 默认的YooAsset文件夹名称
|
||||||
|
/// </summary>
|
||||||
|
public string DefaultYooFolderName = "yoo";
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 清单文件头标记
|
/// 清单文件头标记
|
||||||
@@ -37,11 +41,6 @@ namespace YooAsset
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public const string CacheBundleInfoFileName = "__info";
|
public const string CacheBundleInfoFileName = "__info";
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 默认的YooAsset文件夹名称
|
|
||||||
/// </summary>
|
|
||||||
public const string DefaultYooFolderName = "yoo";
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 缓存的资源文件的文件夹名称
|
/// 缓存的资源文件的文件夹名称
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "com.tuyoogame.yooasset",
|
"name": "com.tuyoogame.yooasset",
|
||||||
"displayName": "YooAsset",
|
"displayName": "YooAsset",
|
||||||
"version": "1.5.4-preview",
|
"version": "1.5.6-preview",
|
||||||
"unity": "2019.4",
|
"unity": "2019.4",
|
||||||
"description": "unity3d resources management system.",
|
"description": "unity3d resources management system.",
|
||||||
"author": {
|
"author": {
|
||||||
|
|||||||
Reference in New Issue
Block a user