mirror of
https://github.com/yasirkula/UnityAssetUsageDetector.git
synced 2026-11-19 22:42:37 +08:00
Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 8cc7798f17 | |||
| 45b0f6f1d9 | |||
| c599ea6273 | |||
| 7ba33e2d4e | |||
| ac294324dd | |||
| 8dc7d5508b | |||
| c9131811e2 | |||
| 133b8b1227 |
@@ -420,6 +420,27 @@ namespace AssetUsageDetectorNamespace
|
||||
referenceNode.AddLinkTo( SearchObject( triggerModule.GetCollider( i ) ), "Trigger Module: Collider" );
|
||||
}
|
||||
catch { }
|
||||
|
||||
#if UNITY_2017_1_OR_NEWER
|
||||
try
|
||||
{
|
||||
ParticleSystem.TextureSheetAnimationModule textureSheetAnimationModule = particleSystem.textureSheetAnimation;
|
||||
for( int i = 0, j = textureSheetAnimationModule.spriteCount; i < j; i++ )
|
||||
referenceNode.AddLinkTo( SearchObject( textureSheetAnimationModule.GetSprite( i ) ), "Texture Sheet Animation Module: Sprite" );
|
||||
}
|
||||
catch { }
|
||||
#endif
|
||||
|
||||
|
||||
#if UNITY_5_5_OR_NEWER
|
||||
try
|
||||
{
|
||||
ParticleSystem.SubEmittersModule subEmittersModule = particleSystem.subEmitters;
|
||||
for( int i = 0, j = subEmittersModule.subEmittersCount; i < j; i++ )
|
||||
referenceNode.AddLinkTo( SearchObject( subEmittersModule.GetSubEmitterSystem( i ) ), "Sub Emitters Module: ParticleSystem" );
|
||||
}
|
||||
catch { }
|
||||
#endif
|
||||
}
|
||||
else if( searchRenderers && component is Renderer )
|
||||
{
|
||||
@@ -723,19 +744,61 @@ namespace AssetUsageDetectorNamespace
|
||||
if( packables != null )
|
||||
{
|
||||
for( int i = 0; i < packables.Length; i++ )
|
||||
referenceNode.AddLinkTo( SearchObject( packables[i] ), "Packed Texture" );
|
||||
SearchSpriteAtlas( referenceNode, packables[i] );
|
||||
}
|
||||
#else
|
||||
SerializedProperty packables = spriteAtlasSO.FindProperty( "m_EditorData.packables" );
|
||||
if( packables != null )
|
||||
{
|
||||
for( int i = 0, length = packables.arraySize; i < length; i++ )
|
||||
referenceNode.AddLinkTo( SearchObject( packables.GetArrayElementAtIndex( i ).objectReferenceValue ), "Packed Texture" );
|
||||
SearchSpriteAtlas( referenceNode, packables.GetArrayElementAtIndex( i ).objectReferenceValue );
|
||||
}
|
||||
#endif
|
||||
|
||||
return referenceNode;
|
||||
}
|
||||
|
||||
private void SearchSpriteAtlas( ReferenceNode referenceNode, Object packedAsset )
|
||||
{
|
||||
if( packedAsset == null || packedAsset.Equals( null ) )
|
||||
return;
|
||||
|
||||
referenceNode.AddLinkTo( SearchObject( packedAsset ), "Packed Texture" );
|
||||
|
||||
if( packedAsset is Texture )
|
||||
{
|
||||
// Search the Texture's sprites if the Texture asset isn't included in the "Find references of:" list (i.e. user has
|
||||
// added only a Sprite sub-asset of the Texture to the list, not the Texture asset itself). Otherwise, references to
|
||||
// both the Texture and its sprites will be found which can be considered as duplicate references
|
||||
if( AssetDatabase.IsMainAsset( packedAsset ) && !assetsToSearchSet.Contains( packedAsset ) )
|
||||
{
|
||||
Object[] textureSubAssets = AssetDatabase.LoadAllAssetRepresentationsAtPath( AssetDatabase.GetAssetPath( packedAsset ) );
|
||||
for( int i = 0; i < textureSubAssets.Length; i++ )
|
||||
{
|
||||
if( textureSubAssets[i] is Sprite )
|
||||
referenceNode.AddLinkTo( SearchObject( textureSubAssets[i] ), "Packed Texture" );
|
||||
}
|
||||
}
|
||||
}
|
||||
else if( packedAsset.IsFolder() )
|
||||
{
|
||||
// Search all Sprites in the folder
|
||||
string[] texturesInFolder = AssetDatabase.FindAssets( "t:Texture2D", new string[] { AssetDatabase.GetAssetPath( packedAsset ) } );
|
||||
if( texturesInFolder != null )
|
||||
{
|
||||
for( int i = 0; i < texturesInFolder.Length; i++ )
|
||||
{
|
||||
string texturePath = AssetDatabase.GUIDToAssetPath( texturesInFolder[i] );
|
||||
TextureImporter textureImporter = AssetImporter.GetAtPath( texturePath ) as TextureImporter;
|
||||
if( textureImporter != null && textureImporter.textureType == TextureImporterType.Sprite )
|
||||
{
|
||||
// Search the Texture and its sprites
|
||||
SearchSpriteAtlas( referenceNode, AssetDatabase.LoadMainAssetAtPath( texturePath ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if UNITY_2017_3_OR_NEWER
|
||||
@@ -917,6 +980,9 @@ namespace AssetUsageDetectorNamespace
|
||||
for( int i = 0; i < clips.Length; i++ )
|
||||
{
|
||||
AnimationClip clip = clips[i];
|
||||
if( !clip )
|
||||
continue;
|
||||
|
||||
bool isClipUnique = true;
|
||||
for( int j = i - 1; j >= 0; j-- )
|
||||
{
|
||||
|
||||
@@ -86,12 +86,18 @@ namespace AssetUsageDetectorNamespace
|
||||
Object prevObject = GetObjectFromElement( element );
|
||||
Object newObject = EditorGUILayout.ObjectField( "", prevObject, typeof( Object ), acceptSceneObjects );
|
||||
|
||||
if( GUI.changed && prevObject != newObject )
|
||||
if( GUI.changed )
|
||||
{
|
||||
hasChanged = true;
|
||||
SetObjectOfElement( list, i, newObject );
|
||||
}
|
||||
|
||||
if( guiEnabled && newObject && ev.type == EventType.ContextClick && GUILayoutUtility.GetLastRect().Contains( ev.mousePosition ) )
|
||||
{
|
||||
OnElementRightClicked( list, i, newObject );
|
||||
ev.Use();
|
||||
}
|
||||
|
||||
if( guiEnabled )
|
||||
{
|
||||
if( GUILayout.Button( "+", Utilities.GL_WIDTH_25 ) )
|
||||
@@ -121,6 +127,7 @@ namespace AssetUsageDetectorNamespace
|
||||
protected abstract T CreateElement( Object source );
|
||||
protected abstract Object GetObjectFromElement( T element );
|
||||
protected abstract void SetObjectOfElement( List<T> list, int index, Object value );
|
||||
protected abstract void OnElementRightClicked( List<T> list, int index, Object value );
|
||||
protected abstract bool IsElementNull( T element );
|
||||
protected abstract void PostElementDrawer( T element );
|
||||
}
|
||||
@@ -146,6 +153,10 @@ namespace AssetUsageDetectorNamespace
|
||||
list[index] = value;
|
||||
}
|
||||
|
||||
protected override void OnElementRightClicked( List<Object> list, int index, Object value )
|
||||
{
|
||||
}
|
||||
|
||||
protected override bool IsElementNull( Object element )
|
||||
{
|
||||
return element == null || element.Equals( null );
|
||||
@@ -178,6 +189,13 @@ namespace AssetUsageDetectorNamespace
|
||||
list[index].RefreshSubAssets();
|
||||
}
|
||||
|
||||
protected override void OnElementRightClicked( List<ObjectToSearch> list, int index, Object value )
|
||||
{
|
||||
GenericMenu contextMenu = new GenericMenu();
|
||||
contextMenu.AddItem( new GUIContent( "Refresh" ), false, () => SetObjectOfElement( list, index, value ) );
|
||||
contextMenu.ShowAsContext();
|
||||
}
|
||||
|
||||
protected override bool IsElementNull( ObjectToSearch element )
|
||||
{
|
||||
return element == null || element.obj == null || element.obj.Equals( null );
|
||||
|
||||
@@ -924,7 +924,11 @@ namespace AssetUsageDetectorNamespace
|
||||
if( !string.IsNullOrEmpty( description ) )
|
||||
{
|
||||
if( !string.IsNullOrEmpty( links[i].description ) )
|
||||
links[i] = new Link( links[i].targetNode, string.Concat( links[i].description, Environment.NewLine, description ) );
|
||||
{
|
||||
// Avoid duplicate descriptions
|
||||
if( !links[i].description.Contains( description ) )
|
||||
links[i] = new Link( links[i].targetNode, string.Concat( links[i].description, Environment.NewLine, description ) );
|
||||
}
|
||||
else
|
||||
links[i] = new Link( links[i].targetNode, description );
|
||||
}
|
||||
|
||||
@@ -88,7 +88,11 @@ namespace AssetUsageDetectorNamespace
|
||||
m_boxGUIStyle.focused.textColor = textColor;
|
||||
m_boxGUIStyle.active.textColor = textColor;
|
||||
|
||||
#if !UNITY_2019_1_OR_NEWER || UNITY_2019_3_OR_NEWER
|
||||
// On 2019.1 and 2019.2 versions, GUI.skin.button.fontSize returns 0 on some devices
|
||||
// https://forum.unity.com/threads/asset-usage-detector-find-references-to-an-asset-object-open-source.408134/page-3#post-7285954
|
||||
m_boxGUIStyle.fontSize = ( m_boxGUIStyle.fontSize + GUI.skin.button.fontSize ) / 2;
|
||||
#endif
|
||||
}
|
||||
|
||||
return m_boxGUIStyle;
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "com.yasirkula.assetusagedetector",
|
||||
"displayName": "Asset Usage Detector",
|
||||
"version": "1.9.5",
|
||||
"version": "1.9.8",
|
||||
"documentationUrl": "https://github.com/yasirkula/UnityAssetUsageDetector",
|
||||
"changelogUrl": "https://github.com/yasirkula/UnityAssetUsageDetector/releases",
|
||||
"licensesUrl": "https://github.com/yasirkula/UnityAssetUsageDetector/blob/master/LICENSE.txt",
|
||||
|
||||
Reference in New Issue
Block a user