From a4ffa580b7bcc81c51174bac5cee3677ab11bf77 Mon Sep 17 00:00:00 2001 From: hevinci Date: Wed, 1 Nov 2023 11:02:46 +0800 Subject: [PATCH] update asset bundle builder remove RemoveSpriteAtlasRedundancy task. --- .../ScriptableBuildPipeline/BuildTasksEx.cs | 67 ------------------- .../BuildTasksEx.cs.meta | 11 --- .../ScriptableBuildPipeline/SBPBuildTasks.cs | 1 - 3 files changed, 79 deletions(-) delete mode 100644 Assets/YooAsset/Editor/AssetBundleBuilder/BuildPipeline/ScriptableBuildPipeline/BuildTasksEx.cs delete mode 100644 Assets/YooAsset/Editor/AssetBundleBuilder/BuildPipeline/ScriptableBuildPipeline/BuildTasksEx.cs.meta diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildPipeline/ScriptableBuildPipeline/BuildTasksEx.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildPipeline/ScriptableBuildPipeline/BuildTasksEx.cs deleted file mode 100644 index fe0585d..0000000 --- a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildPipeline/ScriptableBuildPipeline/BuildTasksEx.cs +++ /dev/null @@ -1,67 +0,0 @@ -using System.Collections.Generic; -using UnityEditor.Build.Content; -using UnityEngine.U2D; -using UnityEditor.Build.Pipeline.Injector; -using UnityEditor.Build.Pipeline.Interfaces; -using UnityEngine; - -namespace UnityEditor.Build.Pipeline.Tasks -{ - /// - /// Ref https://zhuanlan.zhihu.com/p/586918159 - /// - public class RemoveSpriteAtlasRedundancy : IBuildTask - { - public int Version => 1; - - [InjectContext] - IBundleWriteData writeDataParam; - - public ReturnCode Run() - { -#if UNITY_2020_3_OR_NEWER - BundleWriteData writeData = (BundleWriteData)writeDataParam; - - // 图集引用的精灵图片集合 - HashSet spriteGuids = new HashSet(); - 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); - } - } - } - } - - // 移除图集引用的精力图片对象 - foreach (var pair in writeData.FileToObjects) - { - List 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) - { - // 删除图集散图的冗余纹理 - objectIdentifiers.RemoveAt(i); - } - } - } - } -#endif - - return ReturnCode.Success; - } - } -} \ No newline at end of file diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildPipeline/ScriptableBuildPipeline/BuildTasksEx.cs.meta b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildPipeline/ScriptableBuildPipeline/BuildTasksEx.cs.meta deleted file mode 100644 index 015455c..0000000 --- a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildPipeline/ScriptableBuildPipeline/BuildTasksEx.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: f01d5c82be95c8f4b93aeefc0454ae5c -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildPipeline/ScriptableBuildPipeline/SBPBuildTasks.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildPipeline/ScriptableBuildPipeline/SBPBuildTasks.cs index 71056e6..f928f1b 100644 --- a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildPipeline/ScriptableBuildPipeline/SBPBuildTasks.cs +++ b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildPipeline/ScriptableBuildPipeline/SBPBuildTasks.cs @@ -33,7 +33,6 @@ namespace UnityEditor.Build.Pipeline.Tasks // Packing buildTasks.Add(new GenerateBundlePacking()); - buildTasks.Add(new RemoveSpriteAtlasRedundancy()); // Fix for SpriteAtlas Redundancy buildTasks.Add(new UpdateBundleObjectLayout()); buildTasks.Add(new GenerateBundleCommands()); buildTasks.Add(new GenerateSubAssetPathMaps());