Skip to content

Commit f247ade

Browse files
committed
added functionality to select an asset in the project from the list
1 parent 5e9f5e5 commit f247ade

File tree

7 files changed

+38
-6
lines changed

7 files changed

+38
-6
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ All notable changes to this package are documented in this file.
44
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
55
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
66

7+
## [1.0.0-pre.2] - 2021-??-??
8+
### Added
9+
- Functionality to select an asset in the project. It's the little magnifying-glass icon next to an asset.
10+
11+
712
## [1.0.0-pre.1] - 2021-08-27
813
### Added
914
- Public release

Editor/AssetDuplicatesTreeView.cs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public TreeViewItem FindItem(RichBuildLayout.Asset asset)
3939

4040
IterateItems(delegate (TreeViewItem i)
4141
{
42-
var b = i as AssetItem;
42+
var b = i as BundleItem;
4343
if (b == null)
4444
return false;
4545

@@ -77,6 +77,7 @@ protected override void OnBuildTree(TreeViewItem rootItem, RichBuildLayout build
7777
{
7878
treeView = this,
7979
assets = list,
80+
path = pair.Key,
8081
id = m_UniqueId++,
8182
depth = rootItem.depth + 1,
8283
displayName = pair.Key,
@@ -88,7 +89,7 @@ protected override void OnBuildTree(TreeViewItem rootItem, RichBuildLayout build
8889
{
8990
categoryItem.size += asset.size;
9091

91-
var assetItem = new AssetItem
92+
var assetItem = new BundleItem
9293
{
9394
treeView = this,
9495
asset = asset,
@@ -104,11 +105,11 @@ protected override void OnBuildTree(TreeViewItem rootItem, RichBuildLayout build
104105

105106

106107
[System.Serializable]
107-
class AssetItem : BaseItem
108+
class BundleItem : BaseItem
108109
{
109110
public RichBuildLayout.Asset asset;
110111

111-
public AssetItem()
112+
public BundleItem()
112113
{
113114
supportsSearch = true;
114115
}
@@ -120,7 +121,7 @@ public override object GetObject()
120121

121122
public override int CompareTo(TreeViewItem other, int column)
122123
{
123-
var otherItem = other as AssetItem;
124+
var otherItem = other as BundleItem;
124125
if (otherItem == null)
125126
return 1;
126127

@@ -152,6 +153,7 @@ class CategoryItem : BaseItem
152153
{
153154
public List<RichBuildLayout.Asset> assets;
154155
public long size;
156+
public string path;
155157

156158
public CategoryItem()
157159
{
@@ -189,6 +191,9 @@ public override void OnGUI(Rect position, int column, bool selected)
189191
switch (column)
190192
{
191193
case ColumnIDs.name:
194+
if (GUI.Button(ButtonSpaceR(ref position), CachedGUIContent(Styles.selectAssetIcon, "Select asset in project"), Styles.iconButtonStyle))
195+
TrySelectAsset(path);
196+
192197
LabelField(position, displayName);
193198
break;
194199

Editor/AssetsTreeView.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,9 @@ public override void OnGUI(Rect position, int column, bool selected)
140140
switch(column)
141141
{
142142
case ColumnIDs.name:
143+
if (GUI.Button(ButtonSpaceR(ref position), CachedGUIContent(Styles.selectAssetIcon, "Select asset in project"), Styles.iconButtonStyle))
144+
TrySelectAsset(asset.name);
145+
143146
LabelField(position, displayName);
144147
break;
145148

Editor/BuildLayoutTreeView.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,15 @@ public void NavigateTo(object target)
390390
treeView.m_Window.NavigateTo(target);
391391
}
392392

393+
protected void TrySelectAsset(string assetPath)
394+
{
395+
var obj = AssetDatabase.LoadMainAssetAtPath(assetPath);
396+
if (obj != null)
397+
Selection.activeObject = obj;
398+
else
399+
treeView.m_Window.ShowNotification(CachedGUIContent($"'{assetPath}' doesn't exist in project."));
400+
}
401+
393402
protected void LabelField(Rect position, string text, bool ghosted = false)
394403
{
395404
LabelField(position, CachedGUIContent(text), ghosted);

Editor/BundleTreeView.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,9 @@ public override void OnGUI(Rect position, int column, bool selected)
234234
if (GUI.Button(ButtonSpaceR(ref position), CachedGUIContent(Styles.navigateIcon, "Navigate to asset"), Styles.iconButtonStyle))
235235
NavigateTo(asset);
236236

237+
if (GUI.Button(ButtonSpaceR(ref position), CachedGUIContent(Styles.selectAssetIcon, "Select asset in project"), Styles.iconButtonStyle))
238+
TrySelectAsset(asset.name);
239+
237240
LabelField(position, displayName);
238241
break;
239242

Editor/Styles.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,12 @@ public static Texture2D settingsIcon
8181
private set;
8282
}
8383

84+
public static Texture2D selectAssetIcon
85+
{
86+
get;
87+
private set;
88+
}
89+
8490
public static Texture2D openContainingFolderIcon
8591
{
8692
get;
@@ -154,6 +160,7 @@ static Styles()
154160
navigateIcon = FindBuiltinTexture("PlayButton@2x");
155161
settingsIcon = FindBuiltinTexture("Settings@2x");
156162
openContainingFolderIcon = FindBuiltinTexture("Folder Icon");
163+
selectAssetIcon = FindBuiltinTexture("Search Icon");
157164
deleteIcon = FindBuiltinTexture("P4_DeletedLocal");
158165

159166
includedByIcon = FindBuiltinTexture("AnimatorStateMachine Icon");

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "com.oddworm.addressablesbuildlayoutexplorer",
3-
"version": "1.0.0-pre.1",
3+
"version": "1.0.0-pre.2",
44
"displayName": "Addressables BuildLayout Explorer",
55
"description": "Addressables BuildLayout Explorer allows you to inspect the 'buildlayout.txt' file that Addressables generates when building content.\n\nYou can open the Addressables BuildLayout Explorer window from the main-menu under 'Window > Asset Management > Addressables > BuildLayout Explorer'.",
66
"unity": "2019.3",

0 commit comments

Comments
 (0)