Skip to content

Commit

Permalink
更新修复导入图集初始化信息不全的bug
Browse files Browse the repository at this point in the history
更新修复导入图集初始化信息不全的bug
  • Loading branch information
ALEXTANGXIAO committed Nov 20, 2023
1 parent fea1ae2 commit ff613e4
Showing 1 changed file with 28 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using UnityEditor;
using UnityEditor.U2D;
using UnityEngine;
using UnityEngine.U2D;
using Object = UnityEngine.Object;

/// <summary>
Expand Down Expand Up @@ -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<string>();
m_allASprites.Add(atlasName, list);
}
list.Add(AssetDatabase.GetAssetPath(o));
}
}

m_inited = true;
}

public static void CheckDirty()
Expand Down

0 comments on commit ff613e4

Please sign in to comment.