Skip to content

Commit 1a2eba2

Browse files
committed
Added a setting to show sub-assets' root asset names in search results (disabled by default) (closes #35)
1 parent cf0fea5 commit 1a2eba2

File tree

4 files changed

+21
-3
lines changed

4 files changed

+21
-3
lines changed

Plugins/AssetUsageDetector/Editor/AssetUsageDetectorSettings.cs

+11-1
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,13 @@ public static float ExtraRowHeight
9696
#endregion
9797

9898
#region Other Settings
99+
private static bool? m_showRootAssetName = null;
100+
public static bool ShowRootAssetName
101+
{
102+
get { if( m_showRootAssetName == null ) m_showRootAssetName = EditorPrefs.GetBool( "AUD_ShowRootAssetName", false ); return m_showRootAssetName.Value; }
103+
set { if( m_showRootAssetName == value ) return; m_showRootAssetName = value; EditorPrefs.SetBool( "AUD_ShowRootAssetName", value ); }
104+
}
105+
99106
private static bool? m_pingClickedObjects = null;
100107
public static bool PingClickedObjects
101108
{
@@ -179,7 +186,9 @@ public static void PreferencesGUI()
179186

180187
EditorGUI.BeginChangeCheck();
181188

182-
SettingsHeaderColor = ColorField( "Settings Header Color", SettingsHeaderColor, Color.cyan );
189+
EditorGUIUtility.labelWidth += 140f;
190+
ShowRootAssetName = EditorGUILayout.Toggle( "Show Root Asset's Name For Sub-Assets (Requires Refresh)", ShowRootAssetName );
191+
EditorGUIUtility.labelWidth -= 140f;
183192

184193
EditorGUILayout.Space();
185194

@@ -202,6 +211,7 @@ public static void PreferencesGUI()
202211

203212
EditorGUILayout.Space();
204213

214+
SettingsHeaderColor = ColorField( "Settings Header Color", SettingsHeaderColor, Color.cyan );
205215
SearchResultGroupHeaderColor = ColorField( "Group Header Color", SearchResultGroupHeaderColor, Color.cyan );
206216
RootRowsBackgroundColor = ColorField( "Root Rows Background Color", RootRowsBackgroundColor, EditorGUIUtility.isProSkin ? new Color( 0f, 1f, 1f, 0.15f ) : new Color( 0f, 1f, 1f, 0.25f ) );
207217
RootRowsBorderColor = ColorField( "Root Rows Border Color", RootRowsBorderColor, EditorGUIUtility.isProSkin ? new Color( 0.15f, 0.15f, 0.15f, 1f ) : new Color( 0.375f, 0.375f, 0.375f, 1f ) );

Plugins/AssetUsageDetector/Editor/SearchResult.cs

+8
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System;
22
using System.Collections;
33
using System.Collections.Generic;
4+
using System.IO;
45
using System.Text;
56
using UnityEditor;
67
using UnityEditor.IMGUI.Controls;
@@ -1221,6 +1222,13 @@ public void InitializeRecursively()
12211222
{
12221223
instanceId = unityObject.GetInstanceID();
12231224
Label = unityObject.name + " (" + unityObject.GetType().Name + ")";
1225+
1226+
if( AssetUsageDetectorSettings.ShowRootAssetName && unityObject.IsAsset() && !AssetDatabase.IsMainAsset( unityObject ) )
1227+
{
1228+
string mainAssetName = Path.GetFileNameWithoutExtension( AssetDatabase.GetAssetPath( unityObject ) );
1229+
if( unityObject.name != mainAssetName )
1230+
Label += " <" + mainAssetName + ">";
1231+
}
12241232
}
12251233
else if( nodeObject != null )
12261234
{

Plugins/AssetUsageDetector/README.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
= Asset Usage Detector (v2.4.0) =
1+
= Asset Usage Detector (v2.4.1) =
22

33
Online documentation available at: https://github.com/yasirkula/UnityAssetUsageDetector
44

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "com.yasirkula.assetusagedetector",
33
"displayName": "Asset Usage Detector",
4-
"version": "2.4.0",
4+
"version": "2.4.1",
55
"documentationUrl": "https://github.com/yasirkula/UnityAssetUsageDetector",
66
"changelogUrl": "https://github.com/yasirkula/UnityAssetUsageDetector/releases",
77
"licensesUrl": "https://github.com/yasirkula/UnityAssetUsageDetector/blob/master/LICENSE.txt",

0 commit comments

Comments
 (0)