Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
AssetDatabase.GetCachedIconを使用してアイコンとラベルを表示する。 AssetDatabase.GetAllAssetPaths()で取得するのでファイル数が多いと重くなるかも。 GUIContentを使用してTextFieldのラベルにアイコンを表示する。
using UnityEngine;
using UnityEditor;
using System.Collections;
using System.Collections.Generic;
public class FileIconTest : EditorWindow {
Vector2 scrollPosition;
[MenuItem ("Window/File Icon")]
public static void Init () {
FileIconTest.GetWindow<FileIconTest>(false, "FileIcon");
void OnGUI () {
scrollPosition = GUILayout.BeginScrollView(scrollPosition, false, false);
int index = 0;
foreach (string path in AssetDatabase.GetAllAssetPaths())
Texture icon = AssetDatabase.GetCachedIcon(path);
if (icon != null)
GUIContent contents = new GUIContent();
contents.image = icon;
contents.text = index.ToString();
EditorGUILayout.TextField(contents, path);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment