mirror of
https://github.com/yasirkula/UnityAssetUsageDetector.git
synced 2026-11-20 23:12:38 +08:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 9fddcab6fa | |||
| 66dd66787c |
@@ -711,6 +711,19 @@ namespace AssetUsageDetectorNamespace
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
string assetPath = AssetDatabase.GetAssetPath( obj );
|
string assetPath = AssetDatabase.GetAssetPath( obj );
|
||||||
|
|
||||||
|
// Omit unused sub-assets whose parent assets are used (configurable via Settings)
|
||||||
|
if( AssetUsageDetectorSettings.MarkUsedAssetsSubAssetsAsUsed && AssetDatabase.IsSubAsset( obj ) && usedObjectsSet.Contains( AssetDatabase.LoadMainAssetAtPath( assetPath ) ) )
|
||||||
|
continue;
|
||||||
|
|
||||||
|
// Omit meshes of an imported model asset
|
||||||
|
if( obj is Mesh && !string.IsNullOrEmpty( assetPath ) && AssetDatabase.GetMainAssetTypeAtPath( assetPath ) == typeof( GameObject ) && objectsToSearchSet.Contains( AssetDatabase.LoadMainAssetAtPath( assetPath ) ) )
|
||||||
|
continue;
|
||||||
|
|
||||||
|
// Omit MonoScripts whose types can't be determined
|
||||||
|
if( obj is MonoScript && ( (MonoScript) obj ).GetClass() == null )
|
||||||
|
continue;
|
||||||
|
|
||||||
GameObject searchedTopmostGameObject = null;
|
GameObject searchedTopmostGameObject = null;
|
||||||
if( obj is GameObject )
|
if( obj is GameObject )
|
||||||
{
|
{
|
||||||
@@ -738,14 +751,6 @@ namespace AssetUsageDetectorNamespace
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Omit meshes of an imported model asset
|
|
||||||
if( obj is Mesh && !string.IsNullOrEmpty( assetPath ) && AssetDatabase.GetMainAssetTypeAtPath( assetPath ) == typeof( GameObject ) && objectsToSearchSet.Contains( AssetDatabase.LoadMainAssetAtPath( assetPath ) ) )
|
|
||||||
continue;
|
|
||||||
|
|
||||||
// Omit MonoScripts whose types can't be determined
|
|
||||||
if( obj is MonoScript && ( (MonoScript) obj ).GetClass() == null )
|
|
||||||
continue;
|
|
||||||
|
|
||||||
// Use new ReferenceNodes in UnusedObjects search result group because we don't want these nodes to be linked to the actual ReferenceNodes in any way
|
// Use new ReferenceNodes in UnusedObjects search result group because we don't want these nodes to be linked to the actual ReferenceNodes in any way
|
||||||
// (i.e. we don't use actual ReferenceNodes of these objects (GetReferenceNode) because these may have links to other nodes in unknown circumstances)
|
// (i.e. we don't use actual ReferenceNodes of these objects (GetReferenceNode) because these may have links to other nodes in unknown circumstances)
|
||||||
ReferenceNode node = PopReferenceNode( obj );
|
ReferenceNode node = PopReferenceNode( obj );
|
||||||
|
|||||||
@@ -217,8 +217,9 @@ namespace AssetUsageDetectorNamespace
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if ASSET_USAGE_VFX_GRAPH
|
#if ASSET_USAGE_VFX_GRAPH
|
||||||
private readonly Func<string, object> vfxResourceGetter = (Func<string, object>) Delegate.CreateDelegate( typeof( Func<string, object> ), typeof( Editor ).Assembly.GetType( "UnityEditor.VFX.VisualEffectResource" ).GetMethod( "GetResourceAtPath", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static ) );
|
private static Type vfxResourceType => typeof( Editor ).Assembly.GetType( "UnityEditor.VFX.VisualEffectResource" ) ?? Array.Find( AppDomain.CurrentDomain.GetAssemblies(), ( assembly ) => assembly.GetName().Name == "UnityEditor.VFXModule" ).GetType( "UnityEditor.VFX.VisualEffectResource" );
|
||||||
private readonly MethodInfo vfxResourceContentsGetter = typeof( Editor ).Assembly.GetType( "UnityEditor.VFX.VisualEffectResource" ).GetMethod( "GetContents", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance );
|
private readonly Func<string, object> vfxResourceGetter = (Func<string, object>) Delegate.CreateDelegate( typeof( Func<string, object> ), vfxResourceType.GetMethod( "GetResourceAtPath", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static ) );
|
||||||
|
private readonly MethodInfo vfxResourceContentsGetter = vfxResourceType.GetMethod( "GetContents", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance );
|
||||||
private readonly MethodInfo vfxSerializableObjectValueGetter = Array.Find( Array.Find( AppDomain.CurrentDomain.GetAssemblies(), ( assembly ) => assembly.GetName().Name == "Unity.VisualEffectGraph.Editor" ).GetType( "UnityEditor.VFX.VFXSerializableObject" ).GetMethods( BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance ), ( methodInfo ) => methodInfo.Name == "Get" && !methodInfo.IsGenericMethod );
|
private readonly MethodInfo vfxSerializableObjectValueGetter = Array.Find( Array.Find( AppDomain.CurrentDomain.GetAssemblies(), ( assembly ) => assembly.GetName().Name == "Unity.VisualEffectGraph.Editor" ).GetType( "UnityEditor.VFX.VFXSerializableObject" ).GetMethods( BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance ), ( methodInfo ) => methodInfo.Name == "Get" && !methodInfo.IsGenericMethod );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -124,6 +124,13 @@ namespace AssetUsageDetectorNamespace
|
|||||||
set { if( m_selectDoubleClickedObjects == value ) return; m_selectDoubleClickedObjects = value; EditorPrefs.SetBool( "AUD_SelectDoubleClickedObj", value ); }
|
set { if( m_selectDoubleClickedObjects == value ) return; m_selectDoubleClickedObjects = value; EditorPrefs.SetBool( "AUD_SelectDoubleClickedObj", value ); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static bool? m_markUsedAssetsSubAssetsAsUsed = null;
|
||||||
|
public static bool MarkUsedAssetsSubAssetsAsUsed
|
||||||
|
{
|
||||||
|
get { if( m_markUsedAssetsSubAssetsAsUsed == null ) m_markUsedAssetsSubAssetsAsUsed = EditorPrefs.GetBool( "AUD_MarkUsedAssetsSubAssetsAsUsed", true ); return m_markUsedAssetsSubAssetsAsUsed.Value; }
|
||||||
|
set { if( m_markUsedAssetsSubAssetsAsUsed == value ) return; m_markUsedAssetsSubAssetsAsUsed = value; EditorPrefs.SetBool( "AUD_MarkUsedAssetsSubAssetsAsUsed", value ); }
|
||||||
|
}
|
||||||
|
|
||||||
private static bool? m_showUnityTooltip = null;
|
private static bool? m_showUnityTooltip = null;
|
||||||
public static bool ShowUnityTooltip
|
public static bool ShowUnityTooltip
|
||||||
{
|
{
|
||||||
@@ -186,20 +193,22 @@ namespace AssetUsageDetectorNamespace
|
|||||||
|
|
||||||
EditorGUI.BeginChangeCheck();
|
EditorGUI.BeginChangeCheck();
|
||||||
|
|
||||||
EditorGUIUtility.labelWidth += 140f;
|
ShowRootAssetName = AssetUsageDetectorWindow.WordWrappingToggleLeft( "Show Root Asset's Name For Sub-Assets (Requires Refresh)", ShowRootAssetName );
|
||||||
ShowRootAssetName = EditorGUILayout.Toggle( "Show Root Asset's Name For Sub-Assets (Requires Refresh)", ShowRootAssetName );
|
|
||||||
EditorGUIUtility.labelWidth -= 140f;
|
|
||||||
|
|
||||||
EditorGUILayout.Space();
|
EditorGUILayout.Space();
|
||||||
|
|
||||||
PingClickedObjects = EditorGUILayout.Toggle( "Ping Clicked Objects", PingClickedObjects );
|
PingClickedObjects = AssetUsageDetectorWindow.WordWrappingToggleLeft( "Ping Clicked Objects", PingClickedObjects );
|
||||||
SelectClickedObjects = EditorGUILayout.Toggle( "Select Clicked Objects", SelectClickedObjects );
|
SelectClickedObjects = AssetUsageDetectorWindow.WordWrappingToggleLeft( "Select Clicked Objects", SelectClickedObjects );
|
||||||
SelectDoubleClickedObjects = EditorGUILayout.Toggle( "Select Double Clicked Objects", SelectDoubleClickedObjects );
|
SelectDoubleClickedObjects = AssetUsageDetectorWindow.WordWrappingToggleLeft( "Select Double Clicked Objects", SelectDoubleClickedObjects );
|
||||||
|
|
||||||
EditorGUILayout.Space();
|
EditorGUILayout.Space();
|
||||||
|
|
||||||
ShowUnityTooltip = EditorGUILayout.Toggle( "Show Unity Tooltip", ShowUnityTooltip );
|
MarkUsedAssetsSubAssetsAsUsed = AssetUsageDetectorWindow.WordWrappingToggleLeft( "Hide unused sub-assets in \"Unused Objects\" list if their parent assets are used (Requires Refresh)", MarkUsedAssetsSubAssetsAsUsed );
|
||||||
ShowCustomTooltip = EditorGUILayout.Toggle( "Show Custom Tooltip", ShowCustomTooltip );
|
|
||||||
|
EditorGUILayout.Space();
|
||||||
|
|
||||||
|
ShowUnityTooltip = AssetUsageDetectorWindow.WordWrappingToggleLeft( "Show Unity Tooltip", ShowUnityTooltip );
|
||||||
|
ShowCustomTooltip = AssetUsageDetectorWindow.WordWrappingToggleLeft( "Show Custom Tooltip", ShowCustomTooltip );
|
||||||
EditorGUI.indentLevel++;
|
EditorGUI.indentLevel++;
|
||||||
CustomTooltipDelay = FloatField( "Delay", CustomTooltipDelay, 0.7f );
|
CustomTooltipDelay = FloatField( "Delay", CustomTooltipDelay, 0.7f );
|
||||||
EditorGUI.indentLevel--;
|
EditorGUI.indentLevel--;
|
||||||
@@ -223,7 +232,7 @@ namespace AssetUsageDetectorNamespace
|
|||||||
SelectedRowOccurrencesColor = ColorField( "Selected Row All Occurrences Tint", SelectedRowOccurrencesColor, EditorGUIUtility.isProSkin ? new Color( 0f, 0.3f, 0.75f, 1f ) : new Color( 0.25f, 0.75f, 1f, 1f ) );
|
SelectedRowOccurrencesColor = ColorField( "Selected Row All Occurrences Tint", SelectedRowOccurrencesColor, EditorGUIUtility.isProSkin ? new Color( 0f, 0.3f, 0.75f, 1f ) : new Color( 0.25f, 0.75f, 1f, 1f ) );
|
||||||
SearchMatchingTextColor = ColorField( "Matching Search Text Color", SearchMatchingTextColor, Color.red );
|
SearchMatchingTextColor = ColorField( "Matching Search Text Color", SearchMatchingTextColor, Color.red );
|
||||||
|
|
||||||
ShowTreeLines = EditorGUILayout.Toggle( "Show Tree Lines", ShowTreeLines );
|
ShowTreeLines = AssetUsageDetectorWindow.WordWrappingToggleLeft( "Show Tree Lines", ShowTreeLines );
|
||||||
EditorGUI.indentLevel++;
|
EditorGUI.indentLevel++;
|
||||||
TreeLinesColor = ColorField( "Normal Color", TreeLinesColor, EditorGUIUtility.isProSkin ? new Color( 0.65f, 0.65f, 0.65f, 1f ) : new Color( 0.375f, 0.375f, 0.375f, 1f ) );
|
TreeLinesColor = ColorField( "Normal Color", TreeLinesColor, EditorGUIUtility.isProSkin ? new Color( 0.65f, 0.65f, 0.65f, 1f ) : new Color( 0.375f, 0.375f, 0.375f, 1f ) );
|
||||||
HighlightedTreeLinesColor = ColorField( "Highlighted Color", HighlightedTreeLinesColor, Color.cyan );
|
HighlightedTreeLinesColor = ColorField( "Highlighted Color", HighlightedTreeLinesColor, Color.cyan );
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ namespace AssetUsageDetectorNamespace
|
|||||||
private static readonly GUIContent windowTitle = new GUIContent( "Asset Usage Detector" );
|
private static readonly GUIContent windowTitle = new GUIContent( "Asset Usage Detector" );
|
||||||
private static readonly Vector2 windowMinSize = new Vector2( 325f, 220f );
|
private static readonly Vector2 windowMinSize = new Vector2( 325f, 220f );
|
||||||
|
|
||||||
private readonly GUILayoutOption GL_WIDTH_12 = GUILayout.Width( 12f );
|
private static readonly GUILayoutOption GL_WIDTH_12 = GUILayout.Width( 12f );
|
||||||
|
|
||||||
private GUIStyle lockButtonStyle;
|
private GUIStyle lockButtonStyle;
|
||||||
|
|
||||||
@@ -674,7 +674,7 @@ namespace AssetUsageDetectorNamespace
|
|||||||
objectsToSearchDrawer.Draw( objectsToSearch );
|
objectsToSearchDrawer.Draw( objectsToSearch );
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool WordWrappingToggleLeft( string label, bool value )
|
public static bool WordWrappingToggleLeft( string label, bool value )
|
||||||
{
|
{
|
||||||
GUILayout.BeginHorizontal();
|
GUILayout.BeginHorizontal();
|
||||||
bool result = EditorGUILayout.ToggleLeft( GUIContent.none, value, GL_WIDTH_12 );
|
bool result = EditorGUILayout.ToggleLeft( GUIContent.none, value, GL_WIDTH_12 );
|
||||||
|
|||||||
@@ -863,6 +863,9 @@ namespace AssetUsageDetectorNamespace
|
|||||||
if( searchResult != null && searchResult.SearchParameters.dontSearchInSourceAssets && searchResult.SearchParameters.objectsToSearch.Length > 1 )
|
if( searchResult != null && searchResult.SearchParameters.dontSearchInSourceAssets && searchResult.SearchParameters.objectsToSearch.Length > 1 )
|
||||||
EditorGUILayout.HelpBox( "'Don't search \"SEARCHED OBJECTS\" themselves for references' is enabled, some of these objects might be used by \"SEARCHED OBJECTS\".", MessageType.Warning );
|
EditorGUILayout.HelpBox( "'Don't search \"SEARCHED OBJECTS\" themselves for references' is enabled, some of these objects might be used by \"SEARCHED OBJECTS\".", MessageType.Warning );
|
||||||
|
|
||||||
|
if( !AssetUsageDetectorSettings.MarkUsedAssetsSubAssetsAsUsed )
|
||||||
|
EditorGUILayout.HelpBox( "'Hide unused sub-assets in \"Unused Objects\" list if their parent assets are used' is disabled, unused sub-assets' parent assets might be used.", MessageType.Warning );
|
||||||
|
|
||||||
EditorGUILayout.HelpBox( "Although no references to these objects are found, they might still be used somewhere (e.g. via Resources.Load). If you intend to delete these objects, consider creating a backup of your project first.", MessageType.Info );
|
EditorGUILayout.HelpBox( "Although no references to these objects are found, they might still be used somewhere (e.g. via Resources.Load). If you intend to delete these objects, consider creating a backup of your project first.", MessageType.Info );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
= Asset Usage Detector (v2.5.1) =
|
= Asset Usage Detector (v2.5.3) =
|
||||||
|
|
||||||
Documentation: https://github.com/yasirkula/UnityAssetUsageDetector
|
Documentation: https://github.com/yasirkula/UnityAssetUsageDetector
|
||||||
E-mail: yasirkula@gmail.com
|
E-mail: yasirkula@gmail.com
|
||||||
+1
-1
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "com.yasirkula.assetusagedetector",
|
"name": "com.yasirkula.assetusagedetector",
|
||||||
"displayName": "Asset Usage Detector",
|
"displayName": "Asset Usage Detector",
|
||||||
"version": "2.5.1",
|
"version": "2.5.3",
|
||||||
"documentationUrl": "https://github.com/yasirkula/UnityAssetUsageDetector",
|
"documentationUrl": "https://github.com/yasirkula/UnityAssetUsageDetector",
|
||||||
"changelogUrl": "https://github.com/yasirkula/UnityAssetUsageDetector/releases",
|
"changelogUrl": "https://github.com/yasirkula/UnityAssetUsageDetector/releases",
|
||||||
"licensesUrl": "https://github.com/yasirkula/UnityAssetUsageDetector/blob/master/LICENSE.txt",
|
"licensesUrl": "https://github.com/yasirkula/UnityAssetUsageDetector/blob/master/LICENSE.txt",
|
||||||
|
|||||||
Reference in New Issue
Block a user