-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathShowUnityIconsWnd
More file actions
109 lines (92 loc) · 2.42 KB
/
ShowUnityIconsWnd
File metadata and controls
109 lines (92 loc) · 2.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine;
using UnityEditor;
using System;
using System.Linq;
using System.Reflection;
class ShowUnityIconsWnd : EditorWindow
{
[MenuItem("Tools/ShowUnityBuildInIcons")]
public static void ShowWindow()
{
EditorWindow.GetWindow(typeof(ShowUnityIconsWnd));
}
private string search = "UI";
List<Texture2D> builtInTexs = new List<Texture2D>();
Dictionary<Texture,bool> dict= new Dictionary<Texture, bool>();
void GetBultinAsset()
{
dict.Clear();
builtInTexs.Clear();
var flags = BindingFlags.Static | BindingFlags.NonPublic;
var info = typeof(EditorGUIUtility).GetMethod("GetEditorAssetBundle", flags);
var bundle = info.Invoke(null, new object[0]) as AssetBundle;
UnityEngine.Object[] objs = bundle.LoadAllAssets<Texture>();
if (null != objs)
{
for (int i = 0; i < objs.Length; i++)
{
if (objs[i] is Texture2D)
{
var texture = objs[i] as Texture2D;
if (!dict.ContainsKey(texture))
{
builtInTexs.Add(texture);
dict.Add(texture,true);
}
}
}
}
}
void Awake()
{
GetBultinAsset();
}
Vector2 scrollPos = Vector2.zero;
private const int LINE_HEIGHT = 40;
void OnGUI()
{
GUILayout.BeginHorizontal();
search = EditorGUILayout.TextField("search ", search);
EditorGUILayout.Vector3Field("scrollPos",scrollPos);
GUILayout.EndHorizontal();
GUILayout.Label("TotalItem : "+builtInTexs.Count);
scrollPos = EditorGUILayout.BeginScrollView(scrollPos);
int drawIndex = 0;
for (int i = 0; i < builtInTexs.Count; i++)
{
var texture = builtInTexs[i];
if (string.IsNullOrEmpty(search) == false && texture.name.Contains(search)==false)
{
continue;
}
if (IsVisible(drawIndex))
{
GUILayout.BeginHorizontal();
GUILayout.Box(texture,GUILayout.Width(LINE_HEIGHT),GUILayout.Height(LINE_HEIGHT));
GUILayout.Label("Index: "+drawIndex,GUILayout.Width(100));
EditorGUILayout.TextField(texture.name);
EditorGUILayout.ObjectField(texture, typeof(Texture2D));
GUILayout.EndHorizontal();
}
else
{
//those not visible item only need to take space
GUILayout.Space(LINE_HEIGHT);
}
drawIndex++;
}
EditorGUILayout.EndScrollView();
}
bool IsVisible(int index)
{
var pos = index * LINE_HEIGHT;
if (pos >= scrollPos.y && pos < scrollPos.y + position.height)
{
return true;
}
return false;
}
}