Skip to content

Instantly share code, notes, and snippets.

@Unity-Javier
Last active December 15, 2021 23:43
Show Gist options
  • Save Unity-Javier/670752cb02b4c92e451665631fc2ea7d to your computer and use it in GitHub Desktop.
Save Unity-Javier/670752cb02b4c92e451665631fc2ea7d to your computer and use it in GitHub Desktop.
Output the Distribution of Assets in a CSV friendly format
using System;
using System.Collections.Generic;
using System.Text;
using UnityEditor;
using UnityEngine;
public class AssetDistribution
{
[MenuItem("AssetDatabase/GetAssetDistributions")]
public static void GetAssetDistribution()
{
var allAssets = AssetDatabase.GetAllAssetPaths();
var importerCounts = new Dictionary<Type, int>();
for(int i = 0; i < allAssets.Length; ++i)
{
int count = 0;
var curImporter = AssetImporter.GetAtPath(allAssets[i]);
if (curImporter == null)
{
Debug.LogWarning($"No importer for asset at path {allAssets[i]}");
continue;
}
var importerType = curImporter.GetType();
importerCounts.TryGetValue(importerType, out count);
importerCounts[importerType] = count + 1;
}
StringBuilder info = new StringBuilder();
foreach(var curType in importerCounts)
{
info.Append(curType.Key);
info.Append(",");
info.Append(curType.Value);
info.AppendLine();
}
info.Append("Total assets: ");
info.Append(allAssets.Length);
Debug.Log(info.ToString());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment