public class AtlasChecker : MonoBehaviour {
[MenuItem("Archon/Check Atlas Sizes")]
static void CheckAtlasesMenuCommand()
{
CheckAtlases();
}
public static void CheckAtlases()
{
string[] assets = Directory.GetFiles(".\\Assets\\Graphics\\Atlases");
int curDirLen = 2;// Directory.GetCurrentDirectory().Length + 1;
float count = 0;
foreach (string asset in assets)
{
count++;
EditorUtility.DisplayProgressBar("Checking atlases", "Please wait...", (count / assets.Length));
if (Path.GetExtension(asset) == ".png")
{
Texture2D atlas
= AssetDatabase
.LoadAssetAtPath(asset
.Substring(curDirLen
).Replace('\\',
'/'),
typeof(Texture2D
)) as Texture2D
;
if (atlas != null)
{
if (atlas.height > 2048 || atlas.width > 2048)
{
Debug.LogWarning("<color=yellow>Atlas \"" + atlas.name + "\" is too big (" + atlas.width + "x" + atlas.height + ")!\nMight cause game to crash on iPad.</color>");
}
}
}
}
EditorUtility.ClearProgressBar();
}
}
class AutoCheckAtlases : AssetPostprocessor
{
private static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths)
{
AtlasChecker.CheckAtlases();
}
}