Skip to content

Commit

Permalink
Icons added to the bundleDetailList
Browse files Browse the repository at this point in the history
Added bundle icons to the bundles, and asset icons to the individual assets.
Also added / before the dependent assets name, indicating it is continuing from the AssetBundle name and - before the assets in the current selected bundle
  • Loading branch information
AndyMUnity committed Jul 24, 2018
1 parent 49c3af7 commit 2c33e80
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 18 deletions.
11 changes: 5 additions & 6 deletions Editor/AssetBundleManageTab.cs
Original file line number Diff line number Diff line change
Expand Up @@ -166,12 +166,6 @@ internal void OnGUI(Rect pos)
bundleTreeRect.width,
m_Position.height - bundleTreeRect.height - k_SplitterWidth*2));

if( m_DetailsList.m_SelectedDependentAssets != null && m_DetailsList.m_SelectedDependentAssets.Count > 0 )
{
m_AssetList.SetSelection( m_DetailsList.m_SelectedDependentAssets );
m_DetailsList.m_SelectedDependentAssets = new List<string>();
}

//Right half.
float panelLeft = m_HorizontalSplitterRect.x + k_SplitterWidth;
float panelWidth = m_VerticalSplitterRectRight.width - k_SplitterWidth * 2;
Expand Down Expand Up @@ -274,5 +268,10 @@ internal void SetSelectedItems(IEnumerable<AssetBundleModel.AssetInfo> items)
{
m_MessageList.SetItems(items);
}

internal void SetAssetListSelection( List<string> assets )
{
m_AssetList.SetSelection( assets );
}
}
}
29 changes: 17 additions & 12 deletions Editor/BundleDetailList.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using UnityEditor;
using UnityEngine;
using System.Collections.Generic;
using AssetBundleBrowser.AssetBundleModel;
using UnityEditor.IMGUI.Controls;

namespace AssetBundleBrowser
Expand Down Expand Up @@ -79,6 +80,7 @@ internal class BundleDetailList : TreeView
const string k_DependencyEmpty = k_DependencyHeader + " - None";
const string k_MessageHeader = "Messages:";
const string k_MessageEmpty = k_MessageHeader + " - None";
private const string k_ReferencedPrefix = "- ";


internal BundleDetailList(TreeViewState state) : base(state)
Expand Down Expand Up @@ -147,40 +149,39 @@ protected override float GetCustomRowHeight(int row, TreeViewItem item)
return base.GetCustomRowHeight(row, item);
}

public List<string> m_SelectedDependentAssets = null;

protected override void SelectionChanged( IList<int> selectedIds )
{
base.SelectionChanged( selectedIds );
m_SelectedDependentAssets = new List<string>();
List<string> pathList = new List<string>();

for( int i = 0; i < selectedIds.Count; ++i )
{
TreeViewItem item = this.FindItem( selectedIds[i], rootItem );
if( item != null )
{
AddDependentAssetsRecursive( item );
AddDependentAssetsRecursive( item, pathList );
}
}

// TODO better way to select the objects in the right side
AssetBundleBrowserMain.instance.m_ManageTab.SetAssetListSelection( pathList );
}

void AddDependentAssetsRecursive( TreeViewItem item )
void AddDependentAssetsRecursive( TreeViewItem item, List<string> pathList )
{
TogglePathTreeViewItem pathItem = item as TogglePathTreeViewItem;
if( pathItem != null )
{
// TODO better way to determine if it is an asset that indicates it is an asset referencing another asset bundle
if( pathItem.DisplayNamePrefix == "Referenced by - " && m_SelectedDependentAssets.Contains( pathItem.Path ) == false )
if( string.IsNullOrEmpty(pathItem.DisplayNamePrefix) == false && pathList.Contains( pathItem.Path ) == false )
{
m_SelectedDependentAssets.Add( pathItem.Path );
pathList.Add( pathItem.Path );
}
}

if( item.hasChildren )
{
for( int i=0; i<item.children.Count; ++i )
AddDependentAssetsRecursive( item.children[i] );
AddDependentAssetsRecursive( item.children[i], pathList );
}
}

Expand Down Expand Up @@ -221,6 +222,7 @@ internal static TreeViewItem AppendBundleToTree(AssetBundleModel.BundleDataInfo
{
str = itemName + dep.m_BundleName;
TreeViewItem newItem = new TreeViewItem( str.GetHashCode(), 2, dep.m_BundleName );
newItem.icon = Model.GetBundleIcon();
dependency.AddChild(newItem);

Dictionary<string, TogglePathTreeViewItem> toAssetItems = new Dictionary<string, TogglePathTreeViewItem>();
Expand All @@ -232,14 +234,17 @@ internal static TreeViewItem AppendBundleToTree(AssetBundleModel.BundleDataInfo
if( ! toAssetItems.TryGetValue( dep.m_ToAssets[i].fullAssetName, out item ) )
{
str = itemName + dep.m_BundleName + dep.m_ToAssets[i].displayName;
item = new TogglePathTreeViewItem( str.GetHashCode(), 3, dep.m_ToAssets[i].displayName, dep.m_ToAssets[i].fullAssetName );
item = new TogglePathTreeViewItem( str.GetHashCode(), 3, "/"+dep.m_ToAssets[i].displayName, "/"+dep.m_ToAssets[i].fullAssetName );
item.icon = AssetDatabase.GetCachedIcon(dep.m_ToAssets[i].fullAssetName) as Texture2D;
newItem.AddChild( item );
toAssetItems.Add( dep.m_ToAssets[i].fullAssetName, item );
}

str = str + dep.m_FromAssets[i].displayName;
item.AddChild( new TogglePathTreeViewItem( str.GetHashCode(), 4, "Referenced by - ",
dep.m_FromAssets[i].displayName, dep.m_FromAssets[i].fullAssetName ) );
TreeViewItem refItem = new TogglePathTreeViewItem( str.GetHashCode(), 4, k_ReferencedPrefix,
dep.m_FromAssets[i].displayName, dep.m_FromAssets[i].fullAssetName );
refItem.icon = AssetDatabase.GetCachedIcon(dep.m_FromAssets[i].fullAssetName) as Texture2D;
item.AddChild( refItem );
}
}
}
Expand Down

0 comments on commit 2c33e80

Please sign in to comment.