diff options
author | chai <chaifix@163.com> | 2018-07-10 13:50:31 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2018-07-10 13:50:31 +0800 |
commit | 3bc38cd9ec5629ee59bb134a5d7b57b829c6c61d (patch) | |
tree | b24996e602531dd527398fa85c97a759d771c534 /AssetBrowser.cs | |
parent | 6098343eb702e39c663e6fffebecafa761ff321f (diff) |
+缩略图
Diffstat (limited to 'AssetBrowser.cs')
-rw-r--r-- | AssetBrowser.cs | 48 |
1 files changed, 33 insertions, 15 deletions
diff --git a/AssetBrowser.cs b/AssetBrowser.cs index cf62ffa..748c329 100644 --- a/AssetBrowser.cs +++ b/AssetBrowser.cs @@ -38,6 +38,7 @@ class AssetData png = 0, jpg, bmp, + tga, // Mesh fbx, FBX, @@ -78,6 +79,7 @@ class AssetData } data.Add(GUID); } + Obj = AssetDatabase.LoadAssetAtPath(AssetPath, ObjType); FileInfo finfo = new FileInfo(f.FullName); DiskSize = finfo.Length; DiskSizeStr = EditorUtility.FormatBytes(DiskSize); @@ -91,6 +93,7 @@ class AssetData public long DiskSize; public string DiskSizeStr; public string AssetPath; + public Object Obj = null; public Type ObjType; public string Extension; public AssetType FileType; @@ -108,6 +111,8 @@ class AssetData subType = SubType.jpg; else if (Extension == ".bmp") subType = SubType.bmp; + else if (Extension == ".tga") + subType = SubType.tga; // mesh else if (Extension == ".fbx") subType = SubType.fbx; @@ -123,7 +128,8 @@ class AssetData else if (extension == ".mat") return AssetType.Material; else if (extension == ".asset") return AssetType.Asset; else if (extension == ".fbx" || extension == ".FBX") return AssetType.Mesh; - else if (extension == ".png" || extension == ".jpg" || extension == ".bmp") return AssetType.Texture; + else if (extension == ".png" || extension == ".jpg" || extension == ".bmp" || extension == ".tga") + return AssetType.Texture; else if (extension == ".shader") return AssetType.Shader; else if (extension == ".cs") return AssetType.Script; else if (extension == ".csv") return AssetType.CSV; @@ -160,15 +166,15 @@ class AssetDataManager #region file extensions public static List<string> ValidExtension = new List<string> { - ".unity", // scene - ".prefab", // prefab - ".mat", // material - ".asset", // asset - ".fbx", ".FBX", // mesh - ".png", ".jpg", ".bmp", // texture - ".shader", // shader - ".cs", // script - ".csv" // CSV + ".unity", // scene + ".prefab", // prefab + ".mat", // material + ".asset", // asset + ".fbx", ".FBX", // mesh + ".png", ".jpg", ".bmp", ".tga", // texture + ".shader", // shader + ".cs", // script + ".csv" // CSV }; public string GetExtension(string path) @@ -327,9 +333,9 @@ class Drawer foldout = !foldout; } - public void DrawAssetIcon(Rect rect, AssetData asset) + public void DrawAssetIcon(Rect rect, AssetData asset, bool thumb) { - GUIContent content = EditorGUIUtility.ObjectContent(null, asset.ObjType); + GUIContent content = EditorGUIUtility.ObjectContent(thumb ? asset.Obj : null, asset.ObjType); content.text = asset.Name; GUI.Label(rect, content); } @@ -392,6 +398,13 @@ class AssetBrowser : EditorWindow { private static AssetBrowser editor; private static Drawer drawer; + + private static AssetBrowser Get() + { + if (editor == null) + editor = GetWindow<AssetBrowser>(); + return editor; + } #region file tree private FileTree assetsTree = new FileTree(); @@ -415,6 +428,10 @@ class AssetBrowser : EditorWindow private FileTree.Node selectedNode = null; #endregion + #region thumbs + private bool thumbs = false; + #endregion + #region filters private string filterdirectory = ""; private string filterFile = ""; @@ -584,6 +601,7 @@ class AssetBrowser : EditorWindow ProcessTree(); EditorUtility.DisplayDialog("Load done", "Load done", "OK"); } + drawer.DrawCheckBox(new Rect(420, offsetY, 60, kLineHeight), "thumbs", thumbs, ref thumbs); } private void OnFilters() @@ -770,7 +788,7 @@ class AssetBrowser : EditorWindow drawer.DrawPing(new Rect(hierachy * kTabWidth, offsetY, 10, kLineHeight), ref ping); if (ping) { - Object obj = AssetDatabase.LoadAssetAtPath(asset.AssetPath, asset.ObjType); + Object obj = asset.Obj; if (obj) { EditorGUIUtility.PingObject(obj); @@ -796,7 +814,7 @@ class AssetBrowser : EditorWindow if (selectedNode == node) drawer.SetTextColor(Color.white); // draw asset icon - drawer.DrawAssetIcon(new Rect(hierachy * kTabWidth + 19 + 7, offsetY, ColumWidth[Colum.Name], kLineHeight), asset); + drawer.DrawAssetIcon(new Rect(hierachy * kTabWidth + 19 + 7, offsetY, ColumWidth[Colum.Name], kLineHeight), asset, thumbs); // draw reference count drawer.DrawLabel(new Rect(ColumOffsetX[Colum.Ref], offsetY, 100, kLineHeight), asset.RefCount.ToString()); // draw referenced count @@ -1009,7 +1027,7 @@ public class AssetReverse : EditorWindow if (assetDataManager.AllAssets.TryGetValue(guid, out resource)) { drawer.DrawBackground(new Rect(0, yoffset, ContentWidth, kLineHeight), (count & 1) == 1 ? drawer.ColorHeavy : drawer.ColorLight); - drawer.DrawAssetIcon(new Rect(0, yoffset, 1000, kLineHeight), resource); + drawer.DrawAssetIcon(new Rect(0, yoffset, 1000, kLineHeight), resource, true); drawer.DrawLabel(new Rect(kColumOffset[Colums.cLocation], yoffset, 1000, kLineHeight), resource.AssetPath); yoffset += kLineHeight; ContentHeight += kLineHeight; |