Skip to content

Commit

Permalink
Added a setting to show sub-assets' root asset names in search result…
Browse files Browse the repository at this point in the history
…s (disabled by default) (closes #35)
  • Loading branch information
yasirkula committed Jun 27, 2023
1 parent cf0fea5 commit 1a2eba2
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 3 deletions.
12 changes: 11 additions & 1 deletion Plugins/AssetUsageDetector/Editor/AssetUsageDetectorSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,13 @@ public static float ExtraRowHeight
#endregion

#region Other Settings
private static bool? m_showRootAssetName = null;
public static bool ShowRootAssetName
{
get { if( m_showRootAssetName == null ) m_showRootAssetName = EditorPrefs.GetBool( "AUD_ShowRootAssetName", false ); return m_showRootAssetName.Value; }
set { if( m_showRootAssetName == value ) return; m_showRootAssetName = value; EditorPrefs.SetBool( "AUD_ShowRootAssetName", value ); }
}

private static bool? m_pingClickedObjects = null;
public static bool PingClickedObjects
{
Expand Down Expand Up @@ -179,7 +186,9 @@ public static void PreferencesGUI()

EditorGUI.BeginChangeCheck();

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

EditorGUILayout.Space();

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

EditorGUILayout.Space();

SettingsHeaderColor = ColorField( "Settings Header Color", SettingsHeaderColor, Color.cyan );
SearchResultGroupHeaderColor = ColorField( "Group Header Color", SearchResultGroupHeaderColor, Color.cyan );
RootRowsBackgroundColor = ColorField( "Root Rows Background Color", RootRowsBackgroundColor, EditorGUIUtility.isProSkin ? new Color( 0f, 1f, 1f, 0.15f ) : new Color( 0f, 1f, 1f, 0.25f ) );
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 ) );
Expand Down
8 changes: 8 additions & 0 deletions Plugins/AssetUsageDetector/Editor/SearchResult.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Text;
using UnityEditor;
using UnityEditor.IMGUI.Controls;
Expand Down Expand Up @@ -1221,6 +1222,13 @@ public void InitializeRecursively()
{
instanceId = unityObject.GetInstanceID();
Label = unityObject.name + " (" + unityObject.GetType().Name + ")";

if( AssetUsageDetectorSettings.ShowRootAssetName && unityObject.IsAsset() && !AssetDatabase.IsMainAsset( unityObject ) )
{
string mainAssetName = Path.GetFileNameWithoutExtension( AssetDatabase.GetAssetPath( unityObject ) );
if( unityObject.name != mainAssetName )
Label += " <" + mainAssetName + ">";
}
}
else if( nodeObject != null )
{
Expand Down
2 changes: 1 addition & 1 deletion Plugins/AssetUsageDetector/README.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
= Asset Usage Detector (v2.4.0) =
= Asset Usage Detector (v2.4.1) =

Online documentation available at: https://github.com/yasirkula/UnityAssetUsageDetector
E-mail: yasirkula@gmail.com
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "com.yasirkula.assetusagedetector",
"displayName": "Asset Usage Detector",
"version": "2.4.0",
"version": "2.4.1",
"documentationUrl": "https://github.com/yasirkula/UnityAssetUsageDetector",
"changelogUrl": "https://github.com/yasirkula/UnityAssetUsageDetector/releases",
"licensesUrl": "https://github.com/yasirkula/UnityAssetUsageDetector/blob/master/LICENSE.txt",
Expand Down

0 comments on commit 1a2eba2

Please sign in to comment.