Skip to content

Commit

Permalink
"Hide redundant prefab variant links" setting now works as expected, …
Browse files Browse the repository at this point in the history
…only affecting variables in components and not affecting prefab/MonoScript usages
  • Loading branch information
yasirkula committed Nov 18, 2023
1 parent d9cc52c commit da921c2
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 45 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -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;
Expand Down
24 changes: 0 additions & 24 deletions Plugins/AssetUsageDetector/Editor/SearchResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1180,30 +1180,6 @@ public void SortLinks()
}
}

internal bool HasLinkToObjectWithDescriptions( int instanceId, List<string> descriptions )
{
for( int i = links.Count - 1; i >= 0; i-- )
{
Link link = links[i];
if( link.targetNode.instanceId == instanceId )
{
List<string> _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();
Expand Down
19 changes: 0 additions & 19 deletions Plugins/AssetUsageDetector/Editor/SearchResultTreeView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -287,25 +287,6 @@ protected override TreeViewItem BuildRoot()

private bool GenerateRowsRecursive( TreeViewItem parent, ReferenceNode referenceNode, ReferenceNodeData parentData, int siblingIndex, int depth, bool? itemForcedVisibility, List<ReferenceNode> stack, HashSet<ReferenceNode> 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<string> 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 );

Expand Down
2 changes: 1 addition & 1 deletion Plugins/AssetUsageDetector/README.txt
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down

0 comments on commit da921c2

Please sign in to comment.