Last active
December 15, 2021 23:43
-
-
Save Unity-Javier/670752cb02b4c92e451665631fc2ea7d to your computer and use it in GitHub Desktop.
Output the Distribution of Assets in a CSV friendly format
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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