Skip to content

Instantly share code, notes, and snippets.

@masa795
Created May 20, 2013 00:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save masa795/5609646 to your computer and use it in GitHub Desktop.
Save masa795/5609646 to your computer and use it in GitHub Desktop.
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)
{
++index;
GUILayout.BeginHorizontal();
GUIContent contents = new GUIContent();
contents.image = icon;
contents.text = index.ToString();
EditorGUILayout.TextField(contents, path);
GUILayout.EndHorizontal();
}
}
GUILayout.EndScrollView();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment