From 1a2eba24bd370b94dc628f06bdcf407beab339f9 Mon Sep 17 00:00:00 2001 From: yasirkula Date: Tue, 27 Jun 2023 14:02:34 +0300 Subject: [PATCH] Added a setting to show sub-assets' root asset names in search results (disabled by default) (closes #35) --- .../Editor/AssetUsageDetectorSettings.cs | 12 +++++++++++- Plugins/AssetUsageDetector/Editor/SearchResult.cs | 8 ++++++++ Plugins/AssetUsageDetector/README.txt | 2 +- package.json | 2 +- 4 files changed, 21 insertions(+), 3 deletions(-) diff --git a/Plugins/AssetUsageDetector/Editor/AssetUsageDetectorSettings.cs b/Plugins/AssetUsageDetector/Editor/AssetUsageDetectorSettings.cs index 8564c3c..35693d2 100644 --- a/Plugins/AssetUsageDetector/Editor/AssetUsageDetectorSettings.cs +++ b/Plugins/AssetUsageDetector/Editor/AssetUsageDetectorSettings.cs @@ -96,6 +96,13 @@ namespace AssetUsageDetectorNamespace #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 { @@ -179,7 +186,9 @@ namespace AssetUsageDetectorNamespace 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(); @@ -202,6 +211,7 @@ namespace AssetUsageDetectorNamespace 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 ) ); diff --git a/Plugins/AssetUsageDetector/Editor/SearchResult.cs b/Plugins/AssetUsageDetector/Editor/SearchResult.cs index 60e2742..e6df6c6 100644 --- a/Plugins/AssetUsageDetector/Editor/SearchResult.cs +++ b/Plugins/AssetUsageDetector/Editor/SearchResult.cs @@ -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; @@ -1221,6 +1222,13 @@ namespace AssetUsageDetectorNamespace { 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 ) { diff --git a/Plugins/AssetUsageDetector/README.txt b/Plugins/AssetUsageDetector/README.txt index 2ae615e..2ffb675 100644 --- a/Plugins/AssetUsageDetector/README.txt +++ b/Plugins/AssetUsageDetector/README.txt @@ -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 diff --git a/package.json b/package.json index 395f1cb..d6752d7 100644 --- a/package.json +++ b/package.json @@ -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",