update editor code

修复开启UniqueBundleName选项后,SBP构建报错的问题。
pull/62/head
hevinci 2022-12-21 17:11:09 +08:00
parent 3b1a8beadf
commit f771a98f25
5 changed files with 17 additions and 31 deletions

View File

@ -175,8 +175,7 @@ namespace YooAsset.Editor
if (IsShaderAsset) if (IsShaderAsset)
{ {
string shareBundleName = YooAssetSettingsData.GetUnityShadersBundleFullName(); _shareBundleName = YooAssetSettingsData.GetUnityShadersBundleFullName(uniqueBundleName, packageName);
_shareBundleName = EditorTools.GetRegularPath(shareBundleName).ToLower();
} }
else else
{ {
@ -188,14 +187,12 @@ namespace YooAsset.Editor
bundleName = EditorTools.GetRegularPath(bundleName).Replace('/', '_').Replace('.', '_').ToLower(); bundleName = EditorTools.GetRegularPath(bundleName).Replace('/', '_').Replace('.', '_').ToLower();
else else
bundleName = EditorTools.GetRegularPath(bundleName).ToLower(); bundleName = EditorTools.GetRegularPath(bundleName).ToLower();
_shareBundleName = $"share_{bundleName}.{YooAssetSettingsData.Setting.AssetBundleFileVariant}";
}
}
if (uniqueBundleName) if (uniqueBundleName)
{ _shareBundleName = $"{packageName.ToLower()}_share_{bundleName}.{YooAssetSettingsData.Setting.AssetBundleFileVariant}";
if (string.IsNullOrEmpty(_shareBundleName) == false) else
_shareBundleName = $"{packageName.ToLower()}_{_shareBundleName}"; _shareBundleName = $"share_{bundleName}.{YooAssetSettingsData.Setting.AssetBundleFileVariant}";
}
} }
} }
else else
@ -203,12 +200,17 @@ namespace YooAsset.Editor
if (IsRawAsset) if (IsRawAsset)
{ {
string mainBundleName = $"{_mainBundleName}.{YooAssetSettingsData.Setting.RawFileVariant}"; string mainBundleName = $"{_mainBundleName}.{YooAssetSettingsData.Setting.RawFileVariant}";
_mainBundleName = EditorTools.GetRegularPath(mainBundleName).ToLower(); _mainBundleName = mainBundleName.ToLower();
} }
else else
{ {
string mainBundleName = $"{_mainBundleName}.{YooAssetSettingsData.Setting.AssetBundleFileVariant}"; string mainBundleName = $"{_mainBundleName}.{YooAssetSettingsData.Setting.AssetBundleFileVariant}";
_mainBundleName = EditorTools.GetRegularPath(mainBundleName).ToLower(); ; _mainBundleName = mainBundleName.ToLower(); ;
}
if (uniqueBundleName)
{
_mainBundleName = $"{packageName.ToLower()}_{_mainBundleName}";
} }
} }
} }

View File

@ -33,7 +33,7 @@ namespace YooAsset.Editor
// 开始构建 // 开始构建
IBundleBuildResults buildResults; IBundleBuildResults buildResults;
var buildParameters = buildParametersContext.GetSBPBuildParameters(); var buildParameters = buildParametersContext.GetSBPBuildParameters();
var shadersBunldeName = YooAssetSettingsData.GetUnityShadersBundleFullName(); var shadersBunldeName = YooAssetSettingsData.GetUnityShadersBundleFullName(buildMapContext.UniqueBundleName, buildParametersContext.Parameters.PackageName);
var taskList = SBPBuildTasks.Create(shadersBunldeName); var taskList = SBPBuildTasks.Create(shadersBunldeName);
ReturnCode exitCode = ContentPipeline.BuildAssetBundles(buildParameters, buildContent, out buildResults, taskList); ReturnCode exitCode = ContentPipeline.BuildAssetBundles(buildParameters, buildContent, out buildResults, taskList);
if (exitCode < 0) if (exitCode < 0)

View File

@ -42,12 +42,13 @@ namespace YooAsset.Editor
patchManifest.AssetList = GetAllPatchAsset(context, patchManifest); patchManifest.AssetList = GetAllPatchAsset(context, patchManifest);
// 更新Unity内置资源包的引用关系 // 更新Unity内置资源包的引用关系
string shadersBunldeName = YooAssetSettingsData.GetUnityShadersBundleFullName(buildMapContext.UniqueBundleName, buildParameters.PackageName);
if (buildParameters.BuildPipeline == EBuildPipeline.ScriptableBuildPipeline) if (buildParameters.BuildPipeline == EBuildPipeline.ScriptableBuildPipeline)
{ {
if (buildParameters.BuildMode == EBuildMode.IncrementalBuild) if (buildParameters.BuildMode == EBuildMode.IncrementalBuild)
{ {
var buildResultContext = context.GetContextObject<TaskBuilding_SBP.BuildResultContext>(); var buildResultContext = context.GetContextObject<TaskBuilding_SBP.BuildResultContext>();
UpdateBuiltInBundleReference(patchManifest, buildResultContext.Results); UpdateBuiltInBundleReference(patchManifest, buildResultContext.Results, shadersBunldeName);
} }
} }
@ -165,10 +166,9 @@ namespace YooAsset.Editor
/// <summary> /// <summary>
/// 更新Unity内置资源包的引用关系 /// 更新Unity内置资源包的引用关系
/// </summary> /// </summary>
private void UpdateBuiltInBundleReference(PatchManifest patchManifest, IBundleBuildResults buildResults) private void UpdateBuiltInBundleReference(PatchManifest patchManifest, IBundleBuildResults buildResults, string shadersBunldeName)
{ {
// 获取所有依赖着色器资源包的资源包列表 // 获取所有依赖着色器资源包的资源包列表
string shadersBunldeName = YooAssetSettingsData.GetUnityShadersBundleFullName();
List<string> shaderBundleReferenceList = new List<string>(); List<string> shaderBundleReferenceList = new List<string>();
foreach (var valuePair in buildResults.BundleInfos) foreach (var valuePair in buildResults.BundleInfos)
{ {

View File

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

View File

@ -36,14 +36,6 @@ namespace YooAsset.Editor
public void SetCollectAssets(List<CollectAssetInfo> collectAssets) public void SetCollectAssets(List<CollectAssetInfo> collectAssets)
{ {
CollectAssets = collectAssets; CollectAssets = collectAssets;
if (UniqueBundleName)
{
foreach (var collectAsset in CollectAssets)
{
collectAsset.BundleNameAppendPackageName(PackageName);
}
}
} }
} }
} }