LoginSignup
0
0

More than 5 years have passed since last update.

アセットのアイコンのTextureを取得する

Last updated at Posted at 2015-05-21

以下のコードでアセットのアイコン表示に使われているTextureが取得できる。

Texture iconTexture = AssetDatabase.GetCachedIcon (assetPath);

これでProjectビューみたいなアセット一覧が作れそう。

int selected = 0;
Vector2 scrollPosition = new Vector2 ();
List<string> assetPathList = new List<string> ();
List<GUIContent> contentList = new List<GUIContent>();

...

foreach (string assetPath in assetPathList) {

    Texture iconTexture = AssetDatabase.GetCachedIcon (assetPath);
    GUIContent content = new GUIContent (assetPath, iconTexture);
    contentList.Add (content);
}

scrollPosition = GUILayout.BeginScrollView (scrollPosition, "Box");
selected = GUILayout.SelectionGrid (selected, _searchResultGUIContentList.ToArray(), 1);
GUILayout.EndScrollView ();

asset_list_resize.jpg

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0