Compare commits

...

2 Commits

Author SHA1 Message Date
何冠峰
a5138b9846 feat : 在SBP构建管线里,自动建立主资源对象对图集的依赖关系 2025-08-29 19:06:55 +08:00
何冠峰
e1b6458c26 update space shooter 2025-08-29 19:04:29 +08:00
12 changed files with 317 additions and 64 deletions

View File

@@ -13,6 +13,11 @@ namespace YooAsset.Editor
/// </summary>
private readonly Dictionary<string, BuildBundleInfo> _bundleInfoDic = new Dictionary<string, BuildBundleInfo>(10000);
/// <summary>
/// 图集资源集合
/// </summary>
public readonly List<BuildAssetInfo> SpriteAtlasAssetList = new List<BuildAssetInfo>(10000);
/// <summary>
/// 未被依赖的资源列表
/// </summary>
@@ -60,6 +65,12 @@ namespace YooAsset.Editor
newBundleInfo.PackAsset(assetInfo);
_bundleInfoDic.Add(bundleName, newBundleInfo);
}
// 统计所有的精灵图集
if (assetInfo.AssetInfo.IsSpriteAtlas())
{
SpriteAtlasAssetList.Add(assetInfo);
}
}
/// <summary>

View File

@@ -2,6 +2,7 @@
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using UnityEditor;
namespace YooAsset.Editor
{
@@ -301,15 +302,28 @@ namespace YooAsset.Editor
#region YOOASSET_LEGACY_DEPENDENCY
private void ProcessBuiltinBundleDependency(BuildContext context, PackageManifest manifest)
{
// 注意:初始化资源清单建立引用关系
ManifestTools.InitManifest(manifest);
// 注意:如果是可编程构建管线,需要补充内置资源包
// 注意:该步骤依赖前面的操作!
var buildResultContext = context.TryGetContextObject<TaskBuilding_SBP.BuildResultContext>();
if (buildResultContext != null)
{
// 注意:初始化资源清单建立引用关系
ManifestTools.InitManifest(manifest);
ProcessBuiltinBundleReference(context, manifest, buildResultContext.BuiltinShadersBundleName);
ProcessBuiltinBundleReference(context, manifest, buildResultContext.MonoScriptsBundleName);
// 注意:检测是否开启图集模式
// 说明:需要记录主资源对象对图集的依赖关系!
if (EditorSettings.spritePackerMode != SpritePackerMode.Disabled)
{
var buildMapContext = context.GetContextObject<BuildMapContext>();
foreach (var spriteAtlasAsset in buildMapContext.SpriteAtlasAssetList)
{
string spriteAtlasBundleName = spriteAtlasAsset.BundleName;
ProcessBuiltinBundleReference(context, manifest, spriteAtlasBundleName);
}
}
}
}
private void ProcessBuiltinBundleReference(BuildContext context, PackageManifest manifest, string builtinBundleName)

View File

@@ -62,6 +62,17 @@ namespace YooAsset.Editor
return false;
}
/// <summary>
/// 是否为图集资源
/// </summary>
public bool IsSpriteAtlas()
{
if (AssetType == typeof(UnityEngine.U2D.SpriteAtlas))
return true;
else
return false;
}
public int CompareTo(AssetInfo other)
{
return this.AssetPath.CompareTo(other.AssetPath);

View File

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 686 KiB

View File

@@ -0,0 +1,153 @@
fileFormatVersion: 2
guid: ddd541edadc7b104393f8973da3a3f7f
TextureImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 13
mipmaps:
mipMapMode: 0
enableMipMap: 0
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
flipGreenChannel: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
vTOnly: 0
ignoreMipmapLimit: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: 1
aniso: 1
mipBias: 0
wrapU: 1
wrapV: 1
wrapW: 0
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 1
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 100
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 8
textureShape: 1
singleChannelComponent: 0
flipbookRows: 1
flipbookColumns: 1
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
ignorePngGamma: 0
applyGammaDecoding: 0
swizzle: 50462976
cookieLightType: 0
platformSettings:
- serializedVersion: 3
buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Standalone
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: iPhone
maxTextureSize: 1024
resizeAlgorithm: 0
textureFormat: 4
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 1
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: WebGL
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Android
maxTextureSize: 1024
resizeAlgorithm: 0
textureFormat: 4
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 1
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
bones: []
spriteID: 5e97eb03825dee720800000000000000
internalID: 0
vertices: []
indices:
edges: []
weights: []
secondaryTextures: []
nameFileIdTable: {}
mipmapLimitGroupName:
pSDRemoveMatte: 0
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,48 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!687078895 &4343727234628468602
SpriteAtlas:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: atlas_frame
m_EditorData:
serializedVersion: 2
textureSettings:
serializedVersion: 2
anisoLevel: 1
compressionQuality: 50
maxTextureSize: 2048
textureCompression: 0
filterMode: 1
generateMipMaps: 0
readable: 0
crunchedCompression: 0
sRGB: 1
platformSettings: []
packingSettings:
serializedVersion: 2
padding: 2
blockOffset: 1
allowAlphaSplitting: 0
enableRotation: 0
enableTightPacking: 0
enableAlphaDilation: 0
secondaryTextureSettings: {}
variantMultiplier: 1
packables:
- {fileID: 102900000, guid: 9b4f533c5ce702848a2d979731b313a5, type: 3}
bindAsDefault: 1
isAtlasV2: 0
cachedData: {fileID: 0}
packedSpriteRenderDataKeys:
- ddd541edadc7b104393f8973da3a3f7f: 21300000
m_MasterAtlas: {fileID: 0}
m_PackedSprites:
- {fileID: 21300000, guid: ddd541edadc7b104393f8973da3a3f7f, type: 3}
m_PackedSpriteNamesToIndex:
- frame
m_RenderDataMap: {}
m_Tag: atlas_frame
m_IsVariant: 0

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 999da17edd2fbfe4496de3bbf2c182ec
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 4343727234628468602
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -22,3 +22,11 @@ MonoBehaviour:
- CollectPath: Assets/Samples/Space Shooter/GameRes/EffectArt
WhiteList:
- 1c89236d45255234ebd1d39657ff7e02
- ScannerGUID: e5322d5d-394f-47ea-82ab-82199f8d20d8
ScannerName: Default Scanner
ScannerDesc:
ScannerSchema: 5c2e5b350351d674891ef1a046654bcf
SaveDirectory:
Collectors:
- CollectPath:
WhiteList: []

View File

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<root Version="v2.1">
<root Version="v2025.8.28">
<Common ShowPackageView="False" ShowEditorAlias="False" UniqueBundleName="False" />
<Package PackageName="DefaultPackage" PackageDesc="" AutoAddressable="True" LocationToLower="False" IncludeAssetGUID="False" IgnoreRuleName="NormalIgnoreRule">
<Package PackageName="DefaultPackage" PackageDesc="" AutoAddressable="True" SupportExtensionless="True" LocationToLower="False" IncludeAssetGUID="False" IgnoreRuleName="NormalIgnoreRule">
<Group GroupActiveRule="EnableGroup" GroupName="battle" GroupDesc="战斗" AssetTags="">
<Collector CollectPath="Assets/Samples/Space Shooter/GameRes/Effect" CollectGUID="80d76514758554baaa96a9efffe9f3ef" CollectType="MainAssetCollector" AddressRule="AddressByFileName" PackRule="PackDirectory" FilterRule="CollectAll" UserData="" AssetTags="" />
<Collector CollectPath="Assets/Samples/Space Shooter/GameRes/Entity" CollectGUID="4d7c84745db8e884f8020a8c5356e67c" CollectType="MainAssetCollector" AddressRule="AddressByFileName" PackRule="PackDirectory" FilterRule="CollectAll" UserData="" AssetTags="" />

View File

@@ -19,20 +19,53 @@ MonoBehaviour:
- PackageName: DefaultPackage
PackageDesc:
EnableAddressable: 1
SupportExtensionless: 1
LocationToLower: 0
IncludeAssetGUID: 0
AutoCollectShaders: 1
IgnoreRuleName: NormalIgnoreRule
Groups:
- GroupName: config
GroupDesc: "\u914D\u7F6E"
- GroupName: battle
GroupDesc: "\u6218\u6597"
AssetTags:
ActiveRuleName: EnableGroup
Collectors:
- CollectPath: Assets/Samples/Space Shooter/GameRes/Config
CollectorGUID: c8af3b4cae4ac0b45920b18120610006
- CollectPath: Assets/Samples/Space Shooter/GameRes/Effect
CollectorGUID: 80d76514758554baaa96a9efffe9f3ef
CollectorType: 0
AddressRuleName: AddressByFileName
PackRuleName: PackSeparately
FilterRuleName: CollectAll
AssetTags:
UserData:
- CollectPath: Assets/Samples/Space Shooter/GameRes/Entity
CollectorGUID: 4d7c84745db8e884f8020a8c5356e67c
CollectorType: 0
AddressRuleName: AddressByFileName
PackRuleName: PackSeparately
FilterRuleName: CollectAll
AssetTags:
UserData:
- CollectPath: Assets/Samples/Space Shooter/GameRes/Audio
CollectorGUID: 306075fbe00b24251b6c889984a7a7d5
CollectorType: 0
AddressRuleName: AddressByFileName
PackRuleName: PackSeparately
FilterRuleName: CollectAll
AssetTags:
UserData:
- CollectPath: Assets/Samples/Space Shooter/GameRes/EffectArt
CollectorGUID: 08d38891fe56f75448d95b93bf3e6c5c
CollectorType: 2
AddressRuleName: AddressByFileName
PackRuleName: PackDirectory
FilterRuleName: CollectAll
AssetTags:
UserData:
- CollectPath: Assets/Samples/Space Shooter/GameRes/EntityArt
CollectorGUID: b79178f10b84c764f8c91480b4fdabe8
CollectorType: 2
AddressRuleName: AddressByFileName
PackRuleName: PackDirectory
FilterRuleName: CollectAll
AssetTags:
@@ -58,54 +91,9 @@ MonoBehaviour:
FilterRuleName: CollectShaderVariants
AssetTags:
UserData:
- GroupName: battle
GroupDesc: "\u6218\u6597"
AssetTags: battle
ActiveRuleName: EnableGroup
Collectors:
- CollectPath: Assets/Samples/Space Shooter/GameRes/Effect
CollectorGUID: 80d76514758554baaa96a9efffe9f3ef
CollectorType: 0
AddressRuleName: AddressByFileName
PackRuleName: PackDirectory
FilterRuleName: CollectAll
AssetTags:
UserData:
- CollectPath: Assets/Samples/Space Shooter/GameRes/Entity
CollectorGUID: 4d7c84745db8e884f8020a8c5356e67c
CollectorType: 0
AddressRuleName: AddressByFileName
PackRuleName: PackDirectory
FilterRuleName: CollectAll
AssetTags:
UserData:
- CollectPath: Assets/Samples/Space Shooter/GameRes/Audio
CollectorGUID: 306075fbe00b24251b6c889984a7a7d5
CollectorType: 0
AddressRuleName: AddressByFileName
PackRuleName: PackDirectory
FilterRuleName: CollectAll
AssetTags:
UserData:
- CollectPath: Assets/Samples/Space Shooter/GameRes/EffectArt
CollectorGUID: 08d38891fe56f75448d95b93bf3e6c5c
CollectorType: 2
AddressRuleName: AddressByFileName
PackRuleName: PackDirectory
FilterRuleName: CollectAll
AssetTags:
UserData:
- CollectPath: Assets/Samples/Space Shooter/GameRes/EntityArt
CollectorGUID: b79178f10b84c764f8c91480b4fdabe8
CollectorType: 2
AddressRuleName: AddressByFileName
PackRuleName: PackDirectory
FilterRuleName: CollectAll
AssetTags:
UserData:
- GroupName: scene
GroupDesc: "\u573A\u666F"
AssetTags: scene
AssetTags:
ActiveRuleName: EnableGroup
Collectors:
- CollectPath: Assets/Samples/Space Shooter/GameRes/Scene
@@ -126,14 +114,14 @@ MonoBehaviour:
UserData:
- GroupName: ugui
GroupDesc: "\u9762\u677F"
AssetTags: ui
AssetTags:
ActiveRuleName: EnableGroup
Collectors:
- CollectPath: Assets/Samples/Space Shooter/GameRes/UIPanel
CollectorGUID: 12d33f33f3a55224c9c747d7bffa1c68
CollectorType: 0
AddressRuleName: AddressByFileName
PackRuleName: PackDirectory
PackRuleName: PackSeparately
FilterRuleName: CollectAll
AssetTags:
UserData:
@@ -153,14 +141,6 @@ MonoBehaviour:
FilterRuleName: CollectAll
AssetTags:
UserData:
- CollectPath: Assets/Samples/Space Shooter/GameRes/UISpriteAtlas
CollectorGUID: c355c783476322b4cacac98c5e1b46d8
CollectorType: 0
AddressRuleName: AddressByFileName
PackRuleName: PackSeparately
FilterRuleName: CollectAll
AssetTags:
UserData:
- CollectPath: Assets/Samples/Space Shooter/GameRes/UISprite
CollectorGUID: 935d7f20c085cc141a3daf9cacfabfae
CollectorType: 1
@@ -169,3 +149,11 @@ MonoBehaviour:
FilterRuleName: CollectAll
AssetTags:
UserData:
- CollectPath: Assets/Samples/Space Shooter/GameRes/UISpriteAtlas
CollectorGUID: c355c783476322b4cacac98c5e1b46d8
CollectorType: 0
AddressRuleName: AddressByFileName
PackRuleName: PackSeparately
FilterRuleName: CollectAll
AssetTags:
UserData:

View File

@@ -36,6 +36,10 @@ SpriteAtlas:
bindAsDefault: 1
isAtlasV2: 0
cachedData: {fileID: 0}
packedSpriteRenderDataKeys:
- 379c45e0c5ba5e54e8df03f52e4c7680: 21300000
- fcab35236e33438448805a9211b0cc19: 21300000
- 3b8db7241fc8ff54e9dea6fc64cfd7e5: 21300000
m_MasterAtlas: {fileID: 0}
m_PackedSprites:
- {fileID: 21300000, guid: 379c45e0c5ba5e54e8df03f52e4c7680, type: 3}