Skip to content

Instantly share code, notes, and snippets.

@dimmduh
Created August 19, 2017 12:44
Show Gist options
  • Select an option

  • Save dimmduh/15ef0a58c251eaa8fb277ba862228e88 to your computer and use it in GitHub Desktop.

Select an option

Save dimmduh/15ef0a58c251eaa8fb277ba862228e88 to your computer and use it in GitHub Desktop.
List of textures by atlases made by Unity sprite packer.
using System.Collections;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
namespace IOGames.Utils
{
public class SpritePackerIndex : MonoBehaviour
{
[MenuItem("IO Games/Sprite Packer Index")]
// Use this for initialization
public static void run()
{
var sprites = AssetDatabase.FindAssets("t:Sprite");
var result = new Dictionary<string, List<string>>();
foreach (var sprite in sprites)
{
var path = AssetDatabase.GUIDToAssetPath(sprite);
var ti = AssetImporter.GetAtPath(path) as TextureImporter;
var tag = ti.spritePackingTag;
if (!string.IsNullOrEmpty(tag))
{
if (!result.ContainsKey(tag))
{
result.Add(tag, new List<string>());
}
result[tag].Add(path);
}
}
foreach (var item in result)
{
Debug.LogFormat("=====================\nTag: {0}", item.Key);
foreach (var path in item.Value)
{
Debug.LogFormat("--- {0}", AssetDatabase.LoadAssetAtPath<Object>(path));
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment