From ff613e413036ac77b8019f82fae590ce0d852423 Mon Sep 17 00:00:00 2001 From: ALEXTANG <574809918@qq.com> Date: Mon, 20 Nov 2023 17:49:08 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E4=BF=AE=E5=A4=8D=E5=AF=BC?= =?UTF-8?q?=E5=85=A5=E5=9B=BE=E9=9B=86=E5=88=9D=E5=A7=8B=E5=8C=96=E4=BF=A1?= =?UTF-8?q?=E6=81=AF=E4=B8=8D=E5=85=A8=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 更新修复导入图集初始化信息不全的bug --- .../Postprocessor/SpritePostprocessor.cs | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/UnityProject/Assets/TEngine/Editor/Postprocessor/SpritePostprocessor.cs b/UnityProject/Assets/TEngine/Editor/Postprocessor/SpritePostprocessor.cs index c93292ae3..6a4250886 100644 --- a/UnityProject/Assets/TEngine/Editor/Postprocessor/SpritePostprocessor.cs +++ b/UnityProject/Assets/TEngine/Editor/Postprocessor/SpritePostprocessor.cs @@ -4,6 +4,7 @@ using UnityEditor; using UnityEditor.U2D; using UnityEngine; +using UnityEngine.U2D; using Object = UnityEngine.Object; /// @@ -55,6 +56,33 @@ public static void Init() } EditorApplication.update += CheckDirty; + + //读取所有图集信息 + string[] findAssets = AssetDatabase.FindAssets("t:SpriteAtlas", new[] { NormalAtlasDir }); + foreach (var findAsset in findAssets) + { + var path = AssetDatabase.GUIDToAssetPath(findAsset); + SpriteAtlas sa = AssetDatabase.LoadAssetAtPath(path, typeof(SpriteAtlas)) as SpriteAtlas; + if (sa == null) + { + Debug.LogError($"加载图集数据{path}失败"); + continue; + } + + string atlasName = Path.GetFileNameWithoutExtension(path); + var objects = sa.GetPackables(); + foreach (var o in objects) + { + if (!m_allASprites.TryGetValue(atlasName, out var list)) + { + list = new List(); + m_allASprites.Add(atlasName, list); + } + list.Add(AssetDatabase.GetAssetPath(o)); + } + } + + m_inited = true; } public static void CheckDirty()