Skip to content

Commit ff613e4

Browse files
committed
更新修复导入图集初始化信息不全的bug
更新修复导入图集初始化信息不全的bug
1 parent fea1ae2 commit ff613e4

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

UnityProject/Assets/TEngine/Editor/Postprocessor/SpritePostprocessor.cs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using UnityEditor;
55
using UnityEditor.U2D;
66
using UnityEngine;
7+
using UnityEngine.U2D;
78
using Object = UnityEngine.Object;
89

910
/// <summary>
@@ -55,6 +56,33 @@ public static void Init()
5556
}
5657

5758
EditorApplication.update += CheckDirty;
59+
60+
//读取所有图集信息
61+
string[] findAssets = AssetDatabase.FindAssets("t:SpriteAtlas", new[] { NormalAtlasDir });
62+
foreach (var findAsset in findAssets)
63+
{
64+
var path = AssetDatabase.GUIDToAssetPath(findAsset);
65+
SpriteAtlas sa = AssetDatabase.LoadAssetAtPath(path, typeof(SpriteAtlas)) as SpriteAtlas;
66+
if (sa == null)
67+
{
68+
Debug.LogError($"加载图集数据{path}失败");
69+
continue;
70+
}
71+
72+
string atlasName = Path.GetFileNameWithoutExtension(path);
73+
var objects = sa.GetPackables();
74+
foreach (var o in objects)
75+
{
76+
if (!m_allASprites.TryGetValue(atlasName, out var list))
77+
{
78+
list = new List<string>();
79+
m_allASprites.Add(atlasName, list);
80+
}
81+
list.Add(AssetDatabase.GetAssetPath(o));
82+
}
83+
}
84+
85+
m_inited = true;
5886
}
5987

6088
public static void CheckDirty()

0 commit comments

Comments
 (0)