Compare commits

...

8 Commits

9 changed files with 223 additions and 40 deletions
Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

+12
View File
@@ -37,6 +37,18 @@ There are 5 ways to install this plugin:
![SearchResults2](Images/SearchResults2Dark.png)
## ADDRESSABLES SUPPORT
This plugin has experimental support for *Addressables* package. However, the search may take significantly longer to finish when Addressables are searched. Some manual modifications are needed to enable Addressables support:
- The plugin mustn't be installed as a package, i.e. it must reside inside the *Assets* folder and not the *Packages* folder (it can reside inside a subfolder of Assets like *Assets/Plugins*)
- Modify the **AssetUsageDetector.Editor** Assembly Definition File as follows:
![AddressablesAssemblyChanges](Images/AddressablesAssemblyChanges.png)
- If *Version Defines* isn't present (on older Unity versions), manually add `ASSET_USAGE_ADDRESSABLES` compiler directive to **Player Settings/Scripting Define Symbols** (these symbols are platform specific, so if you change the active platform later, you'll have to add the compiler directive again)
- Enable the "Addressables support" option in Asset Usage Detector window
## SEARCH REFACTORING
While searching for references using the Scripting API, it's possible to get notified of the found references *during* the search (some references like *Assembly Definition File* references or *Shader Graph* references aren't supported) and in most cases, refactor them (e.g. changing all usages of a searched object with something else or *null*). Disabling *Lazy Scene Search* is recommended while using this feature and it's advised to backup your project beforehand.
@@ -47,6 +47,9 @@ namespace AssetUsageDetectorNamespace
public SearchRefactoring searchRefactoring = null;
public bool lazySceneSearch = true;
#if ASSET_USAGE_ADDRESSABLES
public bool addressablesSupport = false;
#endif
public bool calculateUnusedObjects = false;
public bool hideDuplicateRows = true;
public bool hideReduntantPrefabVariantLinks = true;
@@ -347,7 +350,7 @@ namespace AssetUsageDetectorNamespace
// Initialize the nodes of searched asset(s)
foreach( Object obj in objectsToSearchSet )
searchedUnityObjects.Add( obj.GetHashCode(), PopReferenceNode( obj ) );
searchedUnityObjects.Add( obj.GetInstanceID(), PopReferenceNode( obj ) );
// Progressbar values
int searchProgress = 0;
@@ -669,7 +672,7 @@ namespace AssetUsageDetectorNamespace
else
{
for( Transform parent = ( (GameObject) obj ).transform.parent; parent != null; parent = parent.parent )
usedObjectPathsSet.Add( parent.gameObject.GetHashCode().ToString() );
usedObjectPathsSet.Add( parent.gameObject.GetInstanceID().ToString() );
}
}
}
@@ -736,13 +739,13 @@ namespace AssetUsageDetectorNamespace
if( !searchedTopmostGameObject )
{
if( obj is GameObject )
unusedMainObjectNodes[obj.GetHashCode().ToString()] = node;
unusedMainObjectNodes[obj.GetInstanceID().ToString()] = node;
else
currentSearchResultGroup.AddReference( node );
}
else // List child GameObject scene objects under their parent GameObject
{
string dictionaryKey = searchedTopmostGameObject.GetHashCode().ToString();
string dictionaryKey = searchedTopmostGameObject.GetInstanceID().ToString();
List<ReferenceNode> unusedSubObjectNodesAtPath;
if( !unusedSubObjectNodes.TryGetValue( dictionaryKey, out unusedSubObjectNodesAtPath ) )
unusedSubObjectNodes[dictionaryKey] = unusedSubObjectNodesAtPath = new List<ReferenceNode>( 2 );
@@ -1009,14 +1012,14 @@ namespace AssetUsageDetectorNamespace
{
if( assetsToSearchSet.Count == 0 )
{
searchedUnityObjects.Add( unityObject.GetHashCode(), null );
searchedUnityObjects.Add( unityObject.GetInstanceID(), null );
return null;
}
assetPath = AssetDatabase.GetAssetPath( unityObject );
if( excludedAssetsPathsSet.Contains( assetPath ) || !AssetHasAnyReference( assetPath ) )
{
searchedUnityObjects.Add( unityObject.GetHashCode(), null );
searchedUnityObjects.Add( unityObject.GetInstanceID(), null );
return null;
}
}
@@ -1086,13 +1089,13 @@ namespace AssetUsageDetectorNamespace
if( !searchingSourceAsset )
{
if( obj is Object )
searchedUnityObjects.Add( unityObject.GetHashCode(), result );
searchedUnityObjects.Add( unityObject.GetInstanceID(), result );
else
searchedObjects.Add( GetNodeObjectHash( obj ), result );
}
else if( result != null )
{
result.CopyReferencesTo( searchedUnityObjects[unityObject.GetHashCode()] );
result.CopyReferencesTo( searchedUnityObjects[unityObject.GetInstanceID()] );
PoolReferenceNode( result );
}
}
@@ -1103,6 +1106,11 @@ namespace AssetUsageDetectorNamespace
// Check if the asset at specified path depends on any of the references
private bool AssetHasAnyReference( string assetPath )
{
#if ASSET_USAGE_ADDRESSABLES
if( searchParameters.addressablesSupport )
return true;
#endif
if( assetsToSearchPathsSet.Contains( assetPath ) )
return true;
@@ -1221,7 +1229,7 @@ namespace AssetUsageDetectorNamespace
{
if( nodeObject is Object )
{
if( searchedUnityObjects.TryGetValue( nodeObject.GetHashCode(), out referenceNode ) )
if( searchedUnityObjects.TryGetValue( ( (Object) nodeObject ).GetInstanceID(), out referenceNode ) )
return true;
}
else if( searchedObjects.TryGetValue( GetNodeObjectHash( nodeObject ), out referenceNode ) )
@@ -1237,7 +1245,7 @@ namespace AssetUsageDetectorNamespace
ReferenceNode result;
if( nodeObject is Object )
{
int hash = nodeObject.GetHashCode();
int hash = ( (Object) nodeObject ).GetInstanceID();
if( !searchedUnityObjects.TryGetValue( hash, out result ) || result == null )
{
result = PopReferenceNode( nodeObject );
@@ -21,6 +21,9 @@ using UnityEditor.Compilation;
#if UNITY_2017_2_OR_NEWER
using UnityEngine.Tilemaps;
#endif
#if ASSET_USAGE_ADDRESSABLES
using UnityEngine.AddressableAssets;
#endif
using Object = UnityEngine.Object;
namespace AssetUsageDetectorNamespace
@@ -198,6 +201,12 @@ namespace AssetUsageDetectorNamespace
private delegate FieldInfo FieldInfoGetter( SerializedProperty p, out Type t );
private FieldInfoGetter fieldInfoGetter;
#if ASSET_USAGE_ADDRESSABLES
private delegate Sprite[] SpriteAtlasPackedSpritesGetter( SpriteAtlas atlas );
private SpriteAtlasPackedSpritesGetter spriteAtlasPackedSpritesGetter;
private PropertyInfo assetReferenceSubObjectTypeGetter;
#endif
private void InitializeSearchFunctionsData( Parameters searchParameters )
{
if( typeToSearchFunction == null )
@@ -216,6 +225,7 @@ namespace AssetUsageDetectorNamespace
{ typeof( AnimatorStateTransition ), SearchAnimatorStateTransition },
{ typeof( BlendTree ), SearchBlendTree },
{ typeof( AnimationClip ), SearchAnimationClip },
{ typeof( TerrainData ), SearchTerrainData },
#if UNITY_2017_1_OR_NEWER
{ typeof( SpriteAtlas ), SearchSpriteAtlas },
#endif
@@ -345,6 +355,12 @@ namespace AssetUsageDetectorNamespace
MethodInfo fieldInfoGetterMethod = typeof( Editor ).Assembly.GetType( "UnityEditor.ScriptAttributeUtility" ).GetMethod( "GetFieldInfoFromProperty", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static );
#endif
fieldInfoGetter = (FieldInfoGetter) Delegate.CreateDelegate( typeof( FieldInfoGetter ), fieldInfoGetterMethod );
#if ASSET_USAGE_ADDRESSABLES
MethodInfo spriteAtlasPackedSpritesGetterMethod = typeof( SpriteAtlasExtensions ).GetMethod( "GetPackedSprites", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static );
spriteAtlasPackedSpritesGetter = (SpriteAtlasPackedSpritesGetter) Delegate.CreateDelegate( typeof( SpriteAtlasPackedSpritesGetter ), spriteAtlasPackedSpritesGetterMethod );
assetReferenceSubObjectTypeGetter = typeof( AssetReference ).GetProperty( "SubOjbectType", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance );
#endif
}
private ReferenceNode SearchGameObject( Object unityObject )
@@ -966,6 +982,14 @@ namespace AssetUsageDetectorNamespace
return referenceNode;
}
// TerrainData's properties like tree/detail/layer definitions aren't exposed to SerializedObject so use reflection instead
private ReferenceNode SearchTerrainData( Object unityObject )
{
ReferenceNode referenceNode = PopReferenceNode( unityObject );
SearchVariablesWithReflection( referenceNode );
return referenceNode;
}
#if UNITY_2017_1_OR_NEWER
private ReferenceNode SearchSpriteAtlas( Object unityObject )
{
@@ -1112,7 +1136,7 @@ namespace AssetUsageDetectorNamespace
{
// New Shader Graph serialization format is used: https://github.com/Unity-Technologies/Graphics/pull/222
// Iterate over all these occurrences: "guid\": \"GUID_VALUE\" (\" is used instead of " because it is a nested JSON)
IterateOverValuesInString( graphJson, "\"guid\\\"", '"', ( guid ) =>
IterateOverValuesInString( graphJson, new string[] { "\"guid\\\"" }, '"', ( guid ) =>
{
if( guid.Length > 1 )
{
@@ -1132,7 +1156,7 @@ namespace AssetUsageDetectorNamespace
if( shaderIncludesToSearchSet.Count > 0 )
{
// Iterate over all these occurrences: "m_FunctionSource": "GUID_VALUE" (this one is not nested JSON)
IterateOverValuesInString( graphJson, "\"m_FunctionSource\"", '"', ( guid ) =>
IterateOverValuesInString( graphJson, new string[] { "\"m_FunctionSource\"" }, '"', ( guid ) =>
{
string referencePath = AssetDatabase.GUIDToAssetPath( guid );
if( !string.IsNullOrEmpty( referencePath ) && assetsToSearchPathsSet.Contains( referencePath ) )
@@ -1315,8 +1339,8 @@ namespace AssetUsageDetectorNamespace
{
string shaderPath = AssetDatabase.GetAssetPath( (Object) referenceNode.nodeObject );
// Iterate over all these occurrences: #include: "INCLUDE_REFERENCE"
IterateOverValuesInString( File.ReadAllText( shaderPath ), "#include ", '"', ( include ) =>
// Iterate over all these occurrences: #include "INCLUDE_REFERENCE" or #include_with_pragmas "INCLUDE_REFERENCE"
IterateOverValuesInString( File.ReadAllText( shaderPath ), new string[] { "#include ", "#include_with_pragmas " }, '"', ( include ) =>
{
bool isIncludePotentialReference = shaderIncludesToSearchSet.Contains( include );
if( !isIncludePotentialReference )
@@ -1346,6 +1370,12 @@ namespace AssetUsageDetectorNamespace
{
if( !isInPlayMode || referenceNode.nodeObject.IsAsset() )
{
#if ASSET_USAGE_ADDRESSABLES
// See: https://github.com/yasirkula/UnityAssetUsageDetector/issues/29
if( searchParameters.addressablesSupport && ( (Object) referenceNode.nodeObject ).name == "Deprecated EditorExtensionImpl" )
return;
#endif
SerializedObject so = new SerializedObject( (Object) referenceNode.nodeObject );
SerializedProperty iterator = so.GetIterator();
SerializedProperty iteratorVisible = so.GetIterator();
@@ -1389,15 +1419,29 @@ namespace AssetUsageDetectorNamespace
break;
#if UNITY_2019_3_OR_NEWER
case SerializedPropertyType.ManagedReference:
propertyValue = GetRawSerializedPropertyValue( iterator ) as Object;
searchResult = SearchObject( PreferablyGameObject( propertyValue ) );
object managedReferenceValue = GetRawSerializedPropertyValue( iterator );
propertyValue = managedReferenceValue as Object;
searchResult = SearchObject( PreferablyGameObject( managedReferenceValue ) );
enterChildren = false;
break;
#endif
case SerializedPropertyType.Generic:
propertyValue = null;
searchResult = null;
enterChildren = true;
#if ASSET_USAGE_ADDRESSABLES
AssetReference assetReference;
if( searchParameters.addressablesSupport && iterator.type.StartsWithFast( "AssetReference" ) && ( assetReference = GetRawSerializedPropertyValue( iterator ) as AssetReference ) != null )
{
propertyValue = GetAddressablesAssetReferenceValue( assetReference );
searchResult = SearchObject( PreferablyGameObject( propertyValue ) );
enterChildren = false;
}
else
#endif
{
propertyValue = null;
searchResult = null;
enterChildren = true;
}
break;
default:
propertyValue = null;
@@ -1450,6 +1494,15 @@ namespace AssetUsageDetectorNamespace
// no need to have duplicate search entries
if( !( variableValue is ICollection ) )
{
#if ASSET_USAGE_ADDRESSABLES
if( searchParameters.addressablesSupport && variableValue is AssetReference )
{
variableValue = GetAddressablesAssetReferenceValue( (AssetReference) variableValue );
if( variableValue == null || variableValue.Equals( null ) )
continue;
}
#endif
ReferenceNode searchResult = SearchObject( PreferablyGameObject( variableValue ) );
if( searchResult != null && searchResult != referenceNode )
{
@@ -1617,6 +1670,10 @@ namespace AssetUsageDetectorNamespace
#endif
typeof( Collider2D ).IsAssignableFrom( currType ) ) )
continue;
// Ignore certain Material properties that are already searched via SearchMaterial function (also, if a material doesn't have a _Color or _BaseColor
// property and its "color" property is called, it logs an error to the console, so this rule helps avoid that scenario, as well)
else if( ( propertyName == "color" || propertyName == "mainTexture" ) && typeof( Material ).IsAssignableFrom( currType ) )
continue;
// Ignore "parameters" property of Animator since it doesn't contain any useful data and logs a warning to the console when Animator is inactive
else if( typeof( Animator ).IsAssignableFrom( currType ) && propertyName == "parameters" )
continue;
@@ -1626,6 +1683,11 @@ namespace AssetUsageDetectorNamespace
// Ignore "meshFilter" property of TextMeshPro and TMP_SubMesh components because this property adds a MeshFilter component to the object if it doesn't exist
else if( propertyName == "meshFilter" && ( currType.Name == "TextMeshPro" || currType.Name == "TMP_SubMesh" ) )
continue;
// Ignore "users" property of TerrainData because it returns the Terrains in the scene that use that TerrainData. This causes issues with callStack because TerrainData
// is already in callStack when Terrains are searched via "users" property of it and hence, Terrain->TerrainData references for that TerrainData can't be found in scenes
// (this is how callStack works, it prevents searching an object if it's already in callStack to avoid infinite recursion)
else if( propertyName == "users" && typeof( TerrainData ).IsAssignableFrom( currType ) )
continue;
else
{
VariableGetVal getter = property.CreateGetter();
@@ -1723,29 +1785,71 @@ namespace AssetUsageDetectorNamespace
return enumerator.Current;
}
#if ASSET_USAGE_ADDRESSABLES
private Object GetAddressablesAssetReferenceValue( AssetReference assetReference )
{
Object result = assetReference.editorAsset;
if( !result )
return null;
string subObjectName = assetReference.SubObjectName;
if( !string.IsNullOrEmpty( subObjectName ) )
{
if( result is SpriteAtlas )
{
Sprite[] packedSprites = spriteAtlasPackedSpritesGetter( (SpriteAtlas) result );
if( packedSprites != null )
{
for( int i = 0; i < packedSprites.Length; i++ )
{
if( packedSprites[i] && packedSprites[i].name == subObjectName )
return packedSprites[i];
}
}
}
else
{
Type subObjectType = (Type) assetReferenceSubObjectTypeGetter.GetValue( assetReference, null ) ?? typeof( Object );
Object[] subAssets = AssetDatabase.LoadAllAssetRepresentationsAtPath( AssetDatabase.GetAssetPath( result ) );
for( int k = 0; k < subAssets.Length; k++ )
{
if( subAssets[k] && subAssets[k].name == subObjectName && subObjectType.IsAssignableFrom( subAssets[k].GetType() ) )
return subAssets[k];
}
}
}
return result;
}
#endif
// Iterates over all occurrences of specific key-value pairs in string
// Example1: #include "VALUE" valuePrefix=#include, valueWrapperChar="
// Example2: "guid": "VALUE" valuePrefix="guid", valueWrapperChar="
private void IterateOverValuesInString( string str, string valuePrefix, char valueWrapperChar, Action<string> valueAction )
private void IterateOverValuesInString( string str, string[] valuePrefixes, char valueWrapperChar, Action<string> valueAction )
{
int valueStartIndex, valueEndIndex = 0;
while( true )
for( int i = 0; i < valuePrefixes.Length; i++ )
{
valueStartIndex = str.IndexOf( valuePrefix, valueEndIndex );
if( valueStartIndex < 0 )
return;
string valuePrefix = valuePrefixes[i];
int valueStartIndex, valueEndIndex = 0;
while( true )
{
valueStartIndex = str.IndexOf( valuePrefix, valueEndIndex );
if( valueStartIndex < 0 )
break;
valueStartIndex = str.IndexOf( valueWrapperChar, valueStartIndex + valuePrefix.Length );
if( valueStartIndex < 0 )
return;
valueStartIndex = str.IndexOf( valueWrapperChar, valueStartIndex + valuePrefix.Length );
if( valueStartIndex < 0 )
break;
valueStartIndex++;
valueEndIndex = str.IndexOf( valueWrapperChar, valueStartIndex );
if( valueEndIndex < 0 )
return;
valueStartIndex++;
valueEndIndex = str.IndexOf( valueWrapperChar, valueStartIndex );
if( valueEndIndex < 0 )
break;
if( valueEndIndex > valueStartIndex )
valueAction( str.Substring( valueStartIndex, valueEndIndex - valueStartIndex ) );
if( valueEndIndex > valueStartIndex )
valueAction( str.Substring( valueStartIndex, valueEndIndex - valueStartIndex ) );
}
}
}
@@ -31,6 +31,7 @@ namespace AssetUsageDetectorNamespace
private const string PREFS_SEARCH_NON_SERIALIZABLES = "AUD_NonSerializables";
private const string PREFS_SEARCH_UNUSED_MATERIAL_PROPERTIES = "AUD_SearchUnusedMaterialProps";
private const string PREFS_LAZY_SCENE_SEARCH = "AUD_LazySceneSearch";
private const string PREFS_ADDRESSABLES_SUPPORT = "AUD_AddressablesSupport";
private const string PREFS_CALCULATE_UNUSED_OBJECTS = "AUD_FindUnusedObjs";
private const string PREFS_HIDE_DUPLICATE_ROWS = "AUD_HideDuplicates";
private const string PREFS_HIDE_REDUNDANT_PREFAB_VARIANT_LINKS = "AUD_HideRedundantPVariantLinks";
@@ -83,6 +84,9 @@ namespace AssetUsageDetectorNamespace
private int searchDepthLimit = 4; // Depth limit for recursively searching variables of objects
private bool lazySceneSearch = true;
#if ASSET_USAGE_ADDRESSABLES
private bool addressablesSupport = false;
#endif
private bool searchNonSerializableVariables = true;
private bool searchUnusedMaterialProperties = true;
private bool calculateUnusedObjects = false;
@@ -152,6 +156,14 @@ namespace AssetUsageDetectorNamespace
objectsToSearch[i].RefreshSubAssets();
} );
}
else if( currentPhase == Phase.Complete )
{
if( searchResult != null && searchResult.NumberOfGroups > 0 )
{
contextMenu.AddSeparator( "" );
contextMenu.AddItem( new GUIContent( "Collapse All" ), false, searchResult.CollapseAllSearchResultGroups );
}
}
}
// Shows lock button at the top-right corner
@@ -311,6 +323,9 @@ namespace AssetUsageDetectorNamespace
searchUnusedMaterialProperties = searchParameters.searchUnusedMaterialProperties;
searchRefactoring = searchParameters.searchRefactoring;
lazySceneSearch = searchParameters.lazySceneSearch;
#if ASSET_USAGE_ADDRESSABLES
addressablesSupport = searchParameters.addressablesSupport;
#endif
calculateUnusedObjects = searchParameters.calculateUnusedObjects;
hideDuplicateRows = searchParameters.hideDuplicateRows;
hideReduntantPrefabVariantLinks = searchParameters.hideReduntantPrefabVariantLinks;
@@ -390,6 +405,9 @@ namespace AssetUsageDetectorNamespace
EditorPrefs.SetBool( PREFS_SEARCH_NON_SERIALIZABLES, searchNonSerializableVariables );
EditorPrefs.SetBool( PREFS_SEARCH_UNUSED_MATERIAL_PROPERTIES, searchUnusedMaterialProperties );
EditorPrefs.SetBool( PREFS_LAZY_SCENE_SEARCH, lazySceneSearch );
#if ASSET_USAGE_ADDRESSABLES
EditorPrefs.SetBool( PREFS_ADDRESSABLES_SUPPORT, addressablesSupport );
#endif
EditorPrefs.SetBool( PREFS_CALCULATE_UNUSED_OBJECTS, calculateUnusedObjects );
EditorPrefs.SetBool( PREFS_HIDE_DUPLICATE_ROWS, hideDuplicateRows );
EditorPrefs.SetBool( PREFS_HIDE_REDUNDANT_PREFAB_VARIANT_LINKS, hideReduntantPrefabVariantLinks );
@@ -409,6 +427,9 @@ namespace AssetUsageDetectorNamespace
searchNonSerializableVariables = EditorPrefs.GetBool( PREFS_SEARCH_NON_SERIALIZABLES, true );
searchUnusedMaterialProperties = EditorPrefs.GetBool( PREFS_SEARCH_UNUSED_MATERIAL_PROPERTIES, true );
lazySceneSearch = EditorPrefs.GetBool( PREFS_LAZY_SCENE_SEARCH, true );
#if ASSET_USAGE_ADDRESSABLES
addressablesSupport = EditorPrefs.GetBool( PREFS_ADDRESSABLES_SUPPORT, false );
#endif
calculateUnusedObjects = EditorPrefs.GetBool( PREFS_CALCULATE_UNUSED_OBJECTS, false );
hideDuplicateRows = EditorPrefs.GetBool( PREFS_HIDE_DUPLICATE_ROWS, true );
hideReduntantPrefabVariantLinks = EditorPrefs.GetBool( PREFS_HIDE_REDUNDANT_PREFAB_VARIANT_LINKS, true );
@@ -461,7 +482,10 @@ namespace AssetUsageDetectorNamespace
GUILayout.Label( ". . . Search in progress or something went wrong (check console) . . ." );
if( GUILayout.Button( "RETURN", Utilities.GL_HEIGHT_30 ) )
{
ReturnToSetupPhase();
GUIUtility.ExitGUI();
}
}
else if( currentPhase == Phase.Setup )
{
@@ -540,7 +564,14 @@ namespace AssetUsageDetectorNamespace
GUILayout.Box( "<b>SETTINGS</b>", Utilities.BoxGUIStyle, Utilities.GL_EXPAND_WIDTH );
GUI.backgroundColor = c;
#if ASSET_USAGE_ADDRESSABLES
EditorGUI.BeginDisabledGroup( addressablesSupport );
#endif
lazySceneSearch = WordWrappingToggleLeft( "Lazy scene search: scenes are searched in detail only when they are manually refreshed (faster search)", lazySceneSearch );
#if ASSET_USAGE_ADDRESSABLES
EditorGUI.EndDisabledGroup();
addressablesSupport = WordWrappingToggleLeft( "Addressables support (WARNING: 'Lazy scene search' will be disabled) (slower search)", addressablesSupport );
#endif
calculateUnusedObjects = WordWrappingToggleLeft( "Calculate unused objects", calculateUnusedObjects );
hideDuplicateRows = WordWrappingToggleLeft( "Hide duplicate rows in search results", hideDuplicateRows );
#if UNITY_2018_3_OR_NEWER
@@ -576,7 +607,10 @@ namespace AssetUsageDetectorNamespace
GUI.enabled = true;
if( GUILayout.Button( "Reset Search", Utilities.GL_HEIGHT_30 ) )
{
ReturnToSetupPhase();
GUIUtility.ExitGUI();
}
if( searchResult == null )
{
@@ -673,7 +707,12 @@ namespace AssetUsageDetectorNamespace
//searchNonSerializableVariables = searchNonSerializableVariables,
searchUnusedMaterialProperties = searchUnusedMaterialProperties,
searchRefactoring = searchRefactoring,
#if ASSET_USAGE_ADDRESSABLES
lazySceneSearch = lazySceneSearch && !addressablesSupport,
addressablesSupport = addressablesSupport,
#else
lazySceneSearch = lazySceneSearch,
#endif
calculateUnusedObjects = calculateUnusedObjects,
hideDuplicateRows = hideDuplicateRows,
hideReduntantPrefabVariantLinks = hideReduntantPrefabVariantLinks,
@@ -371,9 +371,15 @@ namespace AssetUsageDetectorNamespace
return scrollPosition;
}
public int IndexOf( SearchResultGroup searchResult )
public int IndexOf( SearchResultGroup searchResultGroup )
{
return result.IndexOf( searchResult );
return result.IndexOf( searchResultGroup );
}
public void CollapseAllSearchResultGroups()
{
for( int i = 0; i < result.Count; i++ )
result[i].Collapse();
}
public void CancelDelayedTreeViewTooltip()
@@ -600,6 +606,11 @@ namespace AssetUsageDetectorNamespace
treeViewSearchField = null;
}
public void Collapse()
{
IsExpanded = false;
}
// Initializes commonly used variables of the nodes
public void InitializeNodes( HashSet<Object> objectsToSearchSet )
{
@@ -725,7 +736,7 @@ namespace AssetUsageDetectorNamespace
if( searchResult != null )
contextMenu.AddItem( new GUIContent( "Hide" ), false, () => searchResult.RemoveSearchResultGroup( this ) );
if( references.Count > 0 )
if( references.Count > 0 && treeView != null )
{
if( contextMenu.GetItemCount() > 0 )
contextMenu.AddSeparator( "" );
@@ -299,7 +299,7 @@ namespace AssetUsageDetectorNamespace
if( linkDescriptions.Count > 0 )
{
Object prefabObject = PrefabUtility.GetCorrespondingObjectFromSource( unityObject );
if( prefabObject && parentData.node.HasLinkToObjectWithDescriptions( prefabObject.GetHashCode(), linkDescriptions ) )
if( prefabObject && parentData.node.HasLinkToObjectWithDescriptions( prefabObject.GetInstanceID(), linkDescriptions ) )
return false;
}
}
+10 -1
View File
@@ -1,4 +1,4 @@
= Asset Usage Detector =
= Asset Usage Detector (v2.3.1) =
Online documentation available at: https://github.com/yasirkula/UnityAssetUsageDetector
E-mail: yasirkula@gmail.com
@@ -8,6 +8,15 @@ E-mail: yasirkula@gmail.com
This tool helps you find usages of the selected asset(s) and/or scene object(s), i.e. lists the objects that refer to them.
### ADDRESSABLES SUPPORT
This plugin has experimental support for Addressables package. However, the search may take significantly longer to finish when Addressables are searched. Some manual modifications are needed to enable Addressables support:
- The plugin mustn't be installed as a package, i.e. it must reside inside the Assets folder and not the Packages folder (it can reside inside a subfolder of Assets like Assets/Plugins)
- Add ASSET_USAGE_ADDRESSABLES compiler directive to "Player Settings/Scripting Define Symbols" (these symbols are platform specific, so if you change the active platform later, you'll have to add the compiler directive again)
- Add "Unity.Addressables" assembly to "AssetUsageDetector.Editor" Assembly Definition File's "Assembly Definition References" list
- Enable the "Addressables support" option in Asset Usage Detector window
### HOW TO
- Open "Window-Asset Usage Detector" window, configure the settings and hit "GO!". You can also right click an object and select "Search For References"
+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "com.yasirkula.assetusagedetector",
"displayName": "Asset Usage Detector",
"version": "2.2.1",
"version": "2.3.1",
"documentationUrl": "https://github.com/yasirkula/UnityAssetUsageDetector",
"changelogUrl": "https://github.com/yasirkula/UnityAssetUsageDetector/releases",
"licensesUrl": "https://github.com/yasirkula/UnityAssetUsageDetector/blob/master/LICENSE.txt",