mirror of
https://github.com/yasirkula/UnityAssetUsageDetector.git
synced 2026-11-19 22:42:37 +08:00
Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| ace8ac4947 | |||
| 02167c28a2 | |||
| 092b80ba29 | |||
| 524965aee7 | |||
| efad9fa158 | |||
| 6cd2b407cc | |||
| 3c4292159a | |||
| 1a2eba24bd | |||
| cf0fea56ab | |||
| 956aea1ced |
+2
-1
@@ -8,7 +8,7 @@
|
||||
|
||||
**Discord:** https://discord.gg/UJJt549AaV
|
||||
|
||||
**[Support the Developer ☕](https://yasirkula.itch.io/unity3d)**
|
||||
**[GitHub Sponsors ☕](https://github.com/sponsors/yasirkula)**
|
||||
|
||||
## ABOUT
|
||||
|
||||
@@ -68,5 +68,6 @@ void ReplaceFontUsages( Font from, Font to )
|
||||
|
||||
- *static* variables aren't searched
|
||||
- *Resources.Load* usages can't be found
|
||||
- *ref struct*s can't be searched
|
||||
- *GUIText* materials aren't searched
|
||||
- Textures in *Lens Flares* can't be searched
|
||||
|
||||
@@ -31,6 +31,7 @@ namespace AssetUsageDetectorNamespace
|
||||
public SceneSearchMode searchInScenes = SceneSearchMode.AllScenes;
|
||||
public Object[] searchInScenesSubset = null;
|
||||
public Object[] excludedScenesFromSearch = null;
|
||||
public bool searchInSceneLightingSettings = true;
|
||||
public bool searchInAssetsFolder = true;
|
||||
public Object[] searchInAssetsSubset = null;
|
||||
public Object[] excludedAssetsFromSearch = null;
|
||||
@@ -162,6 +163,7 @@ namespace AssetUsageDetectorNamespace
|
||||
|
||||
// Get the scenes that are open right now
|
||||
SceneSetup[] initialSceneSetup = !isInPlayMode ? EditorSceneManager.GetSceneManagerSetup() : null;
|
||||
Scene activeScene = EditorSceneManager.GetActiveScene();
|
||||
|
||||
// Make sure that the AssetDatabase is up-to-date
|
||||
AssetDatabase.SaveAssets();
|
||||
@@ -289,10 +291,10 @@ namespace AssetUsageDetectorNamespace
|
||||
if( ( searchParameters.searchInScenes & SceneSearchMode.OpenScenes ) == SceneSearchMode.OpenScenes )
|
||||
{
|
||||
// Get all open (and loaded) scenes
|
||||
for( int i = 0; i < EditorSceneManager.loadedSceneCount; i++ )
|
||||
for( int i = 0; i < SceneManager.sceneCount; i++ )
|
||||
{
|
||||
Scene scene = EditorSceneManager.GetSceneAt( i );
|
||||
if( scene.IsValid() )
|
||||
Scene scene = SceneManager.GetSceneAt( i );
|
||||
if( scene.IsValid() && scene.isLoaded )
|
||||
scenesToSearch.Add( scene.path );
|
||||
}
|
||||
}
|
||||
@@ -314,10 +316,10 @@ namespace AssetUsageDetectorNamespace
|
||||
if( isInPlayMode )
|
||||
{
|
||||
HashSet<string> openScenes = new HashSet<string>();
|
||||
for( int i = 0; i < EditorSceneManager.loadedSceneCount; i++ )
|
||||
for( int i = 0; i < SceneManager.sceneCount; i++ )
|
||||
{
|
||||
Scene scene = EditorSceneManager.GetSceneAt( i );
|
||||
if( scene.IsValid() )
|
||||
Scene scene = SceneManager.GetSceneAt( i );
|
||||
if( scene.IsValid() && scene.isLoaded )
|
||||
openScenes.Add( scene.path );
|
||||
}
|
||||
|
||||
@@ -524,7 +526,7 @@ namespace AssetUsageDetectorNamespace
|
||||
if( excludedScenesPathsSet.Contains( scenePath ) )
|
||||
continue;
|
||||
|
||||
SearchScene( scenePath, searchResult, searchParameters.lazySceneSearch, initialSceneSetup );
|
||||
SearchScene( scenePath, searchResult, searchParameters, initialSceneSetup );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -607,6 +609,10 @@ namespace AssetUsageDetectorNamespace
|
||||
|
||||
EditorUtility.ClearProgressBar();
|
||||
|
||||
// If the active scene was changed during search, reset it
|
||||
if( EditorSceneManager.GetActiveScene() != activeScene )
|
||||
EditorSceneManager.SetActiveScene( activeScene );
|
||||
|
||||
#if UNITY_2018_3_OR_NEWER
|
||||
// If a prefab stage was open when the search was triggered, try reopening the prefab stage after the search is completed
|
||||
if( !string.IsNullOrEmpty( openPrefabStageAssetPath ) )
|
||||
@@ -895,7 +901,7 @@ namespace AssetUsageDetectorNamespace
|
||||
}
|
||||
|
||||
// Search a scene for references
|
||||
private void SearchScene( string scenePath, List<SearchResultGroup> searchResult, bool lazySearch, SceneSetup[] initialSceneSetup )
|
||||
private void SearchScene( string scenePath, List<SearchResultGroup> searchResult, Parameters searchParameters, SceneSetup[] initialSceneSetup )
|
||||
{
|
||||
Scene scene = EditorSceneManager.GetSceneByPath( scenePath );
|
||||
if( isInPlayMode && !scene.isLoaded )
|
||||
@@ -911,7 +917,7 @@ namespace AssetUsageDetectorNamespace
|
||||
|
||||
if( !scene.isLoaded )
|
||||
{
|
||||
if( lazySearch )
|
||||
if( searchParameters.lazySceneSearch )
|
||||
{
|
||||
searchResult.Add( new SearchResultGroup( scenePath, SearchResultGroup.GroupType.Scene, true, true ) );
|
||||
return;
|
||||
@@ -927,6 +933,16 @@ namespace AssetUsageDetectorNamespace
|
||||
for( int i = 0; i < rootGameObjects.Length; i++ )
|
||||
SearchGameObjectRecursively( rootGameObjects[i] );
|
||||
|
||||
// Search through Lighting Settings (it requires changing the active scene but don't do that in play mode)
|
||||
if( searchParameters.searchInSceneLightingSettings && ( !isInPlayMode || SceneManager.GetActiveScene() == scene ) )
|
||||
{
|
||||
if( !isInPlayMode && EditorSceneManager.GetActiveScene() != scene )
|
||||
EditorSceneManager.SetActiveScene( scene );
|
||||
|
||||
BeginSearchObject( lightmapSettingsGetter() );
|
||||
BeginSearchObject( renderSettingsGetter() );
|
||||
}
|
||||
|
||||
// If no references are found in the scene and if the scene is not part of the initial scene setup, close it
|
||||
if( currentSearchResultGroup.NumberOfReferences == 0 )
|
||||
{
|
||||
|
||||
@@ -205,6 +205,12 @@ namespace AssetUsageDetectorNamespace
|
||||
private readonly FieldInfoGetter fieldInfoGetter = (FieldInfoGetter) Delegate.CreateDelegate( typeof( FieldInfoGetter ), typeof( Editor ).Assembly.GetType( "UnityEditor.ScriptAttributeUtility" ).GetMethod( "GetFieldInfoFromProperty", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static ) );
|
||||
#endif
|
||||
|
||||
private readonly Func<Object> lightmapSettingsGetter = (Func<Object>) Delegate.CreateDelegate( typeof( Func<Object> ), typeof( LightmapEditorSettings ).GetMethod( "GetLightmapSettings", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static ) );
|
||||
private readonly Func<Object> renderSettingsGetter = (Func<Object>) Delegate.CreateDelegate( typeof( Func<Object> ), typeof( RenderSettings ).GetMethod( "GetRenderSettings", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static ) );
|
||||
#if UNITY_2021_2_OR_NEWER
|
||||
private readonly Func<Cubemap> defaultReflectionProbeGetter = (Func<Cubemap>) Delegate.CreateDelegate( typeof( Func<Cubemap> ), typeof( RenderSettings ).GetProperty( "defaultReflection", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static ).GetGetMethod( true ) );
|
||||
#endif
|
||||
|
||||
#if ASSET_USAGE_ADDRESSABLES
|
||||
private readonly Func<SpriteAtlas, Sprite[]> spriteAtlasPackedSpritesGetter = (Func<SpriteAtlas, Sprite[]>) Delegate.CreateDelegate( typeof( Func<SpriteAtlas, Sprite[]> ), typeof( SpriteAtlasExtensions ).GetMethod( "GetPackedSprites", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static ) );
|
||||
private readonly PropertyInfo assetReferenceSubObjectTypeGetter = typeof( AssetReference ).GetProperty( "SubOjbectType", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance );
|
||||
@@ -235,6 +241,8 @@ namespace AssetUsageDetectorNamespace
|
||||
{ typeof( BlendTree ), SearchBlendTree },
|
||||
{ typeof( AnimationClip ), SearchAnimationClip },
|
||||
{ typeof( TerrainData ), SearchTerrainData },
|
||||
{ typeof( LightmapSettings ), SearchLightmapSettings },
|
||||
{ typeof( RenderSettings ), SearchRenderSettings },
|
||||
#if UNITY_2017_1_OR_NEWER
|
||||
{ typeof( SpriteAtlas ), SearchSpriteAtlas },
|
||||
#endif
|
||||
@@ -1007,6 +1015,36 @@ namespace AssetUsageDetectorNamespace
|
||||
return referenceNode;
|
||||
}
|
||||
|
||||
private ReferenceNode SearchLightmapSettings( object obj )
|
||||
{
|
||||
ReferenceNode referenceNode = PopReferenceNode( obj );
|
||||
|
||||
referenceNode.AddLinkTo( SearchObject( LightmapSettings.lightProbes ), "Light Probes" );
|
||||
|
||||
LightmapData[] lightmaps = LightmapSettings.lightmaps;
|
||||
if( lightmaps != null )
|
||||
{
|
||||
for( int i = 0; i < lightmaps.Length; i++ )
|
||||
referenceNode.AddLinkTo( SearchObject( lightmaps[i] ), "Lightmap" );
|
||||
}
|
||||
|
||||
SearchVariablesWithSerializedObject( referenceNode, true );
|
||||
return referenceNode;
|
||||
}
|
||||
|
||||
private ReferenceNode SearchRenderSettings( object obj )
|
||||
{
|
||||
ReferenceNode referenceNode = PopReferenceNode( obj );
|
||||
|
||||
#if UNITY_2021_2_OR_NEWER
|
||||
referenceNode.AddLinkTo( SearchObject( defaultReflectionProbeGetter() ), "Default Reflection Probe" );
|
||||
#else
|
||||
referenceNode.AddLinkTo( SearchObject( ReflectionProbe.defaultTexture ), "Default Reflection Probe" );
|
||||
#endif
|
||||
SearchVariablesWithSerializedObject( referenceNode, true );
|
||||
return referenceNode;
|
||||
}
|
||||
|
||||
#if UNITY_2017_1_OR_NEWER
|
||||
private ReferenceNode SearchSpriteAtlas( object obj )
|
||||
{
|
||||
@@ -1396,9 +1434,9 @@ namespace AssetUsageDetectorNamespace
|
||||
}
|
||||
|
||||
// Search through variables of an object with SerializedObject
|
||||
private void SearchVariablesWithSerializedObject( ReferenceNode referenceNode )
|
||||
private void SearchVariablesWithSerializedObject( ReferenceNode referenceNode, bool forceUseSerializedObject = false )
|
||||
{
|
||||
if( !isInPlayMode || referenceNode.nodeObject.IsAsset() )
|
||||
if( !isInPlayMode || referenceNode.nodeObject.IsAsset() || forceUseSerializedObject )
|
||||
{
|
||||
#if ASSET_USAGE_ADDRESSABLES
|
||||
// See: https://github.com/yasirkula/UnityAssetUsageDetector/issues/29
|
||||
@@ -1639,6 +1677,12 @@ namespace AssetUsageDetectorNamespace
|
||||
if( field.FieldType.IsIgnoredUnityType() )
|
||||
continue;
|
||||
|
||||
#if UNITY_2021_2_OR_NEWER
|
||||
// "ref struct"s can't be accessed via reflection
|
||||
if( field.FieldType.IsByRefLike )
|
||||
continue;
|
||||
#endif
|
||||
|
||||
// Additional filtering for fields:
|
||||
// 1- Ignore "m_RectTransform", "m_CanvasRenderer" and "m_Canvas" fields of Graphic components
|
||||
string fieldName = field.Name;
|
||||
@@ -1673,6 +1717,12 @@ namespace AssetUsageDetectorNamespace
|
||||
if( property.PropertyType.IsIgnoredUnityType() )
|
||||
continue;
|
||||
|
||||
#if UNITY_2021_2_OR_NEWER
|
||||
// "ref struct"s can't be accessed via reflection
|
||||
if( property.PropertyType.IsByRefLike )
|
||||
continue;
|
||||
#endif
|
||||
|
||||
// Skip properties without a getter function
|
||||
MethodInfo propertyGetter = property.GetGetMethod( true );
|
||||
if( propertyGetter == null )
|
||||
|
||||
@@ -96,6 +96,13 @@ namespace AssetUsageDetectorNamespace
|
||||
#endregion
|
||||
|
||||
#region Other Settings
|
||||
private static bool? m_showRootAssetName = null;
|
||||
public static bool ShowRootAssetName
|
||||
{
|
||||
get { if( m_showRootAssetName == null ) m_showRootAssetName = EditorPrefs.GetBool( "AUD_ShowRootAssetName", false ); return m_showRootAssetName.Value; }
|
||||
set { if( m_showRootAssetName == value ) return; m_showRootAssetName = value; EditorPrefs.SetBool( "AUD_ShowRootAssetName", value ); }
|
||||
}
|
||||
|
||||
private static bool? m_pingClickedObjects = null;
|
||||
public static bool PingClickedObjects
|
||||
{
|
||||
@@ -179,7 +186,9 @@ namespace AssetUsageDetectorNamespace
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
|
||||
SettingsHeaderColor = ColorField( "Settings Header Color", SettingsHeaderColor, Color.cyan );
|
||||
EditorGUIUtility.labelWidth += 140f;
|
||||
ShowRootAssetName = EditorGUILayout.Toggle( "Show Root Asset's Name For Sub-Assets (Requires Refresh)", ShowRootAssetName );
|
||||
EditorGUIUtility.labelWidth -= 140f;
|
||||
|
||||
EditorGUILayout.Space();
|
||||
|
||||
@@ -202,6 +211,7 @@ namespace AssetUsageDetectorNamespace
|
||||
|
||||
EditorGUILayout.Space();
|
||||
|
||||
SettingsHeaderColor = ColorField( "Settings Header Color", SettingsHeaderColor, Color.cyan );
|
||||
SearchResultGroupHeaderColor = ColorField( "Group Header Color", SearchResultGroupHeaderColor, Color.cyan );
|
||||
RootRowsBackgroundColor = ColorField( "Root Rows Background Color", RootRowsBackgroundColor, EditorGUIUtility.isProSkin ? new Color( 0f, 1f, 1f, 0.15f ) : new Color( 0f, 1f, 1f, 0.25f ) );
|
||||
RootRowsBorderColor = ColorField( "Root Rows Border Color", RootRowsBorderColor, EditorGUIUtility.isProSkin ? new Color( 0.15f, 0.15f, 0.15f, 1f ) : new Color( 0.375f, 0.375f, 0.375f, 1f ) );
|
||||
|
||||
@@ -22,6 +22,7 @@ namespace AssetUsageDetectorNamespace
|
||||
private enum WindowFilter { AlwaysReturnActive, ReturnActiveIfNotLocked, AlwaysReturnNew };
|
||||
|
||||
private const string PREFS_SEARCH_SCENES = "AUD_SceneSearch";
|
||||
private const string PREFS_SEARCH_SCENE_LIGHTING_SETTINGS = "AUD_LightingSettingsSearch";
|
||||
private const string PREFS_SEARCH_ASSETS = "AUD_AssetsSearch";
|
||||
private const string PREFS_SEARCH_PROJECT_SETTINGS = "AUD_ProjectSettingsSearch";
|
||||
private const string PREFS_DONT_SEARCH_SOURCE_ASSETS = "AUD_AssetsExcludeSrc";
|
||||
@@ -73,6 +74,7 @@ namespace AssetUsageDetectorNamespace
|
||||
private bool searchInScenesInBuild = true; // Scenes in build
|
||||
private bool searchInScenesInBuildTickedOnly = true; // Scenes in build (ticked only or not)
|
||||
private bool searchInAllScenes = true; // All scenes (including scenes that are not in build)
|
||||
private bool searchInSceneLightingSettings = true; // Window-Rendering-Lighting settings
|
||||
private bool searchInAssetsFolder = true; // Assets in Project window
|
||||
private bool dontSearchInSourceAssets = true; // objectsToSearch won't be searched for internal references
|
||||
private bool searchInProjectSettings = true; // Player Settings, Graphics Settings etc.
|
||||
@@ -313,6 +315,7 @@ namespace AssetUsageDetectorNamespace
|
||||
if( searchParameters != null )
|
||||
{
|
||||
ParseSceneSearchMode( searchParameters.searchInScenes );
|
||||
searchInSceneLightingSettings = searchParameters.searchInSceneLightingSettings;
|
||||
searchInAssetsFolder = searchParameters.searchInAssetsFolder;
|
||||
dontSearchInSourceAssets = searchParameters.dontSearchInSourceAssets;
|
||||
searchInProjectSettings = searchParameters.searchInProjectSettings;
|
||||
@@ -396,6 +399,7 @@ namespace AssetUsageDetectorNamespace
|
||||
private void SavePrefs()
|
||||
{
|
||||
EditorPrefs.SetInt( PREFS_SEARCH_SCENES, (int) GetSceneSearchMode( false ) );
|
||||
EditorPrefs.SetBool( PREFS_SEARCH_SCENE_LIGHTING_SETTINGS, searchInSceneLightingSettings );
|
||||
EditorPrefs.SetBool( PREFS_SEARCH_ASSETS, searchInAssetsFolder );
|
||||
EditorPrefs.SetBool( PREFS_DONT_SEARCH_SOURCE_ASSETS, dontSearchInSourceAssets );
|
||||
EditorPrefs.SetBool( PREFS_SEARCH_PROJECT_SETTINGS, searchInProjectSettings );
|
||||
@@ -417,7 +421,7 @@ namespace AssetUsageDetectorNamespace
|
||||
private void LoadPrefs()
|
||||
{
|
||||
ParseSceneSearchMode( (SceneSearchMode) EditorPrefs.GetInt( PREFS_SEARCH_SCENES, (int) ( SceneSearchMode.OpenScenes | SceneSearchMode.ScenesInBuildSettingsTickedOnly | SceneSearchMode.AllScenes ) ) );
|
||||
|
||||
searchInSceneLightingSettings = EditorPrefs.GetBool( PREFS_SEARCH_SCENE_LIGHTING_SETTINGS, true );
|
||||
searchInAssetsFolder = EditorPrefs.GetBool( PREFS_SEARCH_ASSETS, true );
|
||||
dontSearchInSourceAssets = EditorPrefs.GetBool( PREFS_DONT_SEARCH_SOURCE_ASSETS, true );
|
||||
searchInProjectSettings = EditorPrefs.GetBool( PREFS_SEARCH_PROJECT_SETTINGS, true );
|
||||
@@ -554,6 +558,10 @@ namespace AssetUsageDetectorNamespace
|
||||
GUILayout.EndVertical();
|
||||
GUILayout.EndHorizontal();
|
||||
|
||||
EditorGUI.BeginDisabledGroup( !searchInOpenScenes && !searchInScenesInBuild && !searchInAllScenes );
|
||||
searchInSceneLightingSettings = WordWrappingToggleLeft( "Scene Lighting Settings (WARNING: This may change the active scene during search)", searchInSceneLightingSettings );
|
||||
EditorGUI.EndDisabledGroup();
|
||||
|
||||
Utilities.DrawSeparatorLine();
|
||||
|
||||
searchInProjectSettings = WordWrappingToggleLeft( "Project Settings (Player Settings, Graphics Settings etc.)", searchInProjectSettings );
|
||||
@@ -695,6 +703,7 @@ namespace AssetUsageDetectorNamespace
|
||||
{
|
||||
objectsToSearch = !objectsToSearch.IsEmpty() ? new ObjectToSearchEnumerator( objectsToSearch ).ToArray() : null,
|
||||
searchInScenes = GetSceneSearchMode( true ),
|
||||
searchInSceneLightingSettings = searchInSceneLightingSettings,
|
||||
searchInAssetsFolder = searchInAssetsFolder,
|
||||
searchInAssetsSubset = !searchInAssetsSubset.IsEmpty() ? searchInAssetsSubset.ToArray() : null,
|
||||
excludedAssetsFromSearch = !excludedAssets.IsEmpty() ? excludedAssets.ToArray() : null,
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using UnityEditor;
|
||||
using UnityEditor.IMGUI.Controls;
|
||||
@@ -802,7 +803,12 @@ namespace AssetUsageDetectorNamespace
|
||||
}
|
||||
}
|
||||
|
||||
if( Type == GroupType.Scene && !EditorApplication.isPlaying && EditorSceneManager.loadedSceneCount > 1 )
|
||||
#if UNITY_2022_2_OR_NEWER
|
||||
int loadedSceneCount = SceneManager.loadedSceneCount;
|
||||
#else
|
||||
int loadedSceneCount = EditorSceneManager.loadedSceneCount;
|
||||
#endif
|
||||
if( Type == GroupType.Scene && !EditorApplication.isPlaying && loadedSceneCount > 1 )
|
||||
{
|
||||
// Show context menu when SearchResultGroup's header is right clicked
|
||||
Scene scene = EditorSceneManager.GetSceneByPath( ScenePath );
|
||||
@@ -1221,6 +1227,13 @@ namespace AssetUsageDetectorNamespace
|
||||
{
|
||||
instanceId = unityObject.GetInstanceID();
|
||||
Label = unityObject.name + " (" + unityObject.GetType().Name + ")";
|
||||
|
||||
if( AssetUsageDetectorSettings.ShowRootAssetName && unityObject.IsAsset() && !AssetDatabase.IsMainAsset( unityObject ) )
|
||||
{
|
||||
string mainAssetName = Path.GetFileNameWithoutExtension( AssetDatabase.GetAssetPath( unityObject ) );
|
||||
if( unityObject.name != mainAssetName )
|
||||
Label += " <" + mainAssetName + ">";
|
||||
}
|
||||
}
|
||||
else if( nodeObject != null )
|
||||
{
|
||||
|
||||
@@ -966,6 +966,8 @@ namespace AssetUsageDetectorNamespace
|
||||
for( int i = 0; i < item.children.Count; i++ )
|
||||
shouldExpand |= GetMainReferenceIdsRecursive( item.children[i], ids );
|
||||
}
|
||||
else
|
||||
shouldExpand = true; // No main reference is encountered in this branch; expand the whole branch
|
||||
|
||||
if( shouldExpand )
|
||||
ids.Add( item.id );
|
||||
@@ -1178,7 +1180,7 @@ namespace AssetUsageDetectorNamespace
|
||||
SearchResultTreeView isolatedTreeView = new SearchResultTreeView( new SearchResultTreeViewState(), selectedNodes, TreeType.IsolatedView, null, hideDuplicateRows, hideReduntantPrefabVariantLinks, false );
|
||||
isolatedTreeView.ExpandMainReferences();
|
||||
|
||||
SearchResultTreeViewIsolatedView.Show( new Vector2( EditorWindow.focusedWindow.position.width, isolatedTreeView.totalHeight + 1f ), isolatedTreeView, new GUIContent( selectedNodes[0].Label + ( selectedNodes.Count <= 1 ? "" : ( " (and " + ( selectedNodes.Count - 1 ) + " more)" ) ) ) );
|
||||
SearchResultTreeViewIsolatedView.Show( new Vector2( EditorWindow.focusedWindow.position.width, Mathf.Max( isolatedTreeView.totalHeight, EditorGUIUtility.singleLineHeight * 5f ) + 1f ), isolatedTreeView, new GUIContent( selectedNodes[0].Label + ( selectedNodes.Count <= 1 ? "" : ( " (and " + ( selectedNodes.Count - 1 ) + " more)" ) ) ) );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1332,7 +1334,7 @@ namespace AssetUsageDetectorNamespace
|
||||
SearchResultTreeViewIsolatedView window = CreateInstance<SearchResultTreeViewIsolatedView>();
|
||||
window.treeView = treeView;
|
||||
window.titleContent = title;
|
||||
window.ShowAuxWindow();
|
||||
window.Show();
|
||||
|
||||
window.minSize = new Vector2( 150f, Mathf.Min( preferredSize.y, EditorGUIUtility.singleLineHeight * 2f ) );
|
||||
window.position = new Rect( new Vector2( -9999f, -9999f ), preferredSize );
|
||||
|
||||
@@ -177,6 +177,12 @@ namespace AssetUsageDetectorNamespace
|
||||
selection = objTR.gameObject;
|
||||
#endif
|
||||
}
|
||||
else if( prefabAssetType == PrefabAssetType.Model )
|
||||
{
|
||||
objTR = ( (GameObject) obj ).transform;
|
||||
while( objTR.parent != null && objTR.parent.parent != null )
|
||||
objTR = objTR.parent;
|
||||
}
|
||||
#else
|
||||
Transform objTR = ( (GameObject) obj ).transform;
|
||||
while( objTR.parent != null && objTR.parent.parent != null )
|
||||
@@ -410,9 +416,9 @@ namespace AssetUsageDetectorNamespace
|
||||
// Check if all open scenes are saved (not dirty)
|
||||
public static bool AreScenesSaved()
|
||||
{
|
||||
for( int i = 0; i < EditorSceneManager.loadedSceneCount; i++ )
|
||||
for( int i = 0; i < SceneManager.sceneCount; i++ )
|
||||
{
|
||||
Scene scene = EditorSceneManager.GetSceneAt( i );
|
||||
Scene scene = SceneManager.GetSceneAt( i );
|
||||
if( scene.isDirty || string.IsNullOrEmpty( scene.path ) )
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using UnityEngine;
|
||||
|
||||
namespace AssetUsageDetectorNamespace
|
||||
@@ -39,7 +40,12 @@ namespace AssetUsageDetectorNamespace
|
||||
}
|
||||
catch( Exception e )
|
||||
{
|
||||
Debug.LogException( e );
|
||||
StringBuilder sb = Utilities.stringBuilder;
|
||||
sb.Length = 0;
|
||||
sb.Append( "Error while getting the value of (" ).Append( IsProperty ? ( (PropertyInfo) variable ).PropertyType : ( (FieldInfo) variable ).FieldType ).Append( ") " )
|
||||
.Append( variable.DeclaringType ).Append( "." ).Append( Name ).Append( ": " ).Append( e );
|
||||
|
||||
Debug.LogError( sb.ToString() );
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,45 +1,4 @@
|
||||
= Asset Usage Detector (v2.4.0) =
|
||||
= Asset Usage Detector (v2.5.0) =
|
||||
|
||||
Online documentation available at: https://github.com/yasirkula/UnityAssetUsageDetector
|
||||
E-mail: yasirkula@gmail.com
|
||||
|
||||
|
||||
### ABOUT
|
||||
This tool helps you find usages of the selected asset(s) and/or scene object(s), i.e. lists the objects that refer to them.
|
||||
|
||||
|
||||
### 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"
|
||||
|
||||
- Asset Usage Detector window can be locked via the "Lock" button in its context menu (or via the lock icon at the top-right corner). If all the
|
||||
open windows are locked, "Search For References" opens a new window
|
||||
|
||||
- Seach results are split into different groups (scenes, assets, Project Settings) and each group displays its search results in its own tree view.
|
||||
Tree views support multi-selection and keyboard navigation. It's possible to hide groups or rows via their context menu (right click)
|
||||
|
||||
- Each root row in a group's tree view represents a different searched object and is drawn with an outline. Usage(s) of a searched object are listed under it as
|
||||
child rows (with indentation). If a child row's label contains bold text inside square brackets (e.g. "[Variable: m_Shader]"), then that text describes how
|
||||
its parent row is connected to that row (i.e. the value assigned to the m_Shader variable of that row is its parent row). Child rows can have their own children
|
||||
as some references involve multiple steps (e.g. when a Texture reference is found in a material which is used in a prefab which is referenced by a scene object)
|
||||
|
||||
- Rows with green tint to their left are the main references. For example, main references in a scene are the GameObjects that belong to that scene
|
||||
|
||||
- Rows with yellow tint are the parent rows of the selected row(s). To see a row's connection to the searched object, the yellow tinted rows can be traversed
|
||||
from bottom to top (or, you can hover the cursor over a row and see its connection to the searched object in a tooltip)
|
||||
|
||||
- Rows with gradient blue tint are the other occurrences of the selected row(s) (a row can appear multiple times in the tree view, right clicking the row and
|
||||
selecting "Expand All Occurrences" will reveal them all)
|
||||
|
||||
- When "Hide duplicate rows" option is enabled and a row's label starts with "[D]", then it means that the row has appeared in the tree view before and its children
|
||||
were omitted to simplify the search results (because otherwise the same child rows would be displayed for each occurrence of that row). Only the first occurrence
|
||||
of a row will display its children when "Hide duplicate rows" is enabled. To find a row's first occurrence, you can right click it and select "Select First Occurrence"
|
||||
|
||||
- Inside "Unused Objects" group, if a row's label starts with "[!]", then it means that some of its children are used in the project and it isn't safe to delete
|
||||
that object. Right clicking the row and selecting "Show Used Children" will reveal the used children
|
||||
|
||||
- When a prefab's row is double clicked, that prefab is automatically opened in Prefab Mode
|
||||
|
||||
- Selections in tree views are completely independent from each other, it isn't possible to multi-select objects in different tree views. Likewise, selected rows in
|
||||
a tree view won't be highlighted in other tree views. "Hide duplicate rows" also works independently for each tree view
|
||||
|
||||
- You can tweak most settings/colors via "Project Settings/yasirkula/Asset Usage Detector" page (on older versions, this menu is located at "Preferences" window)
|
||||
Documentation: https://github.com/yasirkula/UnityAssetUsageDetector
|
||||
E-mail: yasirkula@gmail.com
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "com.yasirkula.assetusagedetector",
|
||||
"displayName": "Asset Usage Detector",
|
||||
"version": "2.4.0",
|
||||
"version": "2.5.0",
|
||||
"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