mirror of
https://github.com/yasirkula/UnityAssetUsageDetector.git
synced 2026-11-20 23:12:38 +08:00
Compare commits
14 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| b7b6f8815e | |||
| 40a28f5961 | |||
| b535e09ba2 | |||
| 499e4bc43e | |||
| 93c955993a | |||
| 21f8daffde | |||
| 8cc7798f17 | |||
| 45b0f6f1d9 | |||
| c599ea6273 | |||
| 7ba33e2d4e | |||
| ac294324dd | |||
| 8dc7d5508b | |||
| c9131811e2 | |||
| 133b8b1227 |
+5
-3
@@ -6,6 +6,8 @@
|
|||||||
|
|
||||||
**Forum Thread:** https://forum.unity.com/threads/asset-usage-detector-find-references-to-an-asset-object-open-source.408134/
|
**Forum Thread:** https://forum.unity.com/threads/asset-usage-detector-find-references-to-an-asset-object-open-source.408134/
|
||||||
|
|
||||||
|
**Discord:** https://discord.gg/UJJt549AaV
|
||||||
|
|
||||||
**[Support the Developer ☕](https://yasirkula.itch.io/unity3d)**
|
**[Support the Developer ☕](https://yasirkula.itch.io/unity3d)**
|
||||||
|
|
||||||
## ABOUT
|
## ABOUT
|
||||||
@@ -41,6 +43,6 @@ There are 5 ways to install this plugin:
|
|||||||
|
|
||||||
## KNOWN LIMITATIONS
|
## KNOWN LIMITATIONS
|
||||||
|
|
||||||
- *static* variables are not searched
|
- *static* variables aren't searched
|
||||||
- GUIText materials are not searched
|
- GUIText materials aren't searched
|
||||||
- Textures in Lens Flare's can not be searched
|
- Textures in Lens Flares can't be searched
|
||||||
|
|||||||
@@ -43,13 +43,13 @@ namespace AssetUsageDetectorNamespace
|
|||||||
public BindingFlags propertyModifiers = BindingFlags.Public | BindingFlags.NonPublic;
|
public BindingFlags propertyModifiers = BindingFlags.Public | BindingFlags.NonPublic;
|
||||||
public bool searchNonSerializableVariables = true;
|
public bool searchNonSerializableVariables = true;
|
||||||
|
|
||||||
public bool lazySceneSearch = false;
|
public bool lazySceneSearch = true;
|
||||||
public bool noAssetDatabaseChanges = false;
|
public bool noAssetDatabaseChanges = false;
|
||||||
public bool showDetailedProgressBar = false;
|
public bool showDetailedProgressBar = true;
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
// A set that contains the searched asset(s) and their sub-assets (if any)
|
// A set that contains the searched scene object(s), asset(s) and their sub-assets (if any)
|
||||||
private readonly HashSet<Object> objectsToSearchSet = new HashSet<Object>();
|
private readonly HashSet<Object> objectsToSearchSet = new HashSet<Object>();
|
||||||
// Scenes of scene object(s) in objectsToSearchSet
|
// Scenes of scene object(s) in objectsToSearchSet
|
||||||
private readonly HashSet<string> sceneObjectsToSearchScenesSet = new HashSet<string>();
|
private readonly HashSet<string> sceneObjectsToSearchScenesSet = new HashSet<string>();
|
||||||
@@ -100,26 +100,16 @@ namespace AssetUsageDetectorNamespace
|
|||||||
{
|
{
|
||||||
if( searchParameters == null )
|
if( searchParameters == null )
|
||||||
{
|
{
|
||||||
Debug.LogError( "searchParameters must not be null!" );
|
Debug.LogError( "'searchParameters' mustn't be null!" );
|
||||||
return new SearchResult( false, null, null, this, searchParameters );
|
return new SearchResult( false, null, null, this, searchParameters );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( searchParameters.objectsToSearch == null )
|
if( searchParameters.objectsToSearch == null )
|
||||||
{
|
{
|
||||||
Debug.LogError( "objectsToSearch list is empty!" );
|
Debug.LogError( "'objectsToSearch' list (\"Find references of:\") is empty!" );
|
||||||
return new SearchResult( false, null, null, this, searchParameters );
|
return new SearchResult( false, null, null, this, searchParameters );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( !EditorApplication.isPlaying && !Utilities.AreScenesSaved() )
|
|
||||||
{
|
|
||||||
// Don't start the search if at least one scene is currently dirty (not saved)
|
|
||||||
Debug.LogError( "Save open scenes first!" );
|
|
||||||
return new SearchResult( false, null, null, this, searchParameters );
|
|
||||||
}
|
|
||||||
|
|
||||||
List<SearchResultGroup> searchResult = null;
|
|
||||||
|
|
||||||
isInPlayMode = EditorApplication.isPlaying;
|
|
||||||
#if UNITY_2018_3_OR_NEWER
|
#if UNITY_2018_3_OR_NEWER
|
||||||
openPrefabStagePrefabAsset = null;
|
openPrefabStagePrefabAsset = null;
|
||||||
string openPrefabStageAssetPath = null;
|
string openPrefabStageAssetPath = null;
|
||||||
@@ -133,7 +123,7 @@ namespace AssetUsageDetectorNamespace
|
|||||||
if( openPrefabStage.scene.isDirty )
|
if( openPrefabStage.scene.isDirty )
|
||||||
{
|
{
|
||||||
// Don't start the search if a prefab stage is currently open and dirty (not saved)
|
// Don't start the search if a prefab stage is currently open and dirty (not saved)
|
||||||
Debug.LogError( "Save open prefabs first!" );
|
Debug.LogError( "Save open prefab first!" );
|
||||||
return new SearchResult( false, null, null, this, searchParameters );
|
return new SearchResult( false, null, null, this, searchParameters );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -152,6 +142,15 @@ namespace AssetUsageDetectorNamespace
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
List<SearchResultGroup> searchResult = null;
|
||||||
|
isInPlayMode = EditorApplication.isPlaying;
|
||||||
|
|
||||||
|
if( !isInPlayMode && !Utilities.AreScenesSaved() && !EditorUtility.DisplayDialog( "Asset Usage Detector", "Some scene(s) aren't saved. This may result in incorrect search results in those scene(s). Proceed?", "Yes", "Cancel" ) )
|
||||||
|
{
|
||||||
|
Debug.LogError( "Save open scene(s) first!" );
|
||||||
|
return new SearchResult( false, null, null, this, searchParameters );
|
||||||
|
}
|
||||||
|
|
||||||
// Get the scenes that are open right now
|
// Get the scenes that are open right now
|
||||||
SceneSetup[] initialSceneSetup = !isInPlayMode ? EditorSceneManager.GetSceneManagerSetup() : null;
|
SceneSetup[] initialSceneSetup = !isInPlayMode ? EditorSceneManager.GetSceneManagerSetup() : null;
|
||||||
|
|
||||||
@@ -611,7 +610,7 @@ namespace AssetUsageDetectorNamespace
|
|||||||
private void InitializeSearchResultNodes( List<SearchResultGroup> searchResult )
|
private void InitializeSearchResultNodes( List<SearchResultGroup> searchResult )
|
||||||
{
|
{
|
||||||
for( int i = 0; i < searchResult.Count; i++ )
|
for( int i = 0; i < searchResult.Count; i++ )
|
||||||
searchResult[i].InitializeNodes( GetReferenceNode );
|
searchResult[i].InitializeNodes( GetReferenceNode, objectsToSearchSet );
|
||||||
|
|
||||||
// If there are any empty groups after node initialization, remove those groups
|
// If there are any empty groups after node initialization, remove those groups
|
||||||
for( int i = searchResult.Count - 1; i >= 0; i-- )
|
for( int i = searchResult.Count - 1; i >= 0; i-- )
|
||||||
|
|||||||
@@ -383,44 +383,6 @@ namespace AssetUsageDetectorNamespace
|
|||||||
if( objectsToSearchSet.Contains( script ) )
|
if( objectsToSearchSet.Contains( script ) )
|
||||||
referenceNode.AddLinkTo( GetReferenceNode( script ) );
|
referenceNode.AddLinkTo( GetReferenceNode( script ) );
|
||||||
}
|
}
|
||||||
else if( component is ParticleSystemRenderer )
|
|
||||||
{
|
|
||||||
// Search ParticleSystemRenderer's custom meshes for references (they aren't searched by SerializedObject, unfortunately)
|
|
||||||
Mesh[] meshes = new Mesh[( (ParticleSystemRenderer) component ).meshCount];
|
|
||||||
int meshCount = ( (ParticleSystemRenderer) component ).GetMeshes( meshes );
|
|
||||||
for( int i = 0; i < meshCount; i++ )
|
|
||||||
referenceNode.AddLinkTo( SearchObject( meshes[i] ), "Renderer Module: Mesh" );
|
|
||||||
}
|
|
||||||
else if( component is ParticleSystem )
|
|
||||||
{
|
|
||||||
// Some ParticleSystem properties aren't searched by SerializedObject, search them manually instead
|
|
||||||
ParticleSystem particleSystem = (ParticleSystem) component;
|
|
||||||
referenceNode.AddLinkTo( SearchObject( particleSystem.lights.light ), "Light Module: Light" );
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
ParticleSystem.CollisionModule collisionModule = particleSystem.collision;
|
|
||||||
#if UNITY_2020_2_OR_NEWER
|
|
||||||
for( int i = 0, j = collisionModule.planeCount; i < j; i++ )
|
|
||||||
#else
|
|
||||||
for( int i = 0, j = collisionModule.maxPlaneCount; i < j; i++ )
|
|
||||||
#endif
|
|
||||||
referenceNode.AddLinkTo( SearchObject( collisionModule.GetPlane( i ) ), "Collision Module: Plane" );
|
|
||||||
}
|
|
||||||
catch { }
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
ParticleSystem.TriggerModule triggerModule = particleSystem.trigger;
|
|
||||||
#if UNITY_2020_2_OR_NEWER
|
|
||||||
for( int i = 0, j = triggerModule.colliderCount; i < j; i++ )
|
|
||||||
#else
|
|
||||||
for( int i = 0, j = triggerModule.maxColliderCount; i < j; i++ )
|
|
||||||
#endif
|
|
||||||
referenceNode.AddLinkTo( SearchObject( triggerModule.GetCollider( i ) ), "Trigger Module: Collider" );
|
|
||||||
}
|
|
||||||
catch { }
|
|
||||||
}
|
|
||||||
else if( searchRenderers && component is Renderer )
|
else if( searchRenderers && component is Renderer )
|
||||||
{
|
{
|
||||||
// If an asset is a shader, texture or material, and this component is a Renderer,
|
// If an asset is a shader, texture or material, and this component is a Renderer,
|
||||||
@@ -723,19 +685,61 @@ namespace AssetUsageDetectorNamespace
|
|||||||
if( packables != null )
|
if( packables != null )
|
||||||
{
|
{
|
||||||
for( int i = 0; i < packables.Length; i++ )
|
for( int i = 0; i < packables.Length; i++ )
|
||||||
referenceNode.AddLinkTo( SearchObject( packables[i] ), "Packed Texture" );
|
SearchSpriteAtlas( referenceNode, packables[i] );
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
SerializedProperty packables = spriteAtlasSO.FindProperty( "m_EditorData.packables" );
|
SerializedProperty packables = spriteAtlasSO.FindProperty( "m_EditorData.packables" );
|
||||||
if( packables != null )
|
if( packables != null )
|
||||||
{
|
{
|
||||||
for( int i = 0, length = packables.arraySize; i < length; i++ )
|
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
|
#endif
|
||||||
|
|
||||||
return referenceNode;
|
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
|
#endif
|
||||||
|
|
||||||
#if UNITY_2017_3_OR_NEWER
|
#if UNITY_2017_3_OR_NEWER
|
||||||
@@ -917,6 +921,9 @@ namespace AssetUsageDetectorNamespace
|
|||||||
for( int i = 0; i < clips.Length; i++ )
|
for( int i = 0; i < clips.Length; i++ )
|
||||||
{
|
{
|
||||||
AnimationClip clip = clips[i];
|
AnimationClip clip = clips[i];
|
||||||
|
if( !clip )
|
||||||
|
continue;
|
||||||
|
|
||||||
bool isClipUnique = true;
|
bool isClipUnique = true;
|
||||||
for( int j = i - 1; j >= 0; j-- )
|
for( int j = i - 1; j >= 0; j-- )
|
||||||
{
|
{
|
||||||
@@ -1029,54 +1036,42 @@ namespace AssetUsageDetectorNamespace
|
|||||||
SerializedProperty iteratorVisible = so.GetIterator();
|
SerializedProperty iteratorVisible = so.GetIterator();
|
||||||
if( iterator.Next( true ) )
|
if( iterator.Next( true ) )
|
||||||
{
|
{
|
||||||
string assetPath = AssetDatabase.GetAssetPath( (Object) referenceNode.nodeObject );
|
|
||||||
bool isProjectSettings = !string.IsNullOrEmpty( assetPath ) && assetPath.StartsWithFast( "ProjectSettings/" );
|
|
||||||
|
|
||||||
bool iteratingVisible = iteratorVisible.NextVisible( true );
|
bool iteratingVisible = iteratorVisible.NextVisible( true );
|
||||||
bool enterChildren;
|
bool enterChildren;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
if( isProjectSettings )
|
// Iterate over NextVisible properties AND the properties that have corresponding FieldInfos (internal Unity
|
||||||
{
|
// properties don't have FieldInfos so we are skipping them, which is good because search results found in
|
||||||
// Search Project Settings in full because for some reason, important settings like SRP asset
|
// those properties aren't interesting and mostly confusing)
|
||||||
// slot in Quality Settings aren't searched when iterating over only visible properties
|
bool isVisible = iteratingVisible && SerializedProperty.EqualContents( iterator, iteratorVisible );
|
||||||
enterChildren = true;
|
if( isVisible )
|
||||||
}
|
iteratingVisible = iteratorVisible.NextVisible( iteratorVisible.propertyType == SerializedPropertyType.Generic );
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Iterate over NextVisible properties AND the properties that have corresponding FieldInfos (internal Unity
|
Type propFieldType;
|
||||||
// properties don't have FieldInfos so we are skipping them, which is good because search results found in
|
isVisible = iterator.type == "Array" || fieldInfoGetter( iterator, out propFieldType ) != null;
|
||||||
// those properties aren't interesting and mostly confusing)
|
}
|
||||||
bool isVisible = iteratingVisible && SerializedProperty.EqualContents( iterator, iteratorVisible );
|
|
||||||
if( isVisible )
|
|
||||||
iteratingVisible = iteratorVisible.NextVisible( true );
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Type propFieldType;
|
|
||||||
isVisible = iterator.type == "Array" || fieldInfoGetter( iterator, out propFieldType ) != null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( !isVisible )
|
if( !isVisible )
|
||||||
{
|
{
|
||||||
enterChildren = false;
|
enterChildren = false;
|
||||||
continue;
|
continue;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ReferenceNode searchResult;
|
ReferenceNode searchResult;
|
||||||
switch( iterator.propertyType )
|
switch( iterator.propertyType )
|
||||||
{
|
{
|
||||||
case SerializedPropertyType.ObjectReference:
|
case SerializedPropertyType.ObjectReference:
|
||||||
searchResult = SearchObject( iterator.objectReferenceValue );
|
searchResult = SearchObject( PreferablyGameObject( iterator.objectReferenceValue ) );
|
||||||
enterChildren = false;
|
enterChildren = false;
|
||||||
break;
|
break;
|
||||||
case SerializedPropertyType.ExposedReference:
|
case SerializedPropertyType.ExposedReference:
|
||||||
searchResult = SearchObject( iterator.exposedReferenceValue );
|
searchResult = SearchObject( PreferablyGameObject( iterator.exposedReferenceValue ) );
|
||||||
enterChildren = false;
|
enterChildren = false;
|
||||||
break;
|
break;
|
||||||
#if UNITY_2019_3_OR_NEWER
|
#if UNITY_2019_3_OR_NEWER
|
||||||
case SerializedPropertyType.ManagedReference:
|
case SerializedPropertyType.ManagedReference:
|
||||||
searchResult = SearchObject( GetRawSerializedPropertyValue( iterator ) );
|
searchResult = SearchObject( PreferablyGameObject( GetRawSerializedPropertyValue( iterator ) ) );
|
||||||
enterChildren = false;
|
enterChildren = false;
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
@@ -1129,7 +1124,7 @@ namespace AssetUsageDetectorNamespace
|
|||||||
// no need to have duplicate search entries
|
// no need to have duplicate search entries
|
||||||
if( !( variableValue is ICollection ) )
|
if( !( variableValue is ICollection ) )
|
||||||
{
|
{
|
||||||
ReferenceNode searchResult = SearchObject( variableValue );
|
ReferenceNode searchResult = SearchObject( PreferablyGameObject( variableValue ) );
|
||||||
if( searchResult != null && searchResult != referenceNode )
|
if( searchResult != null && searchResult != referenceNode )
|
||||||
referenceNode.AddLinkTo( searchResult, ( variables[i].isProperty ? "Property: " : "Variable: " ) + variables[i].name );
|
referenceNode.AddLinkTo( searchResult, ( variables[i].isProperty ? "Property: " : "Variable: " ) + variables[i].name );
|
||||||
}
|
}
|
||||||
@@ -1141,7 +1136,7 @@ namespace AssetUsageDetectorNamespace
|
|||||||
int index = 0;
|
int index = 0;
|
||||||
foreach( object element in (IEnumerable) variableValue )
|
foreach( object element in (IEnumerable) variableValue )
|
||||||
{
|
{
|
||||||
ReferenceNode searchResult = SearchObject( element );
|
ReferenceNode searchResult = SearchObject( PreferablyGameObject( element ) );
|
||||||
if( searchResult != null && searchResult != referenceNode )
|
if( searchResult != null && searchResult != referenceNode )
|
||||||
referenceNode.AddLinkTo( searchResult, string.Concat( variables[i].isProperty ? "Property: " : "Variable: ", variables[i].name, "[", index + "]" ) );
|
referenceNode.AddLinkTo( searchResult, string.Concat( variables[i].isProperty ? "Property: " : "Variable: ", variables[i].name, "[", index + "]" ) );
|
||||||
|
|
||||||
@@ -1406,5 +1401,12 @@ namespace AssetUsageDetectorNamespace
|
|||||||
valueAction( str.Substring( valueStartIndex, valueEndIndex - valueStartIndex ) );
|
valueAction( str.Substring( valueStartIndex, valueEndIndex - valueStartIndex ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If obj is Component, switches to its GameObject
|
||||||
|
private object PreferablyGameObject( object obj )
|
||||||
|
{
|
||||||
|
Component component = obj as Component;
|
||||||
|
return ( component != null && !component.Equals( null ) ) ? component.gameObject : obj;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -55,14 +55,10 @@ namespace AssetUsageDetectorNamespace
|
|||||||
|
|
||||||
private int searchDepthLimit = 4; // Depth limit for recursively searching variables of objects
|
private int searchDepthLimit = 4; // Depth limit for recursively searching variables of objects
|
||||||
|
|
||||||
private bool restoreInitialSceneSetup = true; // Close the additively loaded scenes that were not part of the initial scene setup
|
private bool lazySceneSearch = true;
|
||||||
|
|
||||||
private string errorMessage = string.Empty;
|
|
||||||
|
|
||||||
private bool lazySceneSearch = false;
|
|
||||||
private bool searchNonSerializableVariables = true;
|
private bool searchNonSerializableVariables = true;
|
||||||
private bool noAssetDatabaseChanges = false;
|
private bool noAssetDatabaseChanges = false;
|
||||||
private bool showDetailedProgressBar = false;
|
private bool showDetailedProgressBar = true;
|
||||||
|
|
||||||
private BindingFlags fieldModifiers, propertyModifiers;
|
private BindingFlags fieldModifiers, propertyModifiers;
|
||||||
|
|
||||||
@@ -75,7 +71,6 @@ namespace AssetUsageDetectorNamespace
|
|||||||
private readonly ObjectListDrawer excludedAssetsDrawer = new ObjectListDrawer( "Don't search following asset(s):", false );
|
private readonly ObjectListDrawer excludedAssetsDrawer = new ObjectListDrawer( "Don't search following asset(s):", false );
|
||||||
private readonly ObjectListDrawer excludedScenesDrawer = new ObjectListDrawer( "Don't search in following scene(s):", false );
|
private readonly ObjectListDrawer excludedScenesDrawer = new ObjectListDrawer( "Don't search in following scene(s):", false );
|
||||||
|
|
||||||
private readonly GUIContent restoreInitialSceneSetupLabel = new GUIContent( "Restore initial scene setup (Recommended)", "For example, if scene A was open when the search was started and scenes A and B are open after the search is completed, clicking the \"Reset Search\" button will automatically close scene B" );
|
|
||||||
private readonly GUIContent showTooltipsLabel = new GUIContent( "Show tooltips", "Display nodes' contents in a tooltip when cursor hovers over them" );
|
private readonly GUIContent showTooltipsLabel = new GUIContent( "Show tooltips", "Display nodes' contents in a tooltip when cursor hovers over them" );
|
||||||
|
|
||||||
private Vector2 scrollPosition = Vector2.zero;
|
private Vector2 scrollPosition = Vector2.zero;
|
||||||
@@ -193,7 +188,7 @@ namespace AssetUsageDetectorNamespace
|
|||||||
|
|
||||||
private static void ShowAndSearchInternal( IEnumerable<Object> searchObjects, AssetUsageDetector.Parameters searchParameters, bool? shouldSearchChildren )
|
private static void ShowAndSearchInternal( IEnumerable<Object> searchObjects, AssetUsageDetector.Parameters searchParameters, bool? shouldSearchChildren )
|
||||||
{
|
{
|
||||||
if( mainWindow != null && !mainWindow.ReturnToSetupPhase( true, true ) )
|
if( mainWindow && !mainWindow.ReturnToSetupPhase() )
|
||||||
{
|
{
|
||||||
Debug.LogError( "Need to reset the previous search first!" );
|
Debug.LogError( "Need to reset the previous search first!" );
|
||||||
return;
|
return;
|
||||||
@@ -281,7 +276,7 @@ namespace AssetUsageDetectorNamespace
|
|||||||
SavePrefs();
|
SavePrefs();
|
||||||
|
|
||||||
if( searchResult != null && currentPhase == Phase.Complete )
|
if( searchResult != null && currentPhase == Phase.Complete )
|
||||||
searchResult.RestoreInitialSceneSetup( true );
|
searchResult.RestoreInitialSceneSetup();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnFocus()
|
private void OnFocus()
|
||||||
@@ -328,9 +323,9 @@ namespace AssetUsageDetectorNamespace
|
|||||||
}
|
}
|
||||||
|
|
||||||
searchNonSerializableVariables = EditorPrefs.GetBool( PREFS_SEARCH_NON_SERIALIZABLES, true );
|
searchNonSerializableVariables = EditorPrefs.GetBool( PREFS_SEARCH_NON_SERIALIZABLES, true );
|
||||||
lazySceneSearch = EditorPrefs.GetBool( PREFS_LAZY_SCENE_SEARCH, false );
|
lazySceneSearch = EditorPrefs.GetBool( PREFS_LAZY_SCENE_SEARCH, true );
|
||||||
searchResultDrawParameters.showTooltips = EditorPrefs.GetBool( PREFS_SHOW_TOOLTIPS, false );
|
searchResultDrawParameters.showTooltips = EditorPrefs.GetBool( PREFS_SHOW_TOOLTIPS, false );
|
||||||
showDetailedProgressBar = EditorPrefs.GetBool( PREFS_SHOW_PROGRESS, false );
|
showDetailedProgressBar = EditorPrefs.GetBool( PREFS_SHOW_PROGRESS, true );
|
||||||
}
|
}
|
||||||
|
|
||||||
private SceneSearchMode GetSceneSearchMode( bool hideOptionsInPlayMode )
|
private SceneSearchMode GetSceneSearchMode( bool hideOptionsInPlayMode )
|
||||||
@@ -380,28 +375,17 @@ namespace AssetUsageDetectorNamespace
|
|||||||
|
|
||||||
GUILayout.BeginVertical();
|
GUILayout.BeginVertical();
|
||||||
|
|
||||||
GUILayout.Space( 10 );
|
|
||||||
|
|
||||||
// Show the error message, if it is not empty
|
|
||||||
if( errorMessage.Length > 0 )
|
|
||||||
EditorGUILayout.HelpBox( errorMessage, MessageType.Error );
|
|
||||||
|
|
||||||
GUILayout.Space( 10 );
|
|
||||||
|
|
||||||
if( currentPhase == Phase.Processing )
|
if( currentPhase == Phase.Processing )
|
||||||
{
|
{
|
||||||
// If we are stuck at this phase, then we have encountered an exception
|
// If we are stuck at this phase, then we have encountered an exception
|
||||||
GUILayout.Label( ". . . Search in progress or something went wrong (check console) . . ." );
|
GUILayout.Label( ". . . Search in progress or something went wrong (check console) . . ." );
|
||||||
|
|
||||||
restoreInitialSceneSetup = EditorGUILayout.ToggleLeft( restoreInitialSceneSetupLabel, restoreInitialSceneSetup );
|
|
||||||
|
|
||||||
if( GUILayout.Button( "RETURN", Utilities.GL_HEIGHT_30 ) )
|
if( GUILayout.Button( "RETURN", Utilities.GL_HEIGHT_30 ) )
|
||||||
ReturnToSetupPhase( restoreInitialSceneSetup, false );
|
ReturnToSetupPhase();
|
||||||
}
|
}
|
||||||
else if( currentPhase == Phase.Setup )
|
else if( currentPhase == Phase.Setup )
|
||||||
{
|
{
|
||||||
if( objectsToSearchDrawer.Draw( objectsToSearch ) )
|
objectsToSearchDrawer.Draw( objectsToSearch );
|
||||||
errorMessage = string.Empty;
|
|
||||||
|
|
||||||
GUILayout.Space( 10 );
|
GUILayout.Space( 10 );
|
||||||
|
|
||||||
@@ -527,7 +511,7 @@ namespace AssetUsageDetectorNamespace
|
|||||||
|
|
||||||
lazySceneSearch = EditorGUILayout.ToggleLeft( "Lazy scene search: scenes are searched in detail only when they are manually refreshed (faster search)", lazySceneSearch );
|
lazySceneSearch = EditorGUILayout.ToggleLeft( "Lazy scene search: scenes are searched in detail only when they are manually refreshed (faster search)", lazySceneSearch );
|
||||||
noAssetDatabaseChanges = EditorGUILayout.ToggleLeft( "I haven't modified any assets/scenes since the last search (faster search)", noAssetDatabaseChanges );
|
noAssetDatabaseChanges = EditorGUILayout.ToggleLeft( "I haven't modified any assets/scenes since the last search (faster search)", noAssetDatabaseChanges );
|
||||||
showDetailedProgressBar = EditorGUILayout.ToggleLeft( "Show detailed progress bar (slower search)", showDetailedProgressBar );
|
showDetailedProgressBar = EditorGUILayout.ToggleLeft( "Update search progress bar more often (slower search)", showDetailedProgressBar );
|
||||||
|
|
||||||
GUILayout.Space( 10 );
|
GUILayout.Space( 10 );
|
||||||
|
|
||||||
@@ -551,10 +535,8 @@ namespace AssetUsageDetectorNamespace
|
|||||||
GUILayout.Space( 10 );
|
GUILayout.Space( 10 );
|
||||||
GUI.enabled = true;
|
GUI.enabled = true;
|
||||||
|
|
||||||
restoreInitialSceneSetup = EditorGUILayout.ToggleLeft( restoreInitialSceneSetupLabel, restoreInitialSceneSetup );
|
|
||||||
|
|
||||||
if( GUILayout.Button( "Reset Search", Utilities.GL_HEIGHT_30 ) )
|
if( GUILayout.Button( "Reset Search", Utilities.GL_HEIGHT_30 ) )
|
||||||
ReturnToSetupPhase( restoreInitialSceneSetup, false );
|
ReturnToSetupPhase();
|
||||||
|
|
||||||
if( searchResult == null )
|
if( searchResult == null )
|
||||||
{
|
{
|
||||||
@@ -647,46 +629,35 @@ namespace AssetUsageDetectorNamespace
|
|||||||
|
|
||||||
private void InitiateSearch()
|
private void InitiateSearch()
|
||||||
{
|
{
|
||||||
if( objectsToSearch.IsEmpty() )
|
currentPhase = Phase.Processing;
|
||||||
errorMessage = "ADD AN ASSET TO THE LIST FIRST!";
|
|
||||||
else if( !EditorApplication.isPlaying && !Utilities.AreScenesSaved() )
|
|
||||||
{
|
|
||||||
// Don't start the search if at least one scene is currently dirty (not saved)
|
|
||||||
errorMessage = "SAVE OPEN SCENES FIRST!";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
errorMessage = string.Empty;
|
|
||||||
currentPhase = Phase.Processing;
|
|
||||||
|
|
||||||
SavePrefs();
|
SavePrefs();
|
||||||
|
|
||||||
#if UNITY_2018_3_OR_NEWER
|
#if UNITY_2018_3_OR_NEWER
|
||||||
ReplacePrefabStageObjectsWithAssets( PrefabStageUtility.GetCurrentPrefabStage() );
|
ReplacePrefabStageObjectsWithAssets( PrefabStageUtility.GetCurrentPrefabStage() );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Start searching
|
// Start searching
|
||||||
searchResult = core.Run( new AssetUsageDetector.Parameters()
|
searchResult = core.Run( new AssetUsageDetector.Parameters()
|
||||||
{
|
{
|
||||||
objectsToSearch = new ObjectToSearchEnumerator( objectsToSearch ).ToArray(),
|
objectsToSearch = !objectsToSearch.IsEmpty() ? new ObjectToSearchEnumerator( objectsToSearch ).ToArray() : null,
|
||||||
searchInScenes = GetSceneSearchMode( true ),
|
searchInScenes = GetSceneSearchMode( true ),
|
||||||
searchInAssetsFolder = searchInAssetsFolder,
|
searchInAssetsFolder = searchInAssetsFolder,
|
||||||
searchInAssetsSubset = !searchInAssetsSubset.IsEmpty() ? searchInAssetsSubset.ToArray() : null,
|
searchInAssetsSubset = !searchInAssetsSubset.IsEmpty() ? searchInAssetsSubset.ToArray() : null,
|
||||||
excludedAssetsFromSearch = !excludedAssets.IsEmpty() ? excludedAssets.ToArray() : null,
|
excludedAssetsFromSearch = !excludedAssets.IsEmpty() ? excludedAssets.ToArray() : null,
|
||||||
dontSearchInSourceAssets = dontSearchInSourceAssets,
|
dontSearchInSourceAssets = dontSearchInSourceAssets,
|
||||||
excludedScenesFromSearch = !excludedScenes.IsEmpty() ? excludedScenes.ToArray() : null,
|
excludedScenesFromSearch = !excludedScenes.IsEmpty() ? excludedScenes.ToArray() : null,
|
||||||
searchInProjectSettings = searchInProjectSettings,
|
searchInProjectSettings = searchInProjectSettings,
|
||||||
//fieldModifiers = fieldModifiers,
|
//fieldModifiers = fieldModifiers,
|
||||||
//propertyModifiers = propertyModifiers,
|
//propertyModifiers = propertyModifiers,
|
||||||
//searchDepthLimit = searchDepthLimit,
|
//searchDepthLimit = searchDepthLimit,
|
||||||
//searchNonSerializableVariables = searchNonSerializableVariables,
|
//searchNonSerializableVariables = searchNonSerializableVariables,
|
||||||
lazySceneSearch = lazySceneSearch,
|
lazySceneSearch = lazySceneSearch,
|
||||||
noAssetDatabaseChanges = noAssetDatabaseChanges,
|
noAssetDatabaseChanges = noAssetDatabaseChanges,
|
||||||
showDetailedProgressBar = showDetailedProgressBar
|
showDetailedProgressBar = showDetailedProgressBar
|
||||||
} );
|
} );
|
||||||
|
|
||||||
currentPhase = Phase.Complete;
|
currentPhase = Phase.Complete;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if UNITY_2018_3_OR_NEWER
|
#if UNITY_2018_3_OR_NEWER
|
||||||
@@ -729,14 +700,12 @@ namespace AssetUsageDetectorNamespace
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
private bool ReturnToSetupPhase( bool restoreInitialSceneSetup, bool sceneSetupRestorationIsOptional )
|
private bool ReturnToSetupPhase()
|
||||||
{
|
{
|
||||||
if( searchResult != null && restoreInitialSceneSetup && !EditorApplication.isPlaying && !searchResult.RestoreInitialSceneSetup( sceneSetupRestorationIsOptional ) )
|
if( searchResult != null && !EditorApplication.isPlaying && !searchResult.RestoreInitialSceneSetup() )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
searchResult = null;
|
searchResult = null;
|
||||||
|
|
||||||
errorMessage = string.Empty;
|
|
||||||
currentPhase = Phase.Setup;
|
currentPhase = Phase.Setup;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -86,12 +86,18 @@ namespace AssetUsageDetectorNamespace
|
|||||||
Object prevObject = GetObjectFromElement( element );
|
Object prevObject = GetObjectFromElement( element );
|
||||||
Object newObject = EditorGUILayout.ObjectField( "", prevObject, typeof( Object ), acceptSceneObjects );
|
Object newObject = EditorGUILayout.ObjectField( "", prevObject, typeof( Object ), acceptSceneObjects );
|
||||||
|
|
||||||
if( GUI.changed && prevObject != newObject )
|
if( GUI.changed )
|
||||||
{
|
{
|
||||||
hasChanged = true;
|
hasChanged = true;
|
||||||
SetObjectOfElement( list, i, newObject );
|
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( guiEnabled )
|
||||||
{
|
{
|
||||||
if( GUILayout.Button( "+", Utilities.GL_WIDTH_25 ) )
|
if( GUILayout.Button( "+", Utilities.GL_WIDTH_25 ) )
|
||||||
@@ -121,6 +127,7 @@ namespace AssetUsageDetectorNamespace
|
|||||||
protected abstract T CreateElement( Object source );
|
protected abstract T CreateElement( Object source );
|
||||||
protected abstract Object GetObjectFromElement( T element );
|
protected abstract Object GetObjectFromElement( T element );
|
||||||
protected abstract void SetObjectOfElement( List<T> list, int index, Object value );
|
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 bool IsElementNull( T element );
|
||||||
protected abstract void PostElementDrawer( T element );
|
protected abstract void PostElementDrawer( T element );
|
||||||
}
|
}
|
||||||
@@ -146,6 +153,10 @@ namespace AssetUsageDetectorNamespace
|
|||||||
list[index] = value;
|
list[index] = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void OnElementRightClicked( List<Object> list, int index, Object value )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
protected override bool IsElementNull( Object element )
|
protected override bool IsElementNull( Object element )
|
||||||
{
|
{
|
||||||
return element == null || element.Equals( null );
|
return element == null || element.Equals( null );
|
||||||
@@ -178,6 +189,13 @@ namespace AssetUsageDetectorNamespace
|
|||||||
list[index].RefreshSubAssets();
|
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 )
|
protected override bool IsElementNull( ObjectToSearch element )
|
||||||
{
|
{
|
||||||
return element == null || element.obj == null || element.obj.Equals( null );
|
return element == null || element.obj == null || element.obj.Equals( null );
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
using UnityEditor;
|
using UnityEditor;
|
||||||
using UnityEditor.SceneManagement;
|
using UnityEditor.SceneManagement;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
@@ -328,17 +329,31 @@ namespace AssetUsageDetectorNamespace
|
|||||||
|
|
||||||
// Close the scenes that were not part of the initial scene setup
|
// Close the scenes that were not part of the initial scene setup
|
||||||
// Returns true if initial scene setup is restored successfully
|
// Returns true if initial scene setup is restored successfully
|
||||||
public bool RestoreInitialSceneSetup( bool optional )
|
public bool RestoreInitialSceneSetup()
|
||||||
{
|
{
|
||||||
if( initialSceneSetup == null || initialSceneSetup.Length == 0 )
|
if( initialSceneSetup == null || initialSceneSetup.Length == 0 )
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if( EditorApplication.isPlaying || !EditorSceneManager.SaveCurrentModifiedScenesIfUserWantsTo() )
|
if( EditorApplication.isPlaying )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if( optional && IsSceneSetupDifferentThanCurrentSetup() && !EditorUtility.DisplayDialog( "Scenes", "Restore initial scene setup?", "Yes", "Leave it as is" ) )
|
if( !IsSceneSetupDifferentThanCurrentSetup() )
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
StringBuilder sb = new StringBuilder( 300 );
|
||||||
|
sb.AppendLine( "Restore initial scene setup?" );
|
||||||
|
for( int i = 0; i < initialSceneSetup.Length; i++ )
|
||||||
|
sb.AppendLine().Append( "- " ).Append( initialSceneSetup[i].path );
|
||||||
|
|
||||||
|
switch( EditorUtility.DisplayDialogComplex( "Asset Usage Detector", sb.ToString(), "Yes", "Cancel", "Leave it as is" ) )
|
||||||
|
{
|
||||||
|
case 1: return false;
|
||||||
|
case 2: return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( !EditorSceneManager.SaveCurrentModifiedScenesIfUserWantsTo() )
|
||||||
|
return false;
|
||||||
|
|
||||||
for( int i = 0; i < initialSceneSetup.Length; i++ )
|
for( int i = 0; i < initialSceneSetup.Length; i++ )
|
||||||
{
|
{
|
||||||
Scene scene = EditorSceneManager.GetSceneByPath( initialSceneSetup[i].path );
|
Scene scene = EditorSceneManager.GetSceneByPath( initialSceneSetup[i].path );
|
||||||
@@ -500,7 +515,7 @@ namespace AssetUsageDetectorNamespace
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Initializes commonly used variables of the nodes
|
// Initializes commonly used variables of the nodes
|
||||||
public void InitializeNodes( Func<object, ReferenceNode> nodeGetter )
|
public void InitializeNodes( Func<object, ReferenceNode> nodeGetter, HashSet<Object> objectsToSearchSet )
|
||||||
{
|
{
|
||||||
// Remove root nodes that don't have any outgoing links or have null node objects (somehow)
|
// Remove root nodes that don't have any outgoing links or have null node objects (somehow)
|
||||||
for( int i = references.Count - 1; i >= 0; i-- )
|
for( int i = references.Count - 1; i >= 0; i-- )
|
||||||
@@ -529,6 +544,26 @@ namespace AssetUsageDetectorNamespace
|
|||||||
|
|
||||||
List<ReferenceNode> callStack = new List<ReferenceNode>( 8 );
|
List<ReferenceNode> callStack = new List<ReferenceNode>( 8 );
|
||||||
|
|
||||||
|
// If this SearchResultGroup belongs to a scene, simplify the root nodes so that they go directly to either the searched objects or to an asset in a single link
|
||||||
|
if( Type == GroupType.Scene || Type == GroupType.DontDestroyOnLoad )
|
||||||
|
{
|
||||||
|
Scene scene = references[0].nodeObject is GameObject ? ( (GameObject) references[0].nodeObject ).scene : ( (Component) references[0].nodeObject ).gameObject.scene;
|
||||||
|
HashSet<ReferenceNode> leafNodes = new HashSet<ReferenceNode>();
|
||||||
|
for( int i = references.Count - 1; i >= 0; i-- )
|
||||||
|
{
|
||||||
|
references[i].GetLeafSceneNodesRecursive( scene, leafNodes, references[i], objectsToSearchSet, callStack );
|
||||||
|
|
||||||
|
if( leafNodes.Count > 0 )
|
||||||
|
{
|
||||||
|
references.RemoveAt( i );
|
||||||
|
foreach( ReferenceNode leafNode in leafNodes )
|
||||||
|
references.Add( leafNode );
|
||||||
|
|
||||||
|
leafNodes.Clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// For simplicity's sake, get rid of root nodes that are already part of another node's hierarchy
|
// For simplicity's sake, get rid of root nodes that are already part of another node's hierarchy
|
||||||
for( int i = references.Count - 1; i >= 0; i-- )
|
for( int i = references.Count - 1; i >= 0; i-- )
|
||||||
{
|
{
|
||||||
@@ -729,11 +764,8 @@ namespace AssetUsageDetectorNamespace
|
|||||||
rect.width = 100f;
|
rect.width = 100f;
|
||||||
if( GUI.Button( rect, "Refresh" ) )
|
if( GUI.Button( rect, "Refresh" ) )
|
||||||
{
|
{
|
||||||
if( Utilities.AreScenesSaved() || ( EditorUtility.DisplayDialog( "Refresh", "Some scene(s) have unsaved changes, they must be saved before the refresh.", "Save Scenes", "Cancel" ) && EditorSceneManager.SaveOpenScenes() ) )
|
parameters.searchResult.RefreshSearchResultGroup( this, parameters.noAssetDatabaseChanges );
|
||||||
{
|
GUIUtility.ExitGUI();
|
||||||
parameters.searchResult.RefreshSearchResultGroup( this, parameters.noAssetDatabaseChanges );
|
|
||||||
GUIUtility.ExitGUI();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -924,7 +956,11 @@ namespace AssetUsageDetectorNamespace
|
|||||||
if( !string.IsNullOrEmpty( description ) )
|
if( !string.IsNullOrEmpty( description ) )
|
||||||
{
|
{
|
||||||
if( !string.IsNullOrEmpty( links[i].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
|
else
|
||||||
links[i] = new Link( links[i].targetNode, description );
|
links[i] = new Link( links[i].targetNode, description );
|
||||||
}
|
}
|
||||||
@@ -994,12 +1030,59 @@ namespace AssetUsageDetectorNamespace
|
|||||||
description = "<<destroyed>>";
|
description = "<<destroyed>>";
|
||||||
}
|
}
|
||||||
|
|
||||||
nodeObject = null; // don't hold Object reference, allow Unity to GC used memory
|
nodeObject = null; // Don't hold Object reference, allow Unity to GC used memory
|
||||||
|
|
||||||
for( int i = 0; i < links.Count; i++ )
|
for( int i = 0; i < links.Count; i++ )
|
||||||
links[i].targetNode.InitializeRecursively();
|
links[i].targetNode.InitializeRecursively();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Finds all leaf nodes that originate from this node and have GameObject/Component node objects in the specified scene
|
||||||
|
public void GetLeafSceneNodesRecursive( Scene scene, HashSet<ReferenceNode> leafNodes, ReferenceNode latestSceneObjectNode, HashSet<Object> objectsToSearchSet, List<ReferenceNode> callStack )
|
||||||
|
{
|
||||||
|
if( links.Count == 0 || callStack.ContainsFast( this ) || ( nodeObject is Object && objectsToSearchSet.Contains( (Object) nodeObject ) ) ) // This is a searched object's node
|
||||||
|
{
|
||||||
|
leafNodes.Add( latestSceneObjectNode );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Object unityObject = nodeObject as Object;
|
||||||
|
if( unityObject != null )
|
||||||
|
{
|
||||||
|
if( AssetDatabase.Contains( unityObject ) )
|
||||||
|
{
|
||||||
|
leafNodes.Add( latestSceneObjectNode );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else if( unityObject is Component )
|
||||||
|
{
|
||||||
|
if( ( (Component) unityObject ).gameObject.scene == scene )
|
||||||
|
latestSceneObjectNode = this;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
leafNodes.Add( latestSceneObjectNode );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if( unityObject is GameObject )
|
||||||
|
{
|
||||||
|
if( ( (GameObject) unityObject ).scene == scene )
|
||||||
|
latestSceneObjectNode = this;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
leafNodes.Add( latestSceneObjectNode );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
callStack.Add( this );
|
||||||
|
|
||||||
|
for( int i = 0; i < links.Count; i++ )
|
||||||
|
links[i].targetNode.GetLeafSceneNodesRecursive( scene, leafNodes, latestSceneObjectNode, objectsToSearchSet, callStack );
|
||||||
|
|
||||||
|
callStack.RemoveAt( callStack.Count - 1 );
|
||||||
|
}
|
||||||
|
|
||||||
// Returns whether or not specified node is part of this node's siblings
|
// Returns whether or not specified node is part of this node's siblings
|
||||||
public bool NodeExistsInChildrenRecursive( ReferenceNode node, List<ReferenceNode> callStack )
|
public bool NodeExistsInChildrenRecursive( ReferenceNode node, List<ReferenceNode> callStack )
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -88,7 +88,11 @@ namespace AssetUsageDetectorNamespace
|
|||||||
m_boxGUIStyle.focused.textColor = textColor;
|
m_boxGUIStyle.focused.textColor = textColor;
|
||||||
m_boxGUIStyle.active.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;
|
m_boxGUIStyle.fontSize = ( m_boxGUIStyle.fontSize + GUI.skin.button.fontSize ) / 2;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
return m_boxGUIStyle;
|
return m_boxGUIStyle;
|
||||||
|
|||||||
@@ -3,17 +3,12 @@
|
|||||||
Online documentation available at: https://github.com/yasirkula/UnityAssetUsageDetector
|
Online documentation available at: https://github.com/yasirkula/UnityAssetUsageDetector
|
||||||
E-mail: yasirkula@gmail.com
|
E-mail: yasirkula@gmail.com
|
||||||
|
|
||||||
1. ABOUT
|
### ABOUT
|
||||||
This tool helps you find usages of the selected asset(s) and/or Object(s) in your Unity project, i.e. lists the objects that refer to them.
|
This tool helps you find usages of the selected asset(s) and/or Object(s) in your Unity project, i.e. lists the objects that refer to them.
|
||||||
|
|
||||||
2. HOW TO
|
### HOW TO
|
||||||
Open "Window-Asset Usage Detector" window, configure the settings and hit GO! You can also right click an object and select "Search For References".
|
Open "Window-Asset Usage Detector" window, configure the settings and hit GO! You can also right click an object and select "Search For References".
|
||||||
|
|
||||||
In the search results page, each row represents a reference to the searched Object(s). Rows can be traversed from left to right to see how the
|
In the search results page, each row represents a reference to the searched Object(s). Rows can be traversed from left to right to see how the
|
||||||
references are formed. If a node's label contains text inside square brackets (e.g. [Child object]), then that text describes how that node is
|
references are formed. If a node's label contains text inside square brackets (e.g. [Child object]), then that text describes how that node is
|
||||||
connected to the node to its left.
|
connected to the node to its left.
|
||||||
|
|
||||||
3. KNOWN LIMITATIONS
|
|
||||||
- static variables are not searched
|
|
||||||
- GUIText materials are not searched
|
|
||||||
- Textures in Lens Flare's can not be searched
|
|
||||||
+1
-1
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "com.yasirkula.assetusagedetector",
|
"name": "com.yasirkula.assetusagedetector",
|
||||||
"displayName": "Asset Usage Detector",
|
"displayName": "Asset Usage Detector",
|
||||||
"version": "1.9.5",
|
"version": "2.0.0",
|
||||||
"documentationUrl": "https://github.com/yasirkula/UnityAssetUsageDetector",
|
"documentationUrl": "https://github.com/yasirkula/UnityAssetUsageDetector",
|
||||||
"changelogUrl": "https://github.com/yasirkula/UnityAssetUsageDetector/releases",
|
"changelogUrl": "https://github.com/yasirkula/UnityAssetUsageDetector/releases",
|
||||||
"licensesUrl": "https://github.com/yasirkula/UnityAssetUsageDetector/blob/master/LICENSE.txt",
|
"licensesUrl": "https://github.com/yasirkula/UnityAssetUsageDetector/blob/master/LICENSE.txt",
|
||||||
|
|||||||
Reference in New Issue
Block a user