From da921c2e064bdd69780c0d11523f0d49e68e7402 Mon Sep 17 00:00:00 2001 From: yasirkula Date: Sat, 18 Nov 2023 17:53:42 +0300 Subject: [PATCH] "Hide redundant prefab variant links" setting now works as expected, only affecting variables in components and not affecting prefab/MonoScript usages --- .../AssetUsageDetectorSearchFunctions.cs | 7 ++++++ .../AssetUsageDetector/Editor/SearchResult.cs | 24 ------------------- .../Editor/SearchResultTreeView.cs | 19 --------------- Plugins/AssetUsageDetector/README.txt | 2 +- package.json | 2 +- 5 files changed, 9 insertions(+), 45 deletions(-) diff --git a/Plugins/AssetUsageDetector/Editor/AssetUsageDetectorSearchFunctions.cs b/Plugins/AssetUsageDetector/Editor/AssetUsageDetectorSearchFunctions.cs index a8e09c8..26fa7ec 100644 --- a/Plugins/AssetUsageDetector/Editor/AssetUsageDetectorSearchFunctions.cs +++ b/Plugins/AssetUsageDetector/Editor/AssetUsageDetectorSearchFunctions.cs @@ -1451,6 +1451,9 @@ private void SearchVariablesWithSerializedObject( ReferenceNode referenceNode, b if( iterator.Next( true ) ) { bool iteratingVisible = iteratorVisible.NextVisible( true ); +#if UNITY_2018_3_OR_NEWER + bool searchPrefabOverridesOnly = searchParameters.hideReduntantPrefabVariantLinks && unityObject.IsAsset() && PrefabUtility.GetCorrespondingObjectFromSource( unityObject ) != null; +#endif bool enterChildren; do { @@ -1467,6 +1470,10 @@ private void SearchVariablesWithSerializedObject( ReferenceNode referenceNode, b if( !isVisible ) enterChildren = false; +#if UNITY_2018_3_OR_NEWER + else if( searchPrefabOverridesOnly && !iterator.prefabOverride ) + enterChildren = false; +#endif else { Object propertyValue; diff --git a/Plugins/AssetUsageDetector/Editor/SearchResult.cs b/Plugins/AssetUsageDetector/Editor/SearchResult.cs index cfb8f9e..5263228 100644 --- a/Plugins/AssetUsageDetector/Editor/SearchResult.cs +++ b/Plugins/AssetUsageDetector/Editor/SearchResult.cs @@ -1180,30 +1180,6 @@ public void SortLinks() } } - internal bool HasLinkToObjectWithDescriptions( int instanceId, List descriptions ) - { - for( int i = links.Count - 1; i >= 0; i-- ) - { - Link link = links[i]; - if( link.targetNode.instanceId == instanceId ) - { - List _descriptions = link.descriptions; - if( _descriptions.Count != descriptions.Count ) - return false; - - for( int j = _descriptions.Count - 1; j >= 0; j-- ) - { - if( _descriptions[j] != descriptions[j] ) - return false; - } - - return true; - } - } - - return false; - } - public void CopyReferencesTo( ReferenceNode other ) { other.links.Clear(); diff --git a/Plugins/AssetUsageDetector/Editor/SearchResultTreeView.cs b/Plugins/AssetUsageDetector/Editor/SearchResultTreeView.cs index 5767034..cbb68fa 100644 --- a/Plugins/AssetUsageDetector/Editor/SearchResultTreeView.cs +++ b/Plugins/AssetUsageDetector/Editor/SearchResultTreeView.cs @@ -287,25 +287,6 @@ protected override TreeViewItem BuildRoot() private bool GenerateRowsRecursive( TreeViewItem parent, ReferenceNode referenceNode, ReferenceNodeData parentData, int siblingIndex, int depth, bool? itemForcedVisibility, List stack, HashSet processedNodes, ref int id ) { -#if UNITY_2018_3_OR_NEWER - // If the same reference is found in both a prefab variant and its base prefab, omit the prefab variant to reduce the number of - // redundant links (changing the value in base prefab will automatically change the value in its variants, after all) - if( hideReduntantPrefabVariantLinks && depth > 0 ) - { - Object unityObject = referenceNode.UnityObject; - if( unityObject && ( unityObject is Component || unityObject is GameObject ) && unityObject.IsAsset() ) - { - List linkDescriptions = parentData.node[siblingIndex].descriptions; - if( linkDescriptions.Count > 0 ) - { - Object prefabObject = PrefabUtility.GetCorrespondingObjectFromSource( unityObject ); - if( prefabObject && parentData.node.HasLinkToObjectWithDescriptions( prefabObject.GetInstanceID(), linkDescriptions ) ) - return false; - } - } - } -#endif - TreeViewItem item = new TreeViewItem( id++, depth, "" ); ReferenceNodeData data = new ReferenceNodeData( item, referenceNode, parentData, siblingIndex ); diff --git a/Plugins/AssetUsageDetector/README.txt b/Plugins/AssetUsageDetector/README.txt index 35aca06..62cce7d 100644 --- a/Plugins/AssetUsageDetector/README.txt +++ b/Plugins/AssetUsageDetector/README.txt @@ -1,4 +1,4 @@ -= Asset Usage Detector (v2.5.0) = += Asset Usage Detector (v2.5.1) = 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 95c8555..f1255fb 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "com.yasirkula.assetusagedetector", "displayName": "Asset Usage Detector", - "version": "2.5.0", + "version": "2.5.1", "documentationUrl": "https://github.com/yasirkula/UnityAssetUsageDetector", "changelogUrl": "https://github.com/yasirkula/UnityAssetUsageDetector/releases", "licensesUrl": "https://github.com/yasirkula/UnityAssetUsageDetector/blob/master/LICENSE.txt",