From 31e2d89597c9b9f118f8401132de4db76e9a6e3c Mon Sep 17 00:00:00 2001 From: RayRen Date: Tue, 24 Sep 2019 16:07:16 +0800 Subject: [PATCH] Add file type label in configure panel --- Editor/AssetBundleModel/ABModelAssetInfo.cs | 3 +++ Editor/AssetListTree.cs | 22 ++++++++++++++++++--- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/Editor/AssetBundleModel/ABModelAssetInfo.cs b/Editor/AssetBundleModel/ABModelAssetInfo.cs index b41994b..7ae58bd 100644 --- a/Editor/AssetBundleModel/ABModelAssetInfo.cs +++ b/Editor/AssetBundleModel/ABModelAssetInfo.cs @@ -1,6 +1,7 @@ using UnityEngine; using UnityEditor; using System.Collections.Generic; +using System.IO; using System.Linq; using UnityEditor.IMGUI.Controls; @@ -73,6 +74,7 @@ internal class AssetInfo internal bool isScene { get; set; } internal bool isFolder { get; set; } internal long fileSize; + public readonly string fileType; private HashSet m_Parents; private string m_AssetName; @@ -87,6 +89,7 @@ internal AssetInfo(string inName, string bundleName="") m_Parents = new HashSet(); isScene = false; isFolder = false; + fileType = Path.GetExtension(m_AssetName).Trim('.'); } internal string fullAssetName diff --git a/Editor/AssetListTree.cs b/Editor/AssetListTree.cs index 714ce9e..b524782 100644 --- a/Editor/AssetListTree.cs +++ b/Editor/AssetListTree.cs @@ -24,6 +24,7 @@ private static MultiColumnHeaderState.Column[] GetColumns() new MultiColumnHeaderState.Column(), new MultiColumnHeaderState.Column(), new MultiColumnHeaderState.Column(), + new MultiColumnHeaderState.Column(), new MultiColumnHeaderState.Column() }; retVal[0].headerContent = new GUIContent("Asset", "Short name of asset. For full name select asset and see message below"); @@ -58,6 +59,13 @@ private static MultiColumnHeaderState.Column[] GetColumns() retVal[3].canSort = true; retVal[3].autoResize = false; + retVal[4].headerContent = new GUIContent("Type", "Type of asset"); + retVal[4].minWidth = 50; + retVal[4].width = 100; + retVal[4].maxWidth = 300; + retVal[4].headerTextAlignment = TextAlignment.Left; + retVal[4].canSort = true; + retVal[4].autoResize = true; return retVal; } enum MyColumns @@ -65,21 +73,24 @@ enum MyColumns Asset, Bundle, Size, - Message + Message, + Type } internal enum SortOption { Asset, Bundle, Size, - Message + Message, + Type } SortOption[] m_SortOptions = { SortOption.Asset, SortOption.Bundle, SortOption.Size, - SortOption.Message + SortOption.Message, + SortOption.Type }; internal AssetListTree(TreeViewState state, MultiColumnHeaderState mchs, AssetBundleManageTab ctrl ) : base(state, new MultiColumnHeader(mchs)) @@ -172,6 +183,9 @@ private void CellGUI(Rect cellRect, AssetBundleModel.AssetTreeItem item, int col GUI.DrawTexture(iconRect, icon, ScaleMode.ScaleToFit); } break; + case 4: + DefaultGUI.Label(cellRect, item.asset.fileType, args.selected, args.focused); + break; } GUI.color = oldColor; } @@ -432,6 +446,8 @@ void SortByColumn() return myTypes.Order(l => l.asset.fileSize, ascending); case SortOption.Message: return myTypes.Order(l => l.HighestMessageLevel(), ascending); + case SortOption.Type: + return myTypes.Order(l => l.asset.fileType, ascending); case SortOption.Bundle: default: return myTypes.Order(l => l.asset.bundleName, ascending);