assetPath | 読み込むアセットのファイルシステム上のパス |
assetPath
のメインアセットオブジェクトのタイプを返します。
すべてのパスは、例えば "Assets/MyTextures/hello.png" のような Project フォルダーに対する相対パスです。
using System.Collections.Generic; using UnityEngine; using UnityEditor;
public class AssetDatabaseExamples : MonoBehaviour { [MenuItem("AssetDatabase/PrintTypeCount")] static void GetAllAssetTypeCount() { var typeCount = new Dictionary<string, uint>(); //Put all the types that were found in the typeCount dictionary and increment their count foreach (var guid in AssetDatabase.FindAssets("", new []{"Assets"})) { var path = AssetDatabase.GUIDToAssetPath(guid); var typeString = AssetDatabase.GetMainAssetTypeAtPath(path).ToString(); if (typeCount.ContainsKey(typeString)) typeCount[typeString]++; else typeCount.Add(typeString, 1); } //Print types and their count into the Unity Console foreach (var element in typeCount) { Debug.Log(element); } } }