diff --git a/Plugins/AssetUsageDetector/Editor/AssetUsageDetector.Editor.asmdef b/Plugins/AssetUsageDetector/Editor/AssetUsageDetector.Editor.asmdef index f02732f..4b6f479 100644 --- a/Plugins/AssetUsageDetector/Editor/AssetUsageDetector.Editor.asmdef +++ b/Plugins/AssetUsageDetector/Editor/AssetUsageDetector.Editor.asmdef @@ -2,7 +2,8 @@ "name": "AssetUsageDetector.Editor", "rootNamespace": "", "references": [ - "Unity.Addressables" + "Unity.Addressables", + "Unity.Addressables.Editor" ], "includePlatforms": [ "Editor" diff --git a/Plugins/AssetUsageDetector/Editor/AssetUsageDetectorSearchFunctions.cs b/Plugins/AssetUsageDetector/Editor/AssetUsageDetectorSearchFunctions.cs index ee2990b..b4d06be 100644 --- a/Plugins/AssetUsageDetector/Editor/AssetUsageDetectorSearchFunctions.cs +++ b/Plugins/AssetUsageDetector/Editor/AssetUsageDetectorSearchFunctions.cs @@ -5,6 +5,9 @@ using System.IO; using System.Reflection; using System.Text; using UnityEditor; +#if ASSET_USAGE_ADDRESSABLES +using UnityEditor.AddressableAssets.Settings; +#endif using UnityEditor.Animations; using UnityEngine; using UnityEngine.UI; @@ -217,6 +220,9 @@ namespace AssetUsageDetectorNamespace { typeof( LightmapSettings ), SearchLightmapSettings }, { typeof( RenderSettings ), SearchRenderSettings }, { typeof( SpriteAtlas ), SearchSpriteAtlas }, +#if ASSET_USAGE_ADDRESSABLES + { typeof(AddressableAssetSettings), SearchAddressableAssetSettings }, +#endif }; } @@ -1062,6 +1068,29 @@ namespace AssetUsageDetectorNamespace } } +#if ASSET_USAGE_ADDRESSABLES + private ReferenceNode SearchAddressableAssetSettings(object obj) + { + AddressableAssetSettings addressableSettings = (AddressableAssetSettings)obj; + ReferenceNode referenceNode = PopReferenceNode(addressableSettings); + + // Search Addressable groups + foreach (Object asset in assetsToSearchSet) + { + // Don't check redundant prefab objects + if (asset is Component) + continue; + if (asset is GameObject gameObject && gameObject.transform.parent != null) + continue; + + if (AssetDatabase.TryGetGUIDAndLocalFileIdentifier(asset, out string guid, out long _) && addressableSettings.FindAssetEntry(guid, true) is AddressableAssetEntry addressableEntry) + referenceNode.AddLinkTo(GetReferenceNode(asset), $"Addressable: \"{addressableEntry.parentGroup.Name}\" -> \"{addressableEntry.address}\""); + } + + return referenceNode; + } +#endif + // Find references from an Assembly Definition File to its Assembly Definition References private ReferenceNode SearchAssemblyDefinitionFile( object obj ) { diff --git a/Plugins/AssetUsageDetector/README.txt b/Plugins/AssetUsageDetector/README.txt index c63aa0a..e5d96e7 100644 --- a/Plugins/AssetUsageDetector/README.txt +++ b/Plugins/AssetUsageDetector/README.txt @@ -1,4 +1,4 @@ -= Asset Usage Detector (v2.5.7) = += Asset Usage Detector (v2.6.0) = Documentation: https://github.com/yasirkula/UnityAssetUsageDetector E-mail: yasirkula@gmail.com \ No newline at end of file diff --git a/package.json b/package.json index e79681e..cb0d81c 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "com.yasirkula.assetusagedetector", "displayName": "Asset Usage Detector", - "version": "2.5.7", + "version": "2.6.0", "documentationUrl": "https://github.com/yasirkula/UnityAssetUsageDetector", "changelogUrl": "https://github.com/yasirkula/UnityAssetUsageDetector/releases", "licensesUrl": "https://github.com/yasirkula/UnityAssetUsageDetector/blob/master/LICENSE.txt",