diff --git a/Assets/YooAsset/CHANGELOG.md b/Assets/YooAsset/CHANGELOG.md
index 8ddf58b..6b7b62a 100644
--- a/Assets/YooAsset/CHANGELOG.md
+++ b/Assets/YooAsset/CHANGELOG.md
@@ -2,6 +2,35 @@
All notable changes to this package will be documented in this file.
+## [1.4.5-preview] - 2023-02-17
+
+### Fixed
+
+- (#67)修复了报告查看界面在Unity2021.3上的兼容性问题。
+- (#66)修复了在Unity2021.3上编辑器模拟模式运行报错的问题。
+
+### Changed
+
+- 接口变更:IPackRule
+
+ ````c#
+ ///
+ /// 资源打包规则接口
+ ///
+ public interface IPackRule
+ {
+ ///
+ /// 获取打包规则结果
+ ///
+ PackRuleResult GetPackRuleResult(PackRuleData data);
+
+ ///
+ /// 是否为原生文件打包规则
+ ///
+ bool IsRawFilePackRule();
+ }
+ ````
+
## [1.4.4-preview] - 2023-02-14
### Fixed
diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildAssetInfo.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildAssetInfo.cs
index e34abce..7999f92 100644
--- a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildAssetInfo.cs
+++ b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildAssetInfo.cs
@@ -7,8 +7,6 @@ namespace YooAsset.Editor
{
public class BuildAssetInfo
{
- private string _mainBundleName;
- private string _shareBundleName;
private bool _isAddAssetTags = false;
private readonly HashSet _referenceBundleNames = new HashSet();
@@ -17,6 +15,11 @@ namespace YooAsset.Editor
///
public ECollectorType CollectorType { private set; get; }
+ ///
+ /// 资源包完整名称
+ ///
+ public string BundleName { private set; get; }
+
///
/// 可寻址地址
///
@@ -54,10 +57,10 @@ namespace YooAsset.Editor
public List AllDependAssetInfos { private set; get; }
- public BuildAssetInfo(ECollectorType collectorType, string mainBundleName, string address, string assetPath, bool isRawAsset)
+ public BuildAssetInfo(ECollectorType collectorType, string bundleName, string address, string assetPath, bool isRawAsset)
{
- _mainBundleName = mainBundleName;
CollectorType = collectorType;
+ BundleName = bundleName;
Address = address;
AssetPath = assetPath;
IsRawAsset = isRawAsset;
@@ -133,24 +136,12 @@ namespace YooAsset.Editor
///
public bool HasBundleName()
{
- string bundleName = GetBundleName();
- if (string.IsNullOrEmpty(bundleName))
+ if (string.IsNullOrEmpty(BundleName))
return false;
else
return true;
}
- ///
- /// 获取资源包名称
- ///
- public string GetBundleName()
- {
- if (CollectorType == ECollectorType.None)
- return _shareBundleName;
- else
- return _mainBundleName;
- }
-
///
/// 添加关联的资源包名称
///
@@ -164,53 +155,32 @@ namespace YooAsset.Editor
}
///
- /// 计算主资源或共享资源的完整包名
+ /// 计算共享资源包的完整包名
///
- public void CalculateFullBundleName(bool uniqueBundleName, string packageName)
+ public void CalculateShareBundleName(bool uniqueBundleName, string packageName, string shadersBundleName)
{
- if (CollectorType == ECollectorType.None)
+ if (CollectorType != ECollectorType.None)
+ return;
+
+ if (IsRawAsset)
+ throw new Exception("Should never get here !");
+
+ if (IsShaderAsset)
{
- if (IsRawAsset)
- throw new Exception("Should never get here !");
-
- if (IsShaderAsset)
- {
- _shareBundleName = YooAssetSettingsData.GetUnityShadersBundleFullName(uniqueBundleName, packageName);
- }
- else
- {
- if (_referenceBundleNames.Count > 1)
- {
- IPackRule packRule = PackDirectory.StaticPackRule;
- var bundleName = packRule.GetBundleName(new PackRuleData(AssetPath));
- if (YooAssetSettingsData.Setting.RegularBundleName)
- bundleName = EditorTools.GetRegularPath(bundleName).Replace('/', '_').Replace('.', '_').ToLower();
- else
- bundleName = EditorTools.GetRegularPath(bundleName).ToLower();
-
- if (uniqueBundleName)
- _shareBundleName = $"{packageName.ToLower()}_share_{bundleName}.{YooAssetSettingsData.Setting.AssetBundleFileVariant}";
- else
- _shareBundleName = $"share_{bundleName}.{YooAssetSettingsData.Setting.AssetBundleFileVariant}";
- }
- }
+ BundleName = shadersBundleName;
}
else
{
- if (IsRawAsset)
+ if (_referenceBundleNames.Count > 1)
{
- string mainBundleName = $"{_mainBundleName}.{YooAssetSettingsData.Setting.RawBundleFileVariant}";
- _mainBundleName = mainBundleName.ToLower();
+ IPackRule packRule = PackDirectory.StaticPackRule;
+ PackRuleResult packRuleResult = packRule.GetPackRuleResult(new PackRuleData(AssetPath));
+ BundleName = packRuleResult.GetShareBundleName(packageName, uniqueBundleName);
}
else
{
- string mainBundleName = $"{_mainBundleName}.{YooAssetSettingsData.Setting.AssetBundleFileVariant}";
- _mainBundleName = mainBundleName.ToLower(); ;
- }
-
- if (uniqueBundleName)
- {
- _mainBundleName = $"{packageName.ToLower()}_{_mainBundleName}";
+ // 注意:被引用次数小于1的资源不需要设置资源包名称
+ BundleName = string.Empty;
}
}
}
diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildMapContext.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildMapContext.cs
index effc561..f05ee17 100644
--- a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildMapContext.cs
+++ b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildMapContext.cs
@@ -24,6 +24,11 @@ namespace YooAsset.Editor
///
public bool UniqueBundleName;
+ ///
+ /// 着色器统一的全名称
+ ///
+ public string ShadersBundleName;
+
///
/// 资源包列表
///
@@ -35,7 +40,7 @@ namespace YooAsset.Editor
///
public void PackAsset(BuildAssetInfo assetInfo)
{
- string bundleName = assetInfo.GetBundleName();
+ string bundleName = assetInfo.BundleName;
if (string.IsNullOrEmpty(bundleName))
throw new Exception("Should never get here !");
diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildMapCreater.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildMapCreater.cs
index bf783d3..46417ce 100644
--- a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildMapCreater.cs
+++ b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildMapCreater.cs
@@ -11,8 +11,7 @@ namespace YooAsset.Editor
/// 执行资源构建上下文
///
public static BuildMapContext CreateBuildMap(EBuildMode buildMode, string packageName)
- {
- BuildMapContext context = new BuildMapContext();
+ {
Dictionary buildAssetDic = new Dictionary(1000);
// 1. 检测配置合法性
@@ -22,7 +21,7 @@ namespace YooAsset.Editor
var buildResult = AssetBundleCollectorSettingData.Setting.GetPackageAssets(buildMode, packageName);
List allCollectAssets = buildResult.CollectAssets;
- // 3. 剔除未被引用的依赖资源
+ // 3. 剔除未被引用的依赖项资源
List removeDependList = new List();
foreach (var collectAssetInfo in allCollectAssets)
{
@@ -42,7 +41,8 @@ namespace YooAsset.Editor
{
if (buildAssetDic.ContainsKey(collectAssetInfo.AssetPath) == false)
{
- var buildAssetInfo = new BuildAssetInfo(collectAssetInfo.CollectorType, collectAssetInfo.BundleName,
+ var buildAssetInfo = new BuildAssetInfo(
+ collectAssetInfo.CollectorType, collectAssetInfo.BundleName,
collectAssetInfo.Address, collectAssetInfo.AssetPath, collectAssetInfo.IsRawAsset);
buildAssetInfo.AddAssetTags(collectAssetInfo.AssetTags);
buildAssetInfo.AddBundleTags(collectAssetInfo.AssetTags);
@@ -54,32 +54,28 @@ namespace YooAsset.Editor
}
}
- // 5. 录入相关依赖的资源
+ // 5. 录入所有收集资源的依赖资源
foreach (var collectAssetInfo in allCollectAssets)
{
+ string collectAssetBundleName = collectAssetInfo.BundleName;
foreach (var dependAssetPath in collectAssetInfo.DependAssets)
{
if (buildAssetDic.ContainsKey(dependAssetPath))
{
buildAssetDic[dependAssetPath].AddBundleTags(collectAssetInfo.AssetTags);
- buildAssetDic[dependAssetPath].AddReferenceBundleName(collectAssetInfo.BundleName);
+ buildAssetDic[dependAssetPath].AddReferenceBundleName(collectAssetBundleName);
}
else
{
var buildAssetInfo = new BuildAssetInfo(dependAssetPath);
buildAssetInfo.AddBundleTags(collectAssetInfo.AssetTags);
- buildAssetInfo.AddReferenceBundleName(collectAssetInfo.BundleName);
+ buildAssetInfo.AddReferenceBundleName(collectAssetBundleName);
buildAssetDic.Add(dependAssetPath, buildAssetInfo);
}
}
}
- // 6. 记录关键信息
- context.AssetFileCount = buildAssetDic.Count;
- context.EnableAddressable = buildResult.EnableAddressable;
- context.UniqueBundleName = buildResult.UniqueBundleName;
-
- // 7. 填充主动收集资源的依赖列表
+ // 6. 填充所有收集资源的依赖列表
foreach (var collectAssetInfo in allCollectAssets)
{
var dependAssetInfos = new List(collectAssetInfo.DependAssets.Count);
@@ -93,10 +89,18 @@ namespace YooAsset.Editor
buildAssetDic[collectAssetInfo.AssetPath].SetAllDependAssetInfos(dependAssetInfos);
}
- // 8. 计算完整的资源包名
+ // 7. 记录关键信息
+ BuildMapContext context = new BuildMapContext();
+ context.AssetFileCount = buildAssetDic.Count;
+ context.EnableAddressable = buildResult.Command.EnableAddressable;
+ context.UniqueBundleName = buildResult.Command.UniqueBundleName;
+ context.ShadersBundleName = buildResult.ShadersBundleName;
+
+ // 8. 计算共享的资源包名
+ var command = buildResult.Command;
foreach (KeyValuePair pair in buildAssetDic)
{
- pair.Value.CalculateFullBundleName(buildResult.UniqueBundleName, buildResult.PackageName);
+ pair.Value.CalculateShareBundleName(command.UniqueBundleName, command.PackageName, buildResult.ShadersBundleName);
}
// 9. 移除不参与构建的资源
diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskBuilding_SBP.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskBuilding_SBP.cs
index d17ee14..6c7ae23 100644
--- a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskBuilding_SBP.cs
+++ b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskBuilding_SBP.cs
@@ -33,8 +33,7 @@ namespace YooAsset.Editor
// 开始构建
IBundleBuildResults buildResults;
var buildParameters = buildParametersContext.GetSBPBuildParameters();
- var shadersBunldeName = YooAssetSettingsData.GetUnityShadersBundleFullName(buildMapContext.UniqueBundleName, buildParametersContext.Parameters.PackageName);
- var taskList = SBPBuildTasks.Create(shadersBunldeName);
+ var taskList = SBPBuildTasks.Create(buildMapContext.ShadersBundleName);
ReturnCode exitCode = ContentPipeline.BuildAssetBundles(buildParameters, buildContent, out buildResults, taskList);
if (exitCode < 0)
{
diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCreatePatchManifest.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCreatePatchManifest.cs
index 2982c84..2754b7a 100644
--- a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCreatePatchManifest.cs
+++ b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCreatePatchManifest.cs
@@ -42,13 +42,12 @@ namespace YooAsset.Editor
patchManifest.AssetList = GetAllPatchAsset(context, patchManifest);
// 更新Unity内置资源包的引用关系
- string shadersBunldeName = YooAssetSettingsData.GetUnityShadersBundleFullName(buildMapContext.UniqueBundleName, buildParameters.PackageName);
if (buildParameters.BuildPipeline == EBuildPipeline.ScriptableBuildPipeline)
{
if (buildParameters.BuildMode == EBuildMode.IncrementalBuild)
{
var buildResultContext = context.GetContextObject();
- UpdateBuiltInBundleReference(patchManifest, buildResultContext.Results, shadersBunldeName);
+ UpdateBuiltInBundleReference(patchManifest, buildResultContext.Results, buildMapContext.ShadersBundleName);
}
}
@@ -98,7 +97,6 @@ namespace YooAsset.Editor
private List GetAllPatchBundle(BuildContext context)
{
var buildMapContext = context.GetContextObject();
- var buildParametersContext = context.GetContextObject();
List result = new List(1000);
foreach (var bundleInfo in buildMapContext.BundleInfos)
@@ -129,7 +127,7 @@ namespace YooAsset.Editor
patchAsset.Address = string.Empty;
patchAsset.AssetPath = assetInfo.AssetPath;
patchAsset.AssetTags = assetInfo.AssetTags.ToArray();
- patchAsset.BundleID = GetAssetBundleID(assetInfo.GetBundleName(), patchManifest);
+ patchAsset.BundleID = GetAssetBundleID(assetInfo.BundleName, patchManifest);
patchAsset.DependIDs = GetAssetBundleDependIDs(patchAsset.BundleID, assetInfo, patchManifest);
result.Add(patchAsset);
}
@@ -143,7 +141,7 @@ namespace YooAsset.Editor
{
if (dependAssetInfo.HasBundleName())
{
- int bundleID = GetAssetBundleID(dependAssetInfo.GetBundleName(), patchManifest);
+ int bundleID = GetAssetBundleID(dependAssetInfo.BundleName, patchManifest);
if (mainBundleID != bundleID)
{
if (result.Contains(bundleID) == false)
diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskUpdateBuildInfo.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskUpdateBuildInfo.cs
index 8c6f6fd..64dca4d 100644
--- a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskUpdateBuildInfo.cs
+++ b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskUpdateBuildInfo.cs
@@ -48,7 +48,8 @@ namespace YooAsset.Editor
// 4.更新补丁包输出的文件路径
foreach (var bundleInfo in buildMapContext.BundleInfos)
{
- string patchFileName = PatchManifestTools.CreateBundleFileName(outputNameStyle, bundleInfo.BundleName, bundleInfo.PatchInfo.PatchFileHash, bundleInfo.IsRawFile);
+ string patchFileExtension = PatchManifestTools.GetRemoteBundleFileExtension(bundleInfo.BundleName);
+ string patchFileName = PatchManifestTools.GetRemoteBundleFileName(outputNameStyle, bundleInfo.BundleName, patchFileExtension, bundleInfo.PatchInfo.PatchFileHash);
bundleInfo.PatchInfo.PatchOutputFilePath = $"{packageOutputDirectory}/{patchFileName}";
}
}
diff --git a/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollector.cs b/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollector.cs
index 0bff9ef..141365a 100644
--- a/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollector.cs
+++ b/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollector.cs
@@ -152,11 +152,14 @@ namespace YooAsset.Editor
}
Dictionary result = new Dictionary(1000);
- bool isRawAsset = PackRuleName == nameof(PackRawFile);
+
+ // 检测是否为原生资源打包规则
+ IPackRule packRuleInstance = AssetBundleCollectorSettingData.GetPackRuleInstance(PackRuleName);
+ bool isRawFilePackRule = packRuleInstance.IsRawFilePackRule();
// 检测原生资源包的收集器类型
- if (isRawAsset && CollectorType != ECollectorType.MainAssetCollector)
- throw new Exception($"The raw file must be set to {nameof(ECollectorType)}.{ECollectorType.MainAssetCollector} : {CollectPath}");
+ if (isRawFilePackRule && CollectorType != ECollectorType.MainAssetCollector)
+ throw new Exception($"The raw file pack rule must be set to {nameof(ECollectorType)}.{ECollectorType.MainAssetCollector} : {CollectPath}");
if (string.IsNullOrEmpty(CollectPath))
throw new Exception($"The collect path is null or empty in group : {group.GroupName}");
@@ -168,7 +171,7 @@ namespace YooAsset.Editor
string[] findAssets = EditorTools.FindAssets(EAssetSearchType.All, collectDirectory);
foreach (string assetPath in findAssets)
{
- if (IsValidateAsset(assetPath) && IsCollectAsset(assetPath))
+ if (IsValidateAsset(assetPath, isRawFilePackRule) && IsCollectAsset(assetPath))
{
if (IsMultiPlatform)
{
@@ -186,7 +189,7 @@ namespace YooAsset.Editor
if (result.ContainsKey(assetPath) == false)
{
- var collectAssetInfo = CreateCollectAssetInfo(command, group, assetPath, isRawAsset);
+ var collectAssetInfo = CreateCollectAssetInfo(command, group, assetPath, isRawFilePackRule);
result.Add(assetPath, collectAssetInfo);
}
else
@@ -199,9 +202,9 @@ namespace YooAsset.Editor
else
{
string assetPath = CollectPath;
- if (IsValidateAsset(assetPath) && IsCollectAsset(assetPath))
+ if (IsValidateAsset(assetPath, isRawFilePackRule) && IsCollectAsset(assetPath))
{
- var collectAssetInfo = CreateCollectAssetInfo(command, group, assetPath, isRawAsset);
+ var collectAssetInfo = CreateCollectAssetInfo(command, group, assetPath, isRawFilePackRule);
result.Add(assetPath, collectAssetInfo);
}
else
@@ -231,22 +234,22 @@ namespace YooAsset.Editor
return result.Values.ToList();
}
- private CollectAssetInfo CreateCollectAssetInfo(CollectCommand command, AssetBundleCollectorGroup group, string assetPath, bool isRawAsset)
+ private CollectAssetInfo CreateCollectAssetInfo(CollectCommand command, AssetBundleCollectorGroup group, string assetPath, bool isRawFilePackRule)
{
string address = GetAddress(group, assetPath);
- string bundleName = GetBundleName(group, assetPath);
+ string bundleName = GetBundleName(command, group, assetPath);
List assetTags = GetAssetTags(group);
- CollectAssetInfo collectAssetInfo = new CollectAssetInfo(CollectorType, bundleName, address, assetPath, assetTags, isRawAsset);
+ CollectAssetInfo collectAssetInfo = new CollectAssetInfo(CollectorType, bundleName, address, assetPath, isRawFilePackRule, assetTags);
// 注意:模拟构建模式下不需要收集依赖资源
if (command.BuildMode == EBuildMode.SimulateBuild)
collectAssetInfo.DependAssets = new List();
else
- collectAssetInfo.DependAssets = GetAllDependencies(assetPath);
+ collectAssetInfo.DependAssets = GetAllDependencies(assetPath, isRawFilePackRule);
return collectAssetInfo;
}
- private bool IsValidateAsset(string assetPath)
+ private bool IsValidateAsset(string assetPath, bool isRawFilePackRule)
{
if (assetPath.StartsWith("Assets/") == false && assetPath.StartsWith("Packages/") == false)
{
@@ -263,10 +266,31 @@ namespace YooAsset.Editor
if (type == typeof(LightingDataAsset))
return false;
- // 忽略Unity无法识别的无效文件
- // 注意:只对非原生文件收集器处理
- if(PackRuleName != nameof(PackRawFile))
+ // 检测原生文件是否合规
+ if (isRawFilePackRule)
{
+ string extension = StringUtility.RemoveFirstChar(System.IO.Path.GetExtension(assetPath));
+ if (extension == EAssetFileExtension.unity.ToString() || extension == EAssetFileExtension.prefab.ToString() ||
+ extension == EAssetFileExtension.mat.ToString() || extension == EAssetFileExtension.controller.ToString() ||
+ extension == EAssetFileExtension.fbx.ToString() || extension == EAssetFileExtension.anim.ToString() ||
+ extension == EAssetFileExtension.shader.ToString())
+ {
+ UnityEngine.Debug.LogWarning($"Raw file pack rule can not support file estension : {extension}");
+ return false;
+ }
+
+ // 注意:原生文件只支持无依赖关系的资源
+ string[] depends = AssetDatabase.GetDependencies(assetPath, true);
+ if (depends.Length != 1)
+ {
+ UnityEngine.Debug.LogWarning($"Raw file pack rule can not support estension : {extension}");
+ return false;
+ }
+ }
+ else
+ {
+ // 忽略Unity无法识别的无效文件
+ // 注意:只对非原生文件收集器处理
if (type == typeof(UnityEditor.DefaultAsset))
{
UnityEngine.Debug.LogWarning($"Cannot pack default asset : {assetPath}");
@@ -282,7 +306,7 @@ namespace YooAsset.Editor
}
private bool IsIgnoreFile(string fileExtension)
{
- foreach (var extension in YooAssetSettings.IgnoreFileExtensions)
+ foreach (var extension in DefaultFilterRule.IgnoreFileExtensions)
{
if (extension == fileExtension)
return true;
@@ -308,19 +332,22 @@ namespace YooAsset.Editor
string adressValue = addressRuleInstance.GetAssetAddress(new AddressRuleData(assetPath, CollectPath, group.GroupName, Address, IsMultiPlatform));
return adressValue;
}
- private string GetBundleName(AssetBundleCollectorGroup group, string assetPath)
+ private string GetBundleName(CollectCommand command, AssetBundleCollectorGroup group, string assetPath)
{
System.Type assetType = AssetDatabase.GetMainAssetTypeAtPath(assetPath);
if (assetType == typeof(UnityEngine.Shader) || assetType == typeof(UnityEngine.ShaderVariantCollection))
- return EditorTools.GetRegularPath(YooAssetSettings.UnityShadersBundleName).ToLower();
-
- // 根据规则设置获取资源包名称
- IPackRule packRuleInstance = AssetBundleCollectorSettingData.GetPackRuleInstance(PackRuleName);
- string bundleName = packRuleInstance.GetBundleName(new PackRuleData(assetPath, CollectPath, group.GroupName));
- if(YooAssetSettingsData.Setting.RegularBundleName)
- return EditorTools.GetRegularPath(bundleName).Replace('/', '_').Replace('.', '_').ToLower();
+ {
+ // 获取着色器打包规则结果
+ PackRuleResult packRuleResult = DefaultPackRule.CreateShadersPackRuleResult();
+ return packRuleResult.GetMainBundleName(command.PackageName, command.UniqueBundleName);
+ }
else
- return EditorTools.GetRegularPath(bundleName).ToLower();
+ {
+ // 获取其它资源打包规则结果
+ IPackRule packRuleInstance = AssetBundleCollectorSettingData.GetPackRuleInstance(PackRuleName);
+ PackRuleResult packRuleResult = packRuleInstance.GetPackRuleResult(new PackRuleData(assetPath, CollectPath, group.GroupName));
+ return packRuleResult.GetMainBundleName(command.PackageName, command.UniqueBundleName);
+ }
}
private List GetAssetTags(AssetBundleCollectorGroup group)
{
@@ -329,13 +356,13 @@ namespace YooAsset.Editor
tags.AddRange(temper);
return tags;
}
- private List GetAllDependencies(string mainAssetPath)
+ private List GetAllDependencies(string mainAssetPath, bool isRawFilePackRule)
{
List result = new List();
string[] depends = AssetDatabase.GetDependencies(mainAssetPath, true);
foreach (string assetPath in depends)
{
- if (IsValidateAsset(assetPath))
+ if (IsValidateAsset(assetPath, isRawFilePackRule))
{
// 注意:排除主资源对象
if (assetPath != mainAssetPath)
diff --git a/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorSetting.cs b/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorSetting.cs
index bfcc7d8..1480c9a 100644
--- a/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorSetting.cs
+++ b/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorSetting.cs
@@ -100,8 +100,8 @@ namespace YooAsset.Editor
{
if (package.PackageName == packageName)
{
- CollectCommand command = new CollectCommand(buildMode, EnableAddressable);
- CollectResult collectResult = new CollectResult(package.PackageName, EnableAddressable, UniqueBundleName);
+ CollectCommand command = new CollectCommand(buildMode, package.PackageName, EnableAddressable, UniqueBundleName);
+ CollectResult collectResult = new CollectResult(command);
collectResult.SetCollectAssets(package.GetAllCollectAssets(command));
return collectResult;
}
@@ -118,8 +118,8 @@ namespace YooAsset.Editor
List collectResultList = new List(1000);
foreach (var package in Packages)
{
- CollectCommand command = new CollectCommand(buildMode, EnableAddressable);
- CollectResult collectResult = new CollectResult(package.PackageName, EnableAddressable, UniqueBundleName);
+ CollectCommand command = new CollectCommand(buildMode, package.PackageName, EnableAddressable, UniqueBundleName);
+ CollectResult collectResult = new CollectResult(command);
collectResult.SetCollectAssets(package.GetAllCollectAssets(command));
collectResultList.Add(collectResult);
}
diff --git a/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorWindow.cs b/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorWindow.cs
index 3aba38a..3b96ed7 100644
--- a/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorWindow.cs
+++ b/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorWindow.cs
@@ -814,7 +814,7 @@ namespace YooAsset.Editor
try
{
- CollectCommand command = new CollectCommand(EBuildMode.DryRunBuild, _enableAddressableToogle.value);
+ CollectCommand command = new CollectCommand(EBuildMode.DryRunBuild, _packageNameTxt.value, _enableAddressableToogle.value, _uniqueBundleNameToogle.value);
collectAssetInfos = collector.GetAllCollectAssets(command, group);
}
catch (System.Exception e)
diff --git a/Assets/YooAsset/Editor/AssetBundleCollector/CollectAssetInfo.cs b/Assets/YooAsset/Editor/AssetBundleCollector/CollectAssetInfo.cs
index fc9c41b..6d12c35 100644
--- a/Assets/YooAsset/Editor/AssetBundleCollector/CollectAssetInfo.cs
+++ b/Assets/YooAsset/Editor/AssetBundleCollector/CollectAssetInfo.cs
@@ -14,7 +14,7 @@ namespace YooAsset.Editor
/// 资源包名称
///
public string BundleName { private set; get; }
-
+
///
/// 可寻址地址
///
@@ -25,30 +25,30 @@ namespace YooAsset.Editor
///
public string AssetPath { private set; get; }
- ///
- /// 资源分类标签
- ///
- public List AssetTags { private set; get; }
-
///
/// 是否为原生资源
///
public bool IsRawAsset { private set; get; }
+ ///
+ /// 资源分类标签
+ ///
+ public List AssetTags { private set; get; }
+
///
/// 依赖的资源列表
///
public List DependAssets = new List();
- public CollectAssetInfo(ECollectorType collectorType, string bundleName, string address, string assetPath, List assetTags, bool isRawAsset)
+ public CollectAssetInfo(ECollectorType collectorType, string bundleName, string address, string assetPath, bool isRawAsset, List assetTags)
{
CollectorType = collectorType;
BundleName = bundleName;
Address = address;
AssetPath = assetPath;
- AssetTags = assetTags;
IsRawAsset = isRawAsset;
+ AssetTags = assetTags;
}
}
}
\ No newline at end of file
diff --git a/Assets/YooAsset/Editor/AssetBundleCollector/CollectCommand.cs b/Assets/YooAsset/Editor/AssetBundleCollector/CollectCommand.cs
index 0501a37..2f6d3bb 100644
--- a/Assets/YooAsset/Editor/AssetBundleCollector/CollectCommand.cs
+++ b/Assets/YooAsset/Editor/AssetBundleCollector/CollectCommand.cs
@@ -8,15 +8,27 @@ namespace YooAsset.Editor
///
public EBuildMode BuildMode { private set; get; }
+ ///
+ /// 包裹名称
+ ///
+ public string PackageName { private set; get; }
+
///
/// 是否启用可寻址资源定位
///
public bool EnableAddressable { private set; get; }
- public CollectCommand(EBuildMode buildMode, bool enableAddressable)
+ ///
+ /// 资源包名唯一化
+ ///
+ public bool UniqueBundleName { private set; get; }
+
+ public CollectCommand(EBuildMode buildMode, string packageName, bool enableAddressable, bool uniqueBundleName)
{
BuildMode = buildMode;
+ PackageName = packageName;
EnableAddressable = enableAddressable;
+ UniqueBundleName = uniqueBundleName;
}
}
}
\ No newline at end of file
diff --git a/Assets/YooAsset/Editor/AssetBundleCollector/CollectResult.cs b/Assets/YooAsset/Editor/AssetBundleCollector/CollectResult.cs
index 5eca265..3cbd1cf 100644
--- a/Assets/YooAsset/Editor/AssetBundleCollector/CollectResult.cs
+++ b/Assets/YooAsset/Editor/AssetBundleCollector/CollectResult.cs
@@ -6,19 +6,14 @@ namespace YooAsset.Editor
public class CollectResult
{
///
- /// 包裹名称
+ /// 收集命令
///
- public string PackageName { private set; get; }
+ public CollectCommand Command { private set; get; }
///
- /// 是否启用可寻址资源定位
+ /// 着色器统一全名称
///
- public bool EnableAddressable { private set; get; }
-
- ///
- /// 资源包名唯一化
- ///
- public bool UniqueBundleName { private set; get; }
+ public string ShadersBundleName { private set; get; }
///
/// 收集的资源信息列表
@@ -26,11 +21,13 @@ namespace YooAsset.Editor
public List CollectAssets { private set; get; }
- public CollectResult(string packageName, bool enableAddressable, bool uniqueBundleName)
+ public CollectResult(CollectCommand command)
{
- PackageName = packageName;
- EnableAddressable = enableAddressable;
- UniqueBundleName = uniqueBundleName;
+ Command = command;
+
+ // 着色器统一全名称
+ var packRuleResult = DefaultPackRule.CreateShadersPackRuleResult();
+ ShadersBundleName = packRuleResult.GetMainBundleName(command.PackageName, command.UniqueBundleName);
}
public void SetCollectAssets(List collectAssets)
diff --git a/Assets/YooAsset/Editor/AssetBundleCollector/DefaultFilterRule.cs b/Assets/YooAsset/Editor/AssetBundleCollector/DefaultFilterRule.cs
index eba9b87..b24b0b2 100644
--- a/Assets/YooAsset/Editor/AssetBundleCollector/DefaultFilterRule.cs
+++ b/Assets/YooAsset/Editor/AssetBundleCollector/DefaultFilterRule.cs
@@ -4,6 +4,14 @@ using System.IO;
namespace YooAsset.Editor
{
+ public class DefaultFilterRule
+ {
+ ///
+ /// 忽略的文件类型
+ ///
+ public static readonly string[] IgnoreFileExtensions = { "", ".so", ".dll", ".cs", ".js", ".boo", ".meta", ".cginc", ".hlsl" };
+ }
+
[DisplayName("收集所有资源")]
public class CollectAll : IFilterRule
{
diff --git a/Assets/YooAsset/Editor/AssetBundleCollector/DefaultPackRule.cs b/Assets/YooAsset/Editor/AssetBundleCollector/DefaultPackRule.cs
index 3dbc7c9..4d9d582 100644
--- a/Assets/YooAsset/Editor/AssetBundleCollector/DefaultPackRule.cs
+++ b/Assets/YooAsset/Editor/AssetBundleCollector/DefaultPackRule.cs
@@ -4,6 +4,31 @@ using UnityEditor;
namespace YooAsset.Editor
{
+ public class DefaultPackRule
+ {
+ ///
+ /// AssetBundle文件的后缀名
+ ///
+ public const string AssetBundleFileExtension = "bundle";
+
+ ///
+ /// 原生文件的后缀名
+ ///
+ public const string RawFileExtension = "rawfile";
+
+ ///
+ /// Unity着色器资源包名称
+ ///
+ public const string ShadersBundleName = "unityshaders";
+
+
+ public static PackRuleResult CreateShadersPackRuleResult()
+ {
+ PackRuleResult result = new PackRuleResult(ShadersBundleName, AssetBundleFileExtension);
+ return result;
+ }
+ }
+
///
/// 以文件路径作为资源包名
/// 注意:每个文件独自打资源包
@@ -13,9 +38,16 @@ namespace YooAsset.Editor
[DisplayName("以文件路径作为资源包名")]
public class PackSeparately : IPackRule
{
- string IPackRule.GetBundleName(PackRuleData data)
+ PackRuleResult IPackRule.GetPackRuleResult(PackRuleData data)
{
- return StringUtility.RemoveExtension(data.AssetPath);
+ string bundleName = StringUtility.RemoveExtension(data.AssetPath);
+ PackRuleResult result = new PackRuleResult(bundleName, DefaultPackRule.AssetBundleFileExtension);
+ return result;
+ }
+
+ bool IPackRule.IsRawFilePackRule()
+ {
+ return false;
}
}
@@ -30,9 +62,16 @@ namespace YooAsset.Editor
{
public static PackDirectory StaticPackRule = new PackDirectory();
- string IPackRule.GetBundleName(PackRuleData data)
+ PackRuleResult IPackRule.GetPackRuleResult(PackRuleData data)
{
- return Path.GetDirectoryName(data.AssetPath);
+ string bundleName = Path.GetDirectoryName(data.AssetPath);
+ PackRuleResult result = new PackRuleResult(bundleName, DefaultPackRule.AssetBundleFileExtension);
+ return result;
+ }
+
+ bool IPackRule.IsRawFilePackRule()
+ {
+ return false;
}
}
@@ -46,7 +85,7 @@ namespace YooAsset.Editor
[DisplayName("以收集器路径下顶级文件夹为资源包名")]
public class PackTopDirectory : IPackRule
{
- string IPackRule.GetBundleName(PackRuleData data)
+ PackRuleResult IPackRule.GetPackRuleResult(PackRuleData data)
{
string assetPath = data.AssetPath.Replace(data.CollectPath, string.Empty);
assetPath = assetPath.TrimStart('/');
@@ -56,13 +95,19 @@ namespace YooAsset.Editor
if (Path.HasExtension(splits[0]))
throw new Exception($"Not found root directory : {assetPath}");
string bundleName = $"{data.CollectPath}/{splits[0]}";
- return bundleName;
+ PackRuleResult result = new PackRuleResult(bundleName, DefaultPackRule.AssetBundleFileExtension);
+ return result;
}
else
{
throw new Exception($"Not found root directory : {assetPath}");
}
}
+
+ bool IPackRule.IsRawFilePackRule()
+ {
+ return false;
+ }
}
///
@@ -72,17 +117,26 @@ namespace YooAsset.Editor
[DisplayName("以收集器路径作为资源包名")]
public class PackCollector : IPackRule
{
- string IPackRule.GetBundleName(PackRuleData data)
+ PackRuleResult IPackRule.GetPackRuleResult(PackRuleData data)
{
+ string bundleName;
string collectPath = data.CollectPath;
if (AssetDatabase.IsValidFolder(collectPath))
{
- return collectPath;
+ bundleName = collectPath;
}
else
{
- return StringUtility.RemoveExtension(collectPath);
+ bundleName = StringUtility.RemoveExtension(collectPath);
}
+
+ PackRuleResult result = new PackRuleResult(bundleName, DefaultPackRule.AssetBundleFileExtension);
+ return result;
+ }
+
+ bool IPackRule.IsRawFilePackRule()
+ {
+ return false;
}
}
@@ -93,9 +147,16 @@ namespace YooAsset.Editor
[DisplayName("以分组名称作为资源包名")]
public class PackGroup : IPackRule
{
- string IPackRule.GetBundleName(PackRuleData data)
+ PackRuleResult IPackRule.GetPackRuleResult(PackRuleData data)
{
- return data.GroupName;
+ string bundleName = data.GroupName;
+ PackRuleResult result = new PackRuleResult(bundleName, DefaultPackRule.AssetBundleFileExtension);
+ return result;
+ }
+
+ bool IPackRule.IsRawFilePackRule()
+ {
+ return false;
}
}
@@ -106,23 +167,16 @@ namespace YooAsset.Editor
[DisplayName("打包原生文件")]
public class PackRawFile : IPackRule
{
- string IPackRule.GetBundleName(PackRuleData data)
+ PackRuleResult IPackRule.GetPackRuleResult(PackRuleData data)
{
- string extension = StringUtility.RemoveFirstChar(Path.GetExtension(data.AssetPath));
- if (extension == EAssetFileExtension.unity.ToString() || extension == EAssetFileExtension.prefab.ToString() ||
- extension == EAssetFileExtension.mat.ToString() || extension == EAssetFileExtension.controller.ToString() ||
- extension == EAssetFileExtension.fbx.ToString() || extension == EAssetFileExtension.anim.ToString() ||
- extension == EAssetFileExtension.shader.ToString())
- {
- throw new Exception($"{nameof(PackRawFile)} is not support file estension : {extension}");
- }
+ string bundleName = data.AssetPath;
+ PackRuleResult result = new PackRuleResult(bundleName, DefaultPackRule.RawFileExtension);
+ return result;
+ }
- // 注意:原生文件只支持无依赖关系的资源
- string[] depends = AssetDatabase.GetDependencies(data.AssetPath, true);
- if (depends.Length != 1)
- throw new Exception($"{nameof(PackRawFile)} is not support estension : {extension}");
-
- return data.AssetPath;
+ bool IPackRule.IsRawFilePackRule()
+ {
+ return true;
}
}
@@ -132,9 +186,14 @@ namespace YooAsset.Editor
[DisplayName("打包着色器变种集合")]
public class PackShaderVariants : IPackRule
{
- public string GetBundleName(PackRuleData data)
+ public PackRuleResult GetPackRuleResult(PackRuleData data)
{
- return YooAssetSettings.UnityShadersBundleName;
+ return DefaultPackRule.CreateShadersPackRuleResult();
+ }
+
+ bool IPackRule.IsRawFilePackRule()
+ {
+ return false;
}
}
}
\ No newline at end of file
diff --git a/Assets/YooAsset/Editor/AssetBundleCollector/IPackRule.cs b/Assets/YooAsset/Editor/AssetBundleCollector/IPackRule.cs
index c719002..7593baa 100644
--- a/Assets/YooAsset/Editor/AssetBundleCollector/IPackRule.cs
+++ b/Assets/YooAsset/Editor/AssetBundleCollector/IPackRule.cs
@@ -3,7 +3,7 @@ namespace YooAsset.Editor
{
public struct PackRuleData
{
- public string AssetPath;
+ public string AssetPath;
public string CollectPath;
public string GroupName;
@@ -21,14 +21,59 @@ namespace YooAsset.Editor
}
}
+ public struct PackRuleResult
+ {
+ private readonly string _bundleName;
+ private readonly string _bundleExtension;
+
+ public PackRuleResult(string bundleName, string bundleExtension)
+ {
+ _bundleName = bundleName;
+ _bundleExtension = bundleExtension;
+ }
+
+ ///
+ /// 获取主资源包全名称
+ ///
+ public string GetMainBundleName(string packageName, bool uniqueBundleName)
+ {
+ string fullName;
+ string bundleName = EditorTools.GetRegularPath(_bundleName).Replace('/', '_').Replace('.', '_').ToLower();
+ if (uniqueBundleName)
+ fullName = $"{packageName}_{bundleName}.{_bundleExtension}";
+ else
+ fullName = $"{bundleName}.{_bundleExtension}";
+ return fullName.ToLower();
+ }
+
+ ///
+ /// 获取共享资源包全名称
+ ///
+ public string GetShareBundleName(string packageName, bool uniqueBundleName)
+ {
+ string fullName;
+ string bundleName = EditorTools.GetRegularPath(_bundleName).Replace('/', '_').Replace('.', '_').ToLower();
+ if (uniqueBundleName)
+ fullName = $"{packageName}_share_{bundleName}.{_bundleExtension}";
+ else
+ fullName = $"share_{bundleName}.{_bundleExtension}";
+ return fullName.ToLower();
+ }
+ }
+
///
/// 资源打包规则接口
///
public interface IPackRule
{
///
- /// 获取资源打包所属的资源包名称
+ /// 获取打包规则结果
///
- string GetBundleName(PackRuleData data);
+ PackRuleResult GetPackRuleResult(PackRuleData data);
+
+ ///
+ /// 是否为原生文件打包规则
+ ///
+ bool IsRawFilePackRule();
}
}
\ No newline at end of file
diff --git a/Assets/YooAsset/Editor/AssetBundleReporter/VisualViewers/ReporterAssetListViewer.uxml b/Assets/YooAsset/Editor/AssetBundleReporter/VisualViewers/ReporterAssetListViewer.uxml
index 18391ae..a957c06 100644
--- a/Assets/YooAsset/Editor/AssetBundleReporter/VisualViewers/ReporterAssetListViewer.uxml
+++ b/Assets/YooAsset/Editor/AssetBundleReporter/VisualViewers/ReporterAssetListViewer.uxml
@@ -1,10 +1,10 @@
-
+
-
+
diff --git a/Assets/YooAsset/Editor/AssetBundleReporter/VisualViewers/ReporterBundleListViewer.uxml b/Assets/YooAsset/Editor/AssetBundleReporter/VisualViewers/ReporterBundleListViewer.uxml
index 73f0c86..d7434a8 100644
--- a/Assets/YooAsset/Editor/AssetBundleReporter/VisualViewers/ReporterBundleListViewer.uxml
+++ b/Assets/YooAsset/Editor/AssetBundleReporter/VisualViewers/ReporterBundleListViewer.uxml
@@ -1,4 +1,4 @@
-
+
@@ -8,7 +8,7 @@
-
+
diff --git a/Assets/YooAsset/Runtime/PatchSystem/PatchBundle.cs b/Assets/YooAsset/Runtime/PatchSystem/PatchBundle.cs
index fb017fe..7e5e018 100644
--- a/Assets/YooAsset/Runtime/PatchSystem/PatchBundle.cs
+++ b/Assets/YooAsset/Runtime/PatchSystem/PatchBundle.cs
@@ -122,7 +122,7 @@ namespace YooAsset
}
///
- /// 文件名称(远端文件名和内置文件名)
+ /// 文件名称
///
private string _fileName;
public string FileName
@@ -135,6 +135,20 @@ namespace YooAsset
}
}
+ ///
+ /// 文件后缀名
+ ///
+ private string _fileExtension;
+ public string FileExtension
+ {
+ get
+ {
+ if (string.IsNullOrEmpty(_fileExtension))
+ throw new Exception("Should never get here !");
+ return _fileExtension;
+ }
+ }
+
public PatchBundle()
{
@@ -146,7 +160,8 @@ namespace YooAsset
public void ParseBundle(string packageName, int nameStype)
{
PackageName = packageName;
- _fileName = PatchManifestTools.CreateBundleFileName(nameStype, BundleName, FileHash, IsRawFile);
+ _fileExtension = PatchManifestTools.GetRemoteBundleFileExtension(BundleName);
+ _fileName = PatchManifestTools.GetRemoteBundleFileName(nameStype, BundleName, _fileExtension, FileHash);
}
///
diff --git a/Assets/YooAsset/Runtime/PatchSystem/PatchManifestTools.cs b/Assets/YooAsset/Runtime/PatchSystem/PatchManifestTools.cs
index 3ca72ec..10d93e7 100644
--- a/Assets/YooAsset/Runtime/PatchSystem/PatchManifestTools.cs
+++ b/Assets/YooAsset/Runtime/PatchSystem/PatchManifestTools.cs
@@ -155,21 +155,21 @@ namespace YooAsset
}
#endif
- ///
- /// 生成Bundle文件的正式名称
- ///
- public static string CreateBundleFileName(int nameStyle, string bundleName, string fileHash, bool isRawFile)
+ public static string GetRemoteBundleFileExtension(string bundleName)
+ {
+ string fileExtension = Path.GetExtension(bundleName);
+ return fileExtension;
+ }
+ public static string GetRemoteBundleFileName(int nameStyle, string bundleName, string fileExtension, string fileHash)
{
if (nameStyle == 1) //HashName
{
- string fileExtension = isRawFile ? YooAssetSettingsData.Setting.RawBundleFileVariant : YooAssetSettingsData.Setting.AssetBundleFileVariant;
- return StringUtility.Format("{0}.{1}", fileHash, fileExtension);
+ return StringUtility.Format("{0}{1}", fileHash, fileExtension);
}
else if (nameStyle == 4) //BundleName_HashName
{
string fileName = bundleName.Remove(bundleName.LastIndexOf('.'));
- string fileExtension = isRawFile ? YooAssetSettingsData.Setting.RawBundleFileVariant : YooAssetSettingsData.Setting.AssetBundleFileVariant;
- return StringUtility.Format("{0}_{1}.{2}", fileName, fileHash, fileExtension);
+ return StringUtility.Format("{0}_{1}{2}", fileName, fileHash, fileExtension);
}
else
{
diff --git a/Assets/YooAsset/Runtime/Settings/YooAssetSettings.cs b/Assets/YooAsset/Runtime/Settings/YooAssetSettings.cs
index 3dbcdb1..dac7ac6 100644
--- a/Assets/YooAsset/Runtime/Settings/YooAssetSettings.cs
+++ b/Assets/YooAsset/Runtime/Settings/YooAssetSettings.cs
@@ -5,26 +5,11 @@ namespace YooAsset
[CreateAssetMenu(fileName = "YooAssetSettings", menuName = "YooAsset/Create Settings")]
internal class YooAssetSettings : ScriptableObject
{
- ///
- /// AssetBundle文件的后缀名
- ///
- public string AssetBundleFileVariant = "bundle";
-
- ///
- /// 原生文件的后缀名
- ///
- public string RawBundleFileVariant = "rawfile";
-
///
/// 清单文件名称
///
public string PatchManifestFileName = "PatchManifest";
- ///
- /// 资源包名正规化(移除路径分隔符)
- ///
- public bool RegularBundleName = true;
-
///
/// 清单文件头标记
@@ -41,7 +26,7 @@ namespace YooAsset
///
public const string PatchManifestFileVersion = "1.4.0";
-
+
///
/// 缓存的数据文件名称
///
@@ -63,20 +48,9 @@ namespace YooAsset
///
public const string ReportFileName = "BuildReport";
- ///
- /// Unity着色器资源包名称
- ///
- public const string UnityShadersBundleName = "unityshaders";
-
///
/// 内置资源目录名称
///
public const string StreamingAssetsBuildinFolder = "BuildinFiles";
-
-
- ///
- /// 忽略的文件类型
- ///
- public static readonly string[] IgnoreFileExtensions = { "", ".so", ".dll", ".cs", ".js", ".boo", ".meta", ".cginc", ".hlsl" };
}
}
\ No newline at end of file
diff --git a/Assets/YooAsset/Runtime/Settings/YooAssetSettingsData.cs b/Assets/YooAsset/Runtime/Settings/YooAssetSettingsData.cs
index 05cbf2a..f30b5b9 100644
--- a/Assets/YooAsset/Runtime/Settings/YooAssetSettingsData.cs
+++ b/Assets/YooAsset/Runtime/Settings/YooAssetSettingsData.cs
@@ -71,18 +71,5 @@ namespace YooAsset
{
return $"{Setting.PatchManifestFileName}_{packageName}.version";
}
-
- ///
- /// 获取着色器资源包全名称(包含后缀名)
- ///
- public static string GetUnityShadersBundleFullName(bool uniqueBundleName, string packageName)
- {
- string shareBundleName;
- if (uniqueBundleName)
- shareBundleName = $"{packageName.ToLower()}_{YooAssetSettings.UnityShadersBundleName}.{Setting.AssetBundleFileVariant}";
- else
- shareBundleName = $"{YooAssetSettings.UnityShadersBundleName}.{Setting.AssetBundleFileVariant}";
- return shareBundleName.ToLower();
- }
}
}
\ No newline at end of file
diff --git a/Assets/YooAsset/Samples~/Extension Sample/Scripts/Editor/CustomPackRule.cs b/Assets/YooAsset/Samples~/Extension Sample/Scripts/Editor/CustomPackRule.cs
index 653df5a..ebd7a3c 100644
--- a/Assets/YooAsset/Samples~/Extension Sample/Scripts/Editor/CustomPackRule.cs
+++ b/Assets/YooAsset/Samples~/Extension Sample/Scripts/Editor/CustomPackRule.cs
@@ -10,7 +10,7 @@ public class PackEffectTexture : IPackRule
{
private const string PackDirectory = "Assets/Effect/Textures/";
- string IPackRule.GetBundleName(PackRuleData data)
+ PackRuleResult IPackRule.GetPackRuleResult(PackRuleData data)
{
string assetPath = data.AssetPath;
if (assetPath.StartsWith(PackDirectory) == false)
@@ -18,6 +18,43 @@ public class PackEffectTexture : IPackRule
string assetName = Path.GetFileName(assetPath).ToLower();
string firstChar = assetName.Substring(0, 1);
- return $"{PackDirectory}effect_texture_{firstChar}";
+ string bundleName = $"{PackDirectory}effect_texture_{firstChar}";
+ var packRuleResult = new PackRuleResult(bundleName, DefaultPackRule.AssetBundleFileExtension);
+ return packRuleResult;
+ }
+
+ bool IPackRule.IsRawFilePackRule()
+ {
+ return false;
+ }
+}
+
+[DisplayName("打包视频(自定义)")]
+public class PackVideo : IPackRule
+{
+ public PackRuleResult GetPackRuleResult(PackRuleData data)
+ {
+ string bundleName = RemoveExtension(data.AssetPath);
+ string fileExtension = Path.GetExtension(data.AssetPath);
+ fileExtension = fileExtension.Remove(0, 1);
+ PackRuleResult result = new PackRuleResult(bundleName, fileExtension);
+ return result;
+ }
+
+ bool IPackRule.IsRawFilePackRule()
+ {
+ return true;
+ }
+
+ private string RemoveExtension(string str)
+ {
+ if (string.IsNullOrEmpty(str))
+ return str;
+
+ int index = str.LastIndexOf(".");
+ if (index == -1)
+ return str;
+ else
+ return str.Remove(index); //"assets/config/test.unity3d" --> "assets/config/test"
}
}
\ No newline at end of file
diff --git a/Assets/YooAsset/Samples~/Space Shooter/GameScript/Editor/Encryption.cs b/Assets/YooAsset/Samples~/Space Shooter/GameScript/Editor/Encryption.cs
index b69a63f..1b39c2f 100644
--- a/Assets/YooAsset/Samples~/Space Shooter/GameScript/Editor/Encryption.cs
+++ b/Assets/YooAsset/Samples~/Space Shooter/GameScript/Editor/Encryption.cs
@@ -42,7 +42,8 @@ public class FileStreamEncryption : IEncryptionServices
{
public EncryptResult Encrypt(EncryptFileInfo fileInfo)
{
- if (fileInfo.BundleName.Contains("gameres_music"))
+ // LoadFromStream
+ if (fileInfo.BundleName.Contains("_gameres_audio"))
{
var fileData = File.ReadAllBytes(fileInfo.FilePath);
for (int i = 0; i < fileData.Length; i++)
@@ -55,7 +56,22 @@ public class FileStreamEncryption : IEncryptionServices
result.EncryptedData = fileData;
return result;
}
- else
+
+ // LoadFromFileOffset
+ if (fileInfo.BundleName.Contains("_gameres_uiimage"))
+ {
+ var fileData = File.ReadAllBytes(fileInfo.FilePath);
+ int offset = 32;
+ var temper = new byte[fileData.Length + offset];
+ Buffer.BlockCopy(fileData, 0, temper, offset, fileData.Length);
+
+ EncryptResult result = new EncryptResult();
+ result.LoadMethod = EBundleLoadMethod.LoadFromFileOffset;
+ result.EncryptedData = temper;
+ return result;
+ }
+
+ // Normal
{
EncryptResult result = new EncryptResult();
result.LoadMethod = EBundleLoadMethod.Normal;
diff --git a/Assets/YooAsset/package.json b/Assets/YooAsset/package.json
index eda5570..03ceb65 100644
--- a/Assets/YooAsset/package.json
+++ b/Assets/YooAsset/package.json
@@ -1,7 +1,7 @@
{
"name": "com.tuyoogame.yooasset",
"displayName": "YooAsset",
- "version": "1.4.4-preview",
+ "version": "1.4.5-preview",
"unity": "2019.4",
"description": "unity3d resources management system.",
"author": {
diff --git a/Docs/AssetBundleDeployer.md b/Docs/AssetBundleDeployer.md
index 96f53ce..f356a5a 100644
--- a/Docs/AssetBundleDeployer.md
+++ b/Docs/AssetBundleDeployer.md
@@ -20,3 +20,6 @@ CDN
└─v2.0
````
+**游戏版本说明**
+
+v1.0 代表的是游戏版本,不是资源版本。在没有更换安装包的前提下,不需要递增这个游戏版本。每次生成的补丁包只需要覆盖掉当前游戏版本目录下即可。
diff --git a/Docs/Image/Samples-img3.jpg b/Docs/Image/Samples-img3.jpg
new file mode 100644
index 0000000..e44bf67
Binary files /dev/null and b/Docs/Image/Samples-img3.jpg differ
diff --git a/Docs/Samples.md b/Docs/Samples.md
index d6759e9..f3686de 100644
--- a/Docs/Samples.md
+++ b/Docs/Samples.md
@@ -17,3 +17,9 @@
1. Space Shooter在导入完成后,打开YooAsset->AssetBundle Collector窗口。
1. 点击修复按钮,然后点击Save按钮保存配置,最后关闭窗口。
3. 找到Boot.scene场景启动游戏。
+
+#### 太空战机项目
+
+首次需要在项目里手动添加Tags才可以保证真机演示正常运行。
+
+![image](./Image/Samples-img3.jpg)
diff --git a/Docs/ShaderVariantCollector.md b/Docs/ShaderVariantCollector.md
index f77256e..1e8de9a 100644
--- a/Docs/ShaderVariantCollector.md
+++ b/Docs/ShaderVariantCollector.md
@@ -4,6 +4,8 @@
点击搜集变种按钮开始收集,请耐心等待结束。
+**注意:在收集完成之后,需要将生成的shadervariants文件配置到收集界面(AssetBundle Collector)。**
+
### Jenkins支持
```c#