Skip to content

Commit da921c2

Browse files
committed
"Hide redundant prefab variant links" setting now works as expected, only affecting variables in components and not affecting prefab/MonoScript usages
1 parent d9cc52c commit da921c2

5 files changed

Lines changed: 9 additions & 45 deletions

File tree

Plugins/AssetUsageDetector/Editor/AssetUsageDetectorSearchFunctions.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1451,6 +1451,9 @@ private void SearchVariablesWithSerializedObject( ReferenceNode referenceNode, b
14511451
if( iterator.Next( true ) )
14521452
{
14531453
bool iteratingVisible = iteratorVisible.NextVisible( true );
1454+
#if UNITY_2018_3_OR_NEWER
1455+
bool searchPrefabOverridesOnly = searchParameters.hideReduntantPrefabVariantLinks && unityObject.IsAsset() && PrefabUtility.GetCorrespondingObjectFromSource( unityObject ) != null;
1456+
#endif
14541457
bool enterChildren;
14551458
do
14561459
{
@@ -1467,6 +1470,10 @@ private void SearchVariablesWithSerializedObject( ReferenceNode referenceNode, b
14671470

14681471
if( !isVisible )
14691472
enterChildren = false;
1473+
#if UNITY_2018_3_OR_NEWER
1474+
else if( searchPrefabOverridesOnly && !iterator.prefabOverride )
1475+
enterChildren = false;
1476+
#endif
14701477
else
14711478
{
14721479
Object propertyValue;

Plugins/AssetUsageDetector/Editor/SearchResult.cs

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1180,30 +1180,6 @@ public void SortLinks()
11801180
}
11811181
}
11821182

1183-
internal bool HasLinkToObjectWithDescriptions( int instanceId, List<string> descriptions )
1184-
{
1185-
for( int i = links.Count - 1; i >= 0; i-- )
1186-
{
1187-
Link link = links[i];
1188-
if( link.targetNode.instanceId == instanceId )
1189-
{
1190-
List<string> _descriptions = link.descriptions;
1191-
if( _descriptions.Count != descriptions.Count )
1192-
return false;
1193-
1194-
for( int j = _descriptions.Count - 1; j >= 0; j-- )
1195-
{
1196-
if( _descriptions[j] != descriptions[j] )
1197-
return false;
1198-
}
1199-
1200-
return true;
1201-
}
1202-
}
1203-
1204-
return false;
1205-
}
1206-
12071183
public void CopyReferencesTo( ReferenceNode other )
12081184
{
12091185
other.links.Clear();

Plugins/AssetUsageDetector/Editor/SearchResultTreeView.cs

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -287,25 +287,6 @@ protected override TreeViewItem BuildRoot()
287287

288288
private bool GenerateRowsRecursive( TreeViewItem parent, ReferenceNode referenceNode, ReferenceNodeData parentData, int siblingIndex, int depth, bool? itemForcedVisibility, List<ReferenceNode> stack, HashSet<ReferenceNode> processedNodes, ref int id )
289289
{
290-
#if UNITY_2018_3_OR_NEWER
291-
// If the same reference is found in both a prefab variant and its base prefab, omit the prefab variant to reduce the number of
292-
// redundant links (changing the value in base prefab will automatically change the value in its variants, after all)
293-
if( hideReduntantPrefabVariantLinks && depth > 0 )
294-
{
295-
Object unityObject = referenceNode.UnityObject;
296-
if( unityObject && ( unityObject is Component || unityObject is GameObject ) && unityObject.IsAsset() )
297-
{
298-
List<string> linkDescriptions = parentData.node[siblingIndex].descriptions;
299-
if( linkDescriptions.Count > 0 )
300-
{
301-
Object prefabObject = PrefabUtility.GetCorrespondingObjectFromSource( unityObject );
302-
if( prefabObject && parentData.node.HasLinkToObjectWithDescriptions( prefabObject.GetInstanceID(), linkDescriptions ) )
303-
return false;
304-
}
305-
}
306-
}
307-
#endif
308-
309290
TreeViewItem item = new TreeViewItem( id++, depth, "" );
310291
ReferenceNodeData data = new ReferenceNodeData( item, referenceNode, parentData, siblingIndex );
311292

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
= Asset Usage Detector (v2.5.0) =
1+
= Asset Usage Detector (v2.5.1) =
22

33
Documentation: https://github.com/yasirkula/UnityAssetUsageDetector
44
E-mail: yasirkula@gmail.com

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "com.yasirkula.assetusagedetector",
33
"displayName": "Asset Usage Detector",
4-
"version": "2.5.0",
4+
"version": "2.5.1",
55
"documentationUrl": "https://github.com/yasirkula/UnityAssetUsageDetector",
66
"changelogUrl": "https://github.com/yasirkula/UnityAssetUsageDetector/releases",
77
"licensesUrl": "https://github.com/yasirkula/UnityAssetUsageDetector/blob/master/LICENSE.txt",

0 commit comments

Comments
 (0)