File tree 1 file changed +28
-0
lines changed
UnityProject/Assets/TEngine/Editor/Postprocessor 1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change 4
4
using UnityEditor ;
5
5
using UnityEditor . U2D ;
6
6
using UnityEngine ;
7
+ using UnityEngine . U2D ;
7
8
using Object = UnityEngine . Object ;
8
9
9
10
/// <summary>
@@ -55,6 +56,33 @@ public static void Init()
55
56
}
56
57
57
58
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 ;
58
86
}
59
87
60
88
public static void CheckDirty ( )
You can’t perform that action at this time.
0 commit comments