Created
May 20, 2013 00:04
-
-
Save masa795/5609646 to your computer and use it in GitHub Desktop.
AssetDatabase.GetCachedIconを使用してアイコンとラベルを表示する。
AssetDatabase.GetAllAssetPaths()で取得するのでファイル数が多いと重くなるかも。
GUIContentを使用してTextFieldのラベルにアイコンを表示する。
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 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