mirror of
https://github.com/yasirkula/UnityAssetUsageDetector.git
synced 2026-11-20 15:02:38 +08:00
Compare commits
46 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 8f8316266c | |||
| 6edf344ebc | |||
| e80ad3b905 | |||
| 0342ab20c9 | |||
| 6a158cba7e | |||
| 652dbe2171 | |||
| a1b66ced77 | |||
| 2bd6a02504 | |||
| 790a508dcd | |||
| d6a03aa8f2 | |||
| 177db66fbd | |||
| 4415d4b6f4 | |||
| 5104901c5d | |||
| 962f6e04d4 | |||
| 204de979ba | |||
| 50ce6f56c9 | |||
| 0f872ef04d | |||
| f68c8a1375 | |||
| ecfb1adf88 | |||
| e63ebd7f85 | |||
| d5b082c093 | |||
| 1faa789f48 | |||
| 610fffc763 | |||
| 9fddcab6fa | |||
| 66dd66787c | |||
| da921c2e06 | |||
| d9cc52cc37 | |||
| e6641bef48 | |||
| a6d91a58a3 | |||
| ace8ac4947 | |||
| 02167c28a2 | |||
| 092b80ba29 | |||
| 524965aee7 | |||
| efad9fa158 | |||
| 6cd2b407cc | |||
| 3c4292159a | |||
| 1a2eba24bd | |||
| cf0fea56ab | |||
| 956aea1ced | |||
| 466a152ba6 | |||
| 5eda0c1cb0 | |||
| 42e3278129 | |||
| f6a999f053 | |||
| 8441e4701c | |||
| d57a707678 | |||
| 3fa3344507 |
Binary file not shown.
|
Before Width: | Height: | Size: 20 KiB |
+4
-16
@@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
**Discord:** https://discord.gg/UJJt549AaV
|
**Discord:** https://discord.gg/UJJt549AaV
|
||||||
|
|
||||||
**[Support the Developer ☕](https://yasirkula.itch.io/unity3d)**
|
**[GitHub Sponsors ☕](https://github.com/sponsors/yasirkula)**
|
||||||
|
|
||||||
## ABOUT
|
## ABOUT
|
||||||
|
|
||||||
@@ -21,8 +21,8 @@ There are 5 ways to install this plugin:
|
|||||||
- import [AssetUsageDetector.unitypackage](https://github.com/yasirkula/UnityAssetUsageDetector/releases) via *Assets-Import Package*
|
- import [AssetUsageDetector.unitypackage](https://github.com/yasirkula/UnityAssetUsageDetector/releases) via *Assets-Import Package*
|
||||||
- clone/[download](https://github.com/yasirkula/UnityAssetUsageDetector/archive/master.zip) this repository and move the *Plugins* folder to your Unity project's *Assets* folder
|
- clone/[download](https://github.com/yasirkula/UnityAssetUsageDetector/archive/master.zip) this repository and move the *Plugins* folder to your Unity project's *Assets* folder
|
||||||
- import it from [Asset Store](https://assetstore.unity.com/packages/tools/utilities/asset-usage-detector-112837)
|
- import it from [Asset Store](https://assetstore.unity.com/packages/tools/utilities/asset-usage-detector-112837)
|
||||||
- *(via Package Manager)* add the following line to *Packages/manifest.json*:
|
- *(via Package Manager)* click the + button and install the package from the following git URL:
|
||||||
- `"com.yasirkula.assetusagedetector": "https://github.com/yasirkula/UnityAssetUsageDetector.git",`
|
- `https://github.com/yasirkula/UnityAssetUsageDetector.git`
|
||||||
- *(via [OpenUPM](https://openupm.com))* after installing [openupm-cli](https://github.com/openupm/openupm-cli), run the following command:
|
- *(via [OpenUPM](https://openupm.com))* after installing [openupm-cli](https://github.com/openupm/openupm-cli), run the following command:
|
||||||
- `openupm add com.yasirkula.assetusagedetector`
|
- `openupm add com.yasirkula.assetusagedetector`
|
||||||
|
|
||||||
@@ -37,18 +37,6 @@ There are 5 ways to install this plugin:
|
|||||||
|
|
||||||

|

|
||||||
|
|
||||||
## ADDRESSABLES SUPPORT
|
|
||||||
|
|
||||||
This plugin has experimental support for *Addressables* package. However, the search may take significantly longer to finish when Addressables are searched. Some manual modifications are needed to enable Addressables support:
|
|
||||||
|
|
||||||
- The plugin mustn't be installed as a package, i.e. it must reside inside the *Assets* folder and not the *Packages* folder (it can reside inside a subfolder of Assets like *Assets/Plugins*)
|
|
||||||
- Modify the **AssetUsageDetector.Editor** Assembly Definition File as follows:
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
- If *Version Defines* isn't present (on older Unity versions), manually add `ASSET_USAGE_ADDRESSABLES` compiler directive to **Player Settings/Scripting Define Symbols** (these symbols are platform specific, so if you change the active platform later, you'll have to add the compiler directive again)
|
|
||||||
- Enable the "Addressables support" option in Asset Usage Detector window
|
|
||||||
|
|
||||||
## SEARCH REFACTORING
|
## SEARCH REFACTORING
|
||||||
|
|
||||||
While searching for references using the Scripting API, it's possible to get notified of the found references *during* the search (some references like *Assembly Definition File* references or *Shader Graph* references aren't supported) and in most cases, refactor them (e.g. changing all usages of a searched object with something else or *null*). Disabling *Lazy Scene Search* is recommended while using this feature and it's advised to backup your project beforehand.
|
While searching for references using the Scripting API, it's possible to get notified of the found references *during* the search (some references like *Assembly Definition File* references or *Shader Graph* references aren't supported) and in most cases, refactor them (e.g. changing all usages of a searched object with something else or *null*). Disabling *Lazy Scene Search* is recommended while using this feature and it's advised to backup your project beforehand.
|
||||||
@@ -78,8 +66,8 @@ void ReplaceFontUsages( Font from, Font to )
|
|||||||
|
|
||||||
## KNOWN LIMITATIONS
|
## KNOWN LIMITATIONS
|
||||||
|
|
||||||
- *Addressables* aren't supported
|
|
||||||
- *static* variables aren't searched
|
- *static* variables aren't searched
|
||||||
- *Resources.Load* usages can't be found
|
- *Resources.Load* usages can't be found
|
||||||
|
- *ref struct*s can't be searched
|
||||||
- *GUIText* materials aren't searched
|
- *GUIText* materials aren't searched
|
||||||
- Textures in *Lens Flares* can't be searched
|
- Textures in *Lens Flares* can't be searched
|
||||||
|
|||||||
@@ -1,6 +1,10 @@
|
|||||||
{
|
{
|
||||||
"name": "AssetUsageDetector.Editor",
|
"name": "AssetUsageDetector.Editor",
|
||||||
"references": [],
|
"rootNamespace": "",
|
||||||
|
"references": [
|
||||||
|
"Unity.Addressables",
|
||||||
|
"Unity.Addressables.Editor"
|
||||||
|
],
|
||||||
"includePlatforms": [
|
"includePlatforms": [
|
||||||
"Editor"
|
"Editor"
|
||||||
],
|
],
|
||||||
@@ -10,6 +14,17 @@
|
|||||||
"precompiledReferences": [],
|
"precompiledReferences": [],
|
||||||
"autoReferenced": true,
|
"autoReferenced": true,
|
||||||
"defineConstraints": [],
|
"defineConstraints": [],
|
||||||
"versionDefines": [],
|
"versionDefines": [
|
||||||
|
{
|
||||||
|
"name": "com.unity.addressables",
|
||||||
|
"expression": "0.0.0",
|
||||||
|
"define": "ASSET_USAGE_ADDRESSABLES"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "com.unity.visualeffectgraph",
|
||||||
|
"expression": "0.0.0",
|
||||||
|
"define": "ASSET_USAGE_VFX_GRAPH"
|
||||||
|
}
|
||||||
|
],
|
||||||
"noEngineReferences": false
|
"noEngineReferences": false
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,3 @@
|
|||||||
// Asset Usage Detector - by Suleyman Yasir KULA (yasirkula@gmail.com)
|
|
||||||
|
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEditor;
|
using UnityEditor;
|
||||||
using UnityEngine.SceneManagement;
|
using UnityEngine.SceneManagement;
|
||||||
@@ -10,9 +8,10 @@ using System;
|
|||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using Object = UnityEngine.Object;
|
using Object = UnityEngine.Object;
|
||||||
#if UNITY_2018_3_OR_NEWER && !UNITY_2021_2_OR_NEWER
|
#if UNITY_6000_3_OR_NEWER
|
||||||
using PrefabStage = UnityEditor.Experimental.SceneManagement.PrefabStage;
|
using EntityId = UnityEngine.EntityId;
|
||||||
using PrefabStageUtility = UnityEditor.Experimental.SceneManagement.PrefabStageUtility;
|
#else
|
||||||
|
using EntityId = System.Int32;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace AssetUsageDetectorNamespace
|
namespace AssetUsageDetectorNamespace
|
||||||
@@ -31,16 +30,14 @@ namespace AssetUsageDetectorNamespace
|
|||||||
public SceneSearchMode searchInScenes = SceneSearchMode.AllScenes;
|
public SceneSearchMode searchInScenes = SceneSearchMode.AllScenes;
|
||||||
public Object[] searchInScenesSubset = null;
|
public Object[] searchInScenesSubset = null;
|
||||||
public Object[] excludedScenesFromSearch = null;
|
public Object[] excludedScenesFromSearch = null;
|
||||||
|
public bool searchInSceneLightingSettings = true;
|
||||||
public bool searchInAssetsFolder = true;
|
public bool searchInAssetsFolder = true;
|
||||||
public Object[] searchInAssetsSubset = null;
|
public Object[] searchInAssetsSubset = null;
|
||||||
public Object[] excludedAssetsFromSearch = null;
|
public Object[] excludedAssetsFromSearch = null;
|
||||||
public bool dontSearchInSourceAssets = true;
|
public bool dontSearchInSourceAssets = true;
|
||||||
public bool searchInProjectSettings = true;
|
public bool searchInProjectSettings = true;
|
||||||
|
|
||||||
public int searchDepthLimit = 4;
|
public int searchDepthLimit = 32;
|
||||||
public BindingFlags fieldModifiers = BindingFlags.Public | BindingFlags.NonPublic;
|
|
||||||
public BindingFlags propertyModifiers = BindingFlags.Public | BindingFlags.NonPublic;
|
|
||||||
public bool searchNonSerializableVariables = true;
|
|
||||||
|
|
||||||
public bool searchUnusedMaterialProperties = true;
|
public bool searchUnusedMaterialProperties = true;
|
||||||
|
|
||||||
@@ -52,7 +49,8 @@ namespace AssetUsageDetectorNamespace
|
|||||||
#endif
|
#endif
|
||||||
public bool calculateUnusedObjects = false;
|
public bool calculateUnusedObjects = false;
|
||||||
public bool hideDuplicateRows = true;
|
public bool hideDuplicateRows = true;
|
||||||
public bool hideReduntantPrefabVariantLinks = true;
|
public bool hideRedundantPrefabReferencesInAssets = false;
|
||||||
|
public bool hideRedundantPrefabReferencesInScenes = false;
|
||||||
public bool noAssetDatabaseChanges = false;
|
public bool noAssetDatabaseChanges = false;
|
||||||
public bool showDetailedProgressBar = true;
|
public bool showDetailedProgressBar = true;
|
||||||
}
|
}
|
||||||
@@ -80,24 +78,19 @@ namespace AssetUsageDetectorNamespace
|
|||||||
|
|
||||||
// An optimization to search an object only once (key is a hash of the searched object)
|
// An optimization to search an object only once (key is a hash of the searched object)
|
||||||
private readonly Dictionary<string, ReferenceNode> searchedObjects = new Dictionary<string, ReferenceNode>( 4096 );
|
private readonly Dictionary<string, ReferenceNode> searchedObjects = new Dictionary<string, ReferenceNode>( 4096 );
|
||||||
private readonly Dictionary<int, ReferenceNode> searchedUnityObjects = new Dictionary<int, ReferenceNode>( 32768 ); // Unity objects use their instanceIDs as key which is more performant
|
private readonly Dictionary<EntityId, ReferenceNode> searchedUnityObjects = new(32768); // Unity objects use their EntityIds as key
|
||||||
|
|
||||||
// Stack of SearchObject function parameters to avoid infinite loops (which happens when same object is passed as parameter to function)
|
// Stack of SearchObject function parameters to avoid infinite loops (which happens when same object is passed as parameter to function)
|
||||||
private readonly List<object> callStack = new List<object>( 64 );
|
private readonly List<object> callStack = new List<object>( 64 );
|
||||||
|
|
||||||
private Object currentSearchedObject;
|
private Object currentSearchedObject;
|
||||||
private int currentDepth;
|
|
||||||
|
|
||||||
private bool searchingSourceAssets;
|
private bool searchingSourceAssets;
|
||||||
private bool isInPlayMode;
|
private bool isInPlayMode;
|
||||||
|
|
||||||
#if UNITY_2018_3_OR_NEWER
|
|
||||||
private PrefabStage openPrefabStage;
|
private PrefabStage openPrefabStage;
|
||||||
private GameObject openPrefabStagePrefabAsset;
|
private GameObject openPrefabStagePrefabAsset;
|
||||||
#if UNITY_2020_1_OR_NEWER
|
|
||||||
private GameObject openPrefabStageContextObject;
|
private GameObject openPrefabStageContextObject;
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
private int searchedObjectsCount; // Number of searched objects
|
private int searchedObjectsCount; // Number of searched objects
|
||||||
private double searchStartTime;
|
private double searchStartTime;
|
||||||
@@ -119,7 +112,6 @@ namespace AssetUsageDetectorNamespace
|
|||||||
return new SearchResult( false, null, null, null, this, searchParameters );
|
return new SearchResult( false, null, null, null, this, searchParameters );
|
||||||
}
|
}
|
||||||
|
|
||||||
#if UNITY_2018_3_OR_NEWER
|
|
||||||
openPrefabStagePrefabAsset = null;
|
openPrefabStagePrefabAsset = null;
|
||||||
string openPrefabStageAssetPath = null;
|
string openPrefabStageAssetPath = null;
|
||||||
openPrefabStage = PrefabStageUtility.GetCurrentPrefabStage();
|
openPrefabStage = PrefabStageUtility.GetCurrentPrefabStage();
|
||||||
@@ -136,20 +128,12 @@ namespace AssetUsageDetectorNamespace
|
|||||||
return new SearchResult( false, null, null, null, this, searchParameters );
|
return new SearchResult( false, null, null, null, this, searchParameters );
|
||||||
}
|
}
|
||||||
|
|
||||||
#if UNITY_2020_1_OR_NEWER
|
|
||||||
string prefabAssetPath = openPrefabStage.assetPath;
|
string prefabAssetPath = openPrefabStage.assetPath;
|
||||||
#else
|
|
||||||
string prefabAssetPath = openPrefabStage.prefabAssetPath;
|
|
||||||
#endif
|
|
||||||
openPrefabStagePrefabAsset = AssetDatabase.LoadAssetAtPath<GameObject>( prefabAssetPath );
|
openPrefabStagePrefabAsset = AssetDatabase.LoadAssetAtPath<GameObject>( prefabAssetPath );
|
||||||
openPrefabStageAssetPath = prefabAssetPath;
|
openPrefabStageAssetPath = prefabAssetPath;
|
||||||
|
|
||||||
#if UNITY_2020_1_OR_NEWER
|
|
||||||
openPrefabStageContextObject = openPrefabStage.openedFromInstanceRoot;
|
openPrefabStageContextObject = openPrefabStage.openedFromInstanceRoot;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
List<SearchResultGroup> searchResult = null;
|
List<SearchResultGroup> searchResult = null;
|
||||||
isInPlayMode = EditorApplication.isPlaying;
|
isInPlayMode = EditorApplication.isPlaying;
|
||||||
@@ -162,6 +146,7 @@ namespace AssetUsageDetectorNamespace
|
|||||||
|
|
||||||
// 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;
|
||||||
|
Scene activeScene = EditorSceneManager.GetActiveScene();
|
||||||
|
|
||||||
// Make sure that the AssetDatabase is up-to-date
|
// Make sure that the AssetDatabase is up-to-date
|
||||||
AssetDatabase.SaveAssets();
|
AssetDatabase.SaveAssets();
|
||||||
@@ -174,7 +159,6 @@ namespace AssetUsageDetectorNamespace
|
|||||||
searchResult = new List<SearchResultGroup>(); // Overall search results
|
searchResult = new List<SearchResultGroup>(); // Overall search results
|
||||||
|
|
||||||
currentSearchedObject = null;
|
currentSearchedObject = null;
|
||||||
currentDepth = 0;
|
|
||||||
searchedObjectsCount = 0;
|
searchedObjectsCount = 0;
|
||||||
searchStartTime = EditorApplication.timeSinceStartup;
|
searchStartTime = EditorApplication.timeSinceStartup;
|
||||||
|
|
||||||
@@ -190,9 +174,7 @@ namespace AssetUsageDetectorNamespace
|
|||||||
excludedAssetsPathsSet.Clear();
|
excludedAssetsPathsSet.Clear();
|
||||||
alwaysSearchedExtensionsSet.Clear();
|
alwaysSearchedExtensionsSet.Clear();
|
||||||
shaderIncludesToSearchSet.Clear();
|
shaderIncludesToSearchSet.Clear();
|
||||||
#if UNITY_2017_3_OR_NEWER
|
|
||||||
assemblyDefinitionFilesToSearch.Clear();
|
assemblyDefinitionFilesToSearch.Clear();
|
||||||
#endif
|
|
||||||
|
|
||||||
if( assetDependencyCache == null )
|
if( assetDependencyCache == null )
|
||||||
{
|
{
|
||||||
@@ -289,10 +271,10 @@ namespace AssetUsageDetectorNamespace
|
|||||||
if( ( searchParameters.searchInScenes & SceneSearchMode.OpenScenes ) == SceneSearchMode.OpenScenes )
|
if( ( searchParameters.searchInScenes & SceneSearchMode.OpenScenes ) == SceneSearchMode.OpenScenes )
|
||||||
{
|
{
|
||||||
// Get all open (and loaded) scenes
|
// 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 );
|
Scene scene = SceneManager.GetSceneAt( i );
|
||||||
if( scene.IsValid() )
|
if( scene.IsValid() && scene.isLoaded )
|
||||||
scenesToSearch.Add( scene.path );
|
scenesToSearch.Add( scene.path );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -314,10 +296,10 @@ namespace AssetUsageDetectorNamespace
|
|||||||
if( isInPlayMode )
|
if( isInPlayMode )
|
||||||
{
|
{
|
||||||
HashSet<string> openScenes = new HashSet<string>();
|
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 );
|
Scene scene = SceneManager.GetSceneAt( i );
|
||||||
if( scene.IsValid() )
|
if( scene.IsValid() && scene.isLoaded )
|
||||||
openScenes.Add( scene.path );
|
openScenes.Add( scene.path );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -348,9 +330,9 @@ namespace AssetUsageDetectorNamespace
|
|||||||
// Initialize data used by search functions
|
// Initialize data used by search functions
|
||||||
InitializeSearchFunctionsData( searchParameters );
|
InitializeSearchFunctionsData( searchParameters );
|
||||||
|
|
||||||
// Initialize the nodes of searched asset(s)
|
// Initialize the nodes of searched asset(s)
|
||||||
foreach( Object obj in objectsToSearchSet )
|
foreach (Object obj in objectsToSearchSet)
|
||||||
searchedUnityObjects.Add( obj.GetHashCode(), PopReferenceNode( obj ) );
|
searchedUnityObjects.Add(obj.GetEntityId(), PopReferenceNode(obj));
|
||||||
|
|
||||||
// Progressbar values
|
// Progressbar values
|
||||||
int searchProgress = 0;
|
int searchProgress = 0;
|
||||||
@@ -451,7 +433,7 @@ namespace AssetUsageDetectorNamespace
|
|||||||
}
|
}
|
||||||
|
|
||||||
// If a reference is found in the Project view, save the results
|
// If a reference is found in the Project view, save the results
|
||||||
if( currentSearchResultGroup.NumberOfReferences > 0 )
|
if( currentSearchResultGroup.AnyReferencesFound )
|
||||||
searchResult.Add( currentSearchResultGroup );
|
searchResult.Add( currentSearchResultGroup );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -476,14 +458,10 @@ namespace AssetUsageDetectorNamespace
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if( currentSearchResultGroup.NumberOfReferences > 0 )
|
if( currentSearchResultGroup.AnyReferencesFound )
|
||||||
searchResult.Add( currentSearchResultGroup );
|
searchResult.Add( currentSearchResultGroup );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Search non-serializable variables for references while searching a scene in play mode
|
|
||||||
if( isInPlayMode )
|
|
||||||
searchSerializableVariablesOnly = false;
|
|
||||||
|
|
||||||
if( scenesToSearch.Count > 0 )
|
if( scenesToSearch.Count > 0 )
|
||||||
{
|
{
|
||||||
// Calculate the path(s) of the scenes that won't be searched for references
|
// Calculate the path(s) of the scenes that won't be searched for references
|
||||||
@@ -512,19 +490,28 @@ namespace AssetUsageDetectorNamespace
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Search scenes for references
|
||||||
foreach( string scenePath in scenesToSearch )
|
foreach( string scenePath in scenesToSearch )
|
||||||
{
|
{
|
||||||
if( EditorUtility.DisplayCancelableProgressBar( "Please wait...", "Searching scene: " + scenePath, (float) ++searchProgress / searchTotalProgress ) )
|
if( EditorUtility.DisplayCancelableProgressBar( "Please wait...", "Searching scene: " + scenePath, (float) ++searchProgress / searchTotalProgress ) )
|
||||||
throw new Exception( "Search aborted" );
|
throw new Exception( "Search aborted" );
|
||||||
|
|
||||||
// Search scene for references
|
|
||||||
if( string.IsNullOrEmpty( scenePath ) )
|
if( string.IsNullOrEmpty( scenePath ) )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if( excludedScenesPathsSet.Contains( scenePath ) )
|
if( excludedScenesPathsSet.Contains( scenePath ) )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
SearchScene( scenePath, searchResult, searchParameters.lazySceneSearch, initialSceneSetup );
|
// Skip scenes in read-only packages (Issue #36)
|
||||||
|
// Credit: https://forum.unity.com/threads/check-if-asset-inside-package-is-readonly.900902/#post-5990822
|
||||||
|
if( !scenePath.StartsWithFast( "Assets/" ) )
|
||||||
|
{
|
||||||
|
var packageInfo = UnityEditor.PackageManager.PackageInfo.FindForAssetPath( scenePath );
|
||||||
|
if( packageInfo != null && packageInfo.source != UnityEditor.PackageManager.PackageSource.Embedded && packageInfo.source != UnityEditor.PackageManager.PackageSource.Local )
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
SearchScene( scenePath, searchResult, searchParameters, initialSceneSetup );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -540,7 +527,7 @@ namespace AssetUsageDetectorNamespace
|
|||||||
for( int i = 0; i < rootGameObjects.Length; i++ )
|
for( int i = 0; i < rootGameObjects.Length; i++ )
|
||||||
SearchGameObjectRecursively( rootGameObjects[i] );
|
SearchGameObjectRecursively( rootGameObjects[i] );
|
||||||
|
|
||||||
if( currentSearchResultGroup.NumberOfReferences > 0 )
|
if( currentSearchResultGroup.AnyReferencesFound )
|
||||||
searchResult.Add( currentSearchResultGroup );
|
searchResult.Add( currentSearchResultGroup );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -607,11 +594,13 @@ namespace AssetUsageDetectorNamespace
|
|||||||
|
|
||||||
EditorUtility.ClearProgressBar();
|
EditorUtility.ClearProgressBar();
|
||||||
|
|
||||||
#if UNITY_2018_3_OR_NEWER
|
// If the active scene was changed during search, reset it
|
||||||
|
if( EditorSceneManager.GetActiveScene() != activeScene )
|
||||||
|
EditorSceneManager.SetActiveScene( activeScene );
|
||||||
|
|
||||||
// If a prefab stage was open when the search was triggered, try reopening the prefab stage after the search is completed
|
// 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 ) )
|
if( !string.IsNullOrEmpty( openPrefabStageAssetPath ) )
|
||||||
{
|
{
|
||||||
#if UNITY_2020_1_OR_NEWER
|
|
||||||
bool shouldOpenPrefabStageWithoutContext = true;
|
bool shouldOpenPrefabStageWithoutContext = true;
|
||||||
if( openPrefabStageContextObject != null && !openPrefabStageContextObject.Equals( null ) )
|
if( openPrefabStageContextObject != null && !openPrefabStageContextObject.Equals( null ) )
|
||||||
{
|
{
|
||||||
@@ -629,12 +618,8 @@ namespace AssetUsageDetectorNamespace
|
|||||||
}
|
}
|
||||||
|
|
||||||
if( shouldOpenPrefabStageWithoutContext )
|
if( shouldOpenPrefabStageWithoutContext )
|
||||||
#endif
|
|
||||||
{
|
|
||||||
AssetDatabase.OpenAsset( AssetDatabase.LoadAssetAtPath<GameObject>( openPrefabStageAssetPath ) );
|
AssetDatabase.OpenAsset( AssetDatabase.LoadAssetAtPath<GameObject>( openPrefabStageAssetPath ) );
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -645,7 +630,7 @@ namespace AssetUsageDetectorNamespace
|
|||||||
searchResult[i].InitializeNodes( objectsToSearchSet );
|
searchResult[i].InitializeNodes( objectsToSearchSet );
|
||||||
|
|
||||||
// Remove empty search result groups
|
// Remove empty search result groups
|
||||||
if( !searchResult[i].PendingSearch && searchResult[i].NumberOfReferences == 0 )
|
if( !searchResult[i].PendingSearch && !searchResult[i].AnyReferencesFound )
|
||||||
searchResult.RemoveAt( i-- );
|
searchResult.RemoveAt( i-- );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -671,8 +656,8 @@ namespace AssetUsageDetectorNamespace
|
|||||||
usedObjectPathsSet.Add( assetPath );
|
usedObjectPathsSet.Add( assetPath );
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for( Transform parent = ( (GameObject) obj ).transform.parent; parent != null; parent = parent.parent )
|
for (Transform parent = ((GameObject)obj).transform.parent; parent != null; parent = parent.parent)
|
||||||
usedObjectPathsSet.Add( parent.gameObject.GetHashCode().ToString() );
|
usedObjectPathsSet.Add(parent.gameObject.GetEntityId().ToString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -694,6 +679,19 @@ namespace AssetUsageDetectorNamespace
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
string assetPath = AssetDatabase.GetAssetPath( obj );
|
string assetPath = AssetDatabase.GetAssetPath( obj );
|
||||||
|
|
||||||
|
// Omit unused sub-assets whose parent assets are used (configurable via Settings)
|
||||||
|
if( AssetUsageDetectorSettings.MarkUsedAssetsSubAssetsAsUsed && AssetDatabase.IsSubAsset( obj ) && usedObjectsSet.Contains( AssetDatabase.LoadMainAssetAtPath( assetPath ) ) )
|
||||||
|
continue;
|
||||||
|
|
||||||
|
// Omit meshes of an imported model asset
|
||||||
|
if( obj is Mesh && !string.IsNullOrEmpty( assetPath ) && AssetDatabase.GetMainAssetTypeAtPath( assetPath ) == typeof( GameObject ) && objectsToSearchSet.Contains( AssetDatabase.LoadMainAssetAtPath( assetPath ) ) )
|
||||||
|
continue;
|
||||||
|
|
||||||
|
// Omit MonoScripts whose types can't be determined
|
||||||
|
if( obj is MonoScript && ( (MonoScript) obj ).GetClass() == null )
|
||||||
|
continue;
|
||||||
|
|
||||||
GameObject searchedTopmostGameObject = null;
|
GameObject searchedTopmostGameObject = null;
|
||||||
if( obj is GameObject )
|
if( obj is GameObject )
|
||||||
{
|
{
|
||||||
@@ -721,14 +719,6 @@ namespace AssetUsageDetectorNamespace
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Omit meshes of an imported model asset
|
|
||||||
if( obj is Mesh && !string.IsNullOrEmpty( assetPath ) && AssetDatabase.GetMainAssetTypeAtPath( assetPath ) == typeof( GameObject ) && objectsToSearchSet.Contains( AssetDatabase.LoadMainAssetAtPath( assetPath ) ) )
|
|
||||||
continue;
|
|
||||||
|
|
||||||
// Omit MonoScripts whose types can't be determined
|
|
||||||
if( obj is MonoScript && ( (MonoScript) obj ).GetClass() == null )
|
|
||||||
continue;
|
|
||||||
|
|
||||||
// Use new ReferenceNodes in UnusedObjects search result group because we don't want these nodes to be linked to the actual ReferenceNodes in any way
|
// Use new ReferenceNodes in UnusedObjects search result group because we don't want these nodes to be linked to the actual ReferenceNodes in any way
|
||||||
// (i.e. we don't use actual ReferenceNodes of these objects (GetReferenceNode) because these may have links to other nodes in unknown circumstances)
|
// (i.e. we don't use actual ReferenceNodes of these objects (GetReferenceNode) because these may have links to other nodes in unknown circumstances)
|
||||||
ReferenceNode node = PopReferenceNode( obj );
|
ReferenceNode node = PopReferenceNode( obj );
|
||||||
@@ -738,14 +728,14 @@ namespace AssetUsageDetectorNamespace
|
|||||||
{
|
{
|
||||||
if( !searchedTopmostGameObject )
|
if( !searchedTopmostGameObject )
|
||||||
{
|
{
|
||||||
if( obj is GameObject )
|
if (obj is GameObject)
|
||||||
unusedMainObjectNodes[obj.GetHashCode().ToString()] = node;
|
unusedMainObjectNodes[obj.GetEntityId().ToString()] = node;
|
||||||
else
|
else
|
||||||
currentSearchResultGroup.AddReference( node );
|
currentSearchResultGroup.AddReference(node);
|
||||||
}
|
}
|
||||||
else // List child GameObject scene objects under their parent GameObject
|
else // List child GameObject scene objects under their parent GameObject
|
||||||
{
|
{
|
||||||
string dictionaryKey = searchedTopmostGameObject.GetHashCode().ToString();
|
string dictionaryKey = searchedTopmostGameObject.GetEntityId().ToString();
|
||||||
List<ReferenceNode> unusedSubObjectNodesAtPath;
|
List<ReferenceNode> unusedSubObjectNodesAtPath;
|
||||||
if( !unusedSubObjectNodes.TryGetValue( dictionaryKey, out unusedSubObjectNodesAtPath ) )
|
if( !unusedSubObjectNodes.TryGetValue( dictionaryKey, out unusedSubObjectNodesAtPath ) )
|
||||||
unusedSubObjectNodes[dictionaryKey] = unusedSubObjectNodesAtPath = new List<ReferenceNode>( 2 );
|
unusedSubObjectNodes[dictionaryKey] = unusedSubObjectNodesAtPath = new List<ReferenceNode>( 2 );
|
||||||
@@ -814,7 +804,6 @@ namespace AssetUsageDetectorNamespace
|
|||||||
|
|
||||||
objectsToSearchSet.Add( obj );
|
objectsToSearchSet.Add( obj );
|
||||||
|
|
||||||
#if UNITY_2018_3_OR_NEWER
|
|
||||||
// When searching for references of a prefab stage object, try adding its corresponding prefab asset to the searched assets, as well
|
// When searching for references of a prefab stage object, try adding its corresponding prefab asset to the searched assets, as well
|
||||||
if( openPrefabStage != null && openPrefabStagePrefabAsset != null && obj is GameObject && openPrefabStage.IsPartOfPrefabContents( (GameObject) obj ) )
|
if( openPrefabStage != null && openPrefabStagePrefabAsset != null && obj is GameObject && openPrefabStage.IsPartOfPrefabContents( (GameObject) obj ) )
|
||||||
{
|
{
|
||||||
@@ -822,7 +811,6 @@ namespace AssetUsageDetectorNamespace
|
|||||||
if( prefabStageObjectSource != null )
|
if( prefabStageObjectSource != null )
|
||||||
AddSearchedObjectToFilteredSets( prefabStageObjectSource, expandGameObjects );
|
AddSearchedObjectToFilteredSets( prefabStageObjectSource, expandGameObjects );
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
bool isAsset = obj.IsAsset();
|
bool isAsset = obj.IsAsset();
|
||||||
if( isAsset )
|
if( isAsset )
|
||||||
@@ -895,7 +883,7 @@ namespace AssetUsageDetectorNamespace
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Search a scene for references
|
// 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 );
|
Scene scene = EditorSceneManager.GetSceneByPath( scenePath );
|
||||||
if( isInPlayMode && !scene.isLoaded )
|
if( isInPlayMode && !scene.isLoaded )
|
||||||
@@ -911,7 +899,7 @@ namespace AssetUsageDetectorNamespace
|
|||||||
|
|
||||||
if( !scene.isLoaded )
|
if( !scene.isLoaded )
|
||||||
{
|
{
|
||||||
if( lazySearch )
|
if( searchParameters.lazySceneSearch )
|
||||||
{
|
{
|
||||||
searchResult.Add( new SearchResultGroup( scenePath, SearchResultGroup.GroupType.Scene, true, true ) );
|
searchResult.Add( new SearchResultGroup( scenePath, SearchResultGroup.GroupType.Scene, true, true ) );
|
||||||
return;
|
return;
|
||||||
@@ -927,6 +915,16 @@ namespace AssetUsageDetectorNamespace
|
|||||||
for( int i = 0; i < rootGameObjects.Length; i++ )
|
for( int i = 0; i < rootGameObjects.Length; i++ )
|
||||||
SearchGameObjectRecursively( rootGameObjects[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 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 )
|
if( currentSearchResultGroup.NumberOfReferences == 0 )
|
||||||
{
|
{
|
||||||
@@ -949,11 +947,9 @@ namespace AssetUsageDetectorNamespace
|
|||||||
EditorSceneManager.CloseScene( scene, true );
|
EditorSceneManager.CloseScene( scene, true );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
if( currentSearchResultGroup.AnyReferencesFound )
|
||||||
// Some references are found in this scene, save the results
|
|
||||||
searchResult.Add( currentSearchResultGroup );
|
searchResult.Add( currentSearchResultGroup );
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Search a GameObject and its children for references recursively
|
// Search a GameObject and its children for references recursively
|
||||||
@@ -985,9 +981,13 @@ namespace AssetUsageDetectorNamespace
|
|||||||
if( obj == null || obj.Equals( null ) )
|
if( obj == null || obj.Equals( null ) )
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
// Avoid recursion (which leads to stackoverflow exception) using a stack
|
// Avoid recursion (which leads to stackoverflow exception) using a stack (initially, I was using callStack.ContainsFast
|
||||||
if( callStack.ContainsFast( obj ) )
|
// here but it returned false for objects that do exist in the call stack if VFX Graph window was open)
|
||||||
return null;
|
for( int i = callStack.Count - 1; i >= 0; i-- )
|
||||||
|
{
|
||||||
|
if( callStack[i].Equals( obj ) )
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
bool searchingSourceAsset = searchingSourceAssets && ReferenceEquals( currentSearchedObject, obj );
|
bool searchingSourceAsset = searchingSourceAssets && ReferenceEquals( currentSearchedObject, obj );
|
||||||
|
|
||||||
@@ -1000,6 +1000,10 @@ namespace AssetUsageDetectorNamespace
|
|||||||
return cachedResult;
|
return cachedResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Comply with the recursive search limit
|
||||||
|
if (callStack.Count >= searchParameters.searchDepthLimit)
|
||||||
|
return null;
|
||||||
|
|
||||||
searchedObjectsCount++;
|
searchedObjectsCount++;
|
||||||
|
|
||||||
ReferenceNode result;
|
ReferenceNode result;
|
||||||
@@ -1012,14 +1016,14 @@ namespace AssetUsageDetectorNamespace
|
|||||||
{
|
{
|
||||||
if( assetsToSearchSet.Count == 0 )
|
if( assetsToSearchSet.Count == 0 )
|
||||||
{
|
{
|
||||||
searchedUnityObjects.Add( unityObject.GetHashCode(), null );
|
searchedUnityObjects.Add(unityObject.GetEntityId(), null);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
assetPath = AssetDatabase.GetAssetPath( unityObject );
|
assetPath = AssetDatabase.GetAssetPath( unityObject );
|
||||||
if( excludedAssetsPathsSet.Contains( assetPath ) || !AssetHasAnyReference( assetPath ) )
|
if( excludedAssetsPathsSet.Contains( assetPath ) || !AssetHasAnyReference( assetPath ) )
|
||||||
{
|
{
|
||||||
searchedUnityObjects.Add( unityObject.GetHashCode(), null );
|
searchedUnityObjects.Add(unityObject.GetEntityId(), null);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1027,7 +1031,7 @@ namespace AssetUsageDetectorNamespace
|
|||||||
callStack.Add( unityObject );
|
callStack.Add( unityObject );
|
||||||
|
|
||||||
// Search the Object in detail
|
// Search the Object in detail
|
||||||
Func<Object, ReferenceNode> searchFunction;
|
Func<object, ReferenceNode> searchFunction;
|
||||||
if( assetPath != null && extensionToSearchFunction.TryGetValue( Utilities.GetFileExtension( assetPath ), out searchFunction ) && AssetDatabase.IsMainAsset( unityObject ) )
|
if( assetPath != null && extensionToSearchFunction.TryGetValue( Utilities.GetFileExtension( assetPath ), out searchFunction ) && AssetDatabase.IsMainAsset( unityObject ) )
|
||||||
result = searchFunction( unityObject );
|
result = searchFunction( unityObject );
|
||||||
else if( typeToSearchFunction.TryGetValue( unityObject.GetType(), out searchFunction ) )
|
else if( typeToSearchFunction.TryGetValue( unityObject.GetType(), out searchFunction ) )
|
||||||
@@ -1061,17 +1065,11 @@ namespace AssetUsageDetectorNamespace
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Comply with the recursive search limit
|
|
||||||
if( currentDepth >= searchParameters.searchDepthLimit )
|
|
||||||
return null;
|
|
||||||
|
|
||||||
callStack.Add( obj );
|
callStack.Add( obj );
|
||||||
currentDepth++;
|
|
||||||
|
|
||||||
result = PopReferenceNode( obj );
|
result = PopReferenceNode( obj );
|
||||||
SearchVariablesWithReflection( result );
|
SearchVariablesWithReflection( result );
|
||||||
|
|
||||||
currentDepth--;
|
|
||||||
callStack.RemoveAt( callStack.Count - 1 );
|
callStack.RemoveAt( callStack.Count - 1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1081,24 +1079,23 @@ namespace AssetUsageDetectorNamespace
|
|||||||
result = null;
|
result = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cache the search result if we are skimming through a class (not a struct; i.e. objHash != null)
|
// Cache the search result if we are skimming through a class (not a struct) and if the object is a UnityEngine.Object (if not,
|
||||||
// and if the object is a UnityEngine.Object (if not, cache the result only if we have actually found something
|
// cache the result only if we have actually found something or we are at the root of the search; i.e. callStack.Count == 0)
|
||||||
// or we are at the root of the search; i.e. currentDepth == 0)
|
if (obj is not ValueType && (result != null || unityObject != null || callStack.Count == 0))
|
||||||
if( !( obj is ValueType ) && ( result != null || unityObject != null || currentDepth == 0 ) )
|
{
|
||||||
{
|
if (!searchingSourceAsset)
|
||||||
if( !searchingSourceAsset )
|
{
|
||||||
{
|
if (obj is Object)
|
||||||
if( obj is Object )
|
searchedUnityObjects.Add(unityObject.GetEntityId(), result);
|
||||||
searchedUnityObjects.Add( unityObject.GetHashCode(), result );
|
else
|
||||||
else
|
searchedObjects.Add(GetNodeObjectHash(obj), result);
|
||||||
searchedObjects.Add( GetNodeObjectHash( obj ), result );
|
}
|
||||||
}
|
else if (result != null)
|
||||||
else if( result != null )
|
{
|
||||||
{
|
result.CopyReferencesTo(searchedUnityObjects[unityObject.GetEntityId()]);
|
||||||
result.CopyReferencesTo( searchedUnityObjects[unityObject.GetHashCode()] );
|
PoolReferenceNode(result);
|
||||||
PoolReferenceNode( result );
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -1224,46 +1221,46 @@ namespace AssetUsageDetectorNamespace
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If object was already searched, return its ReferenceNode
|
// If object was already searched, return its ReferenceNode
|
||||||
private bool TryGetReferenceNode( object nodeObject, out ReferenceNode referenceNode )
|
private bool TryGetReferenceNode(object nodeObject, out ReferenceNode referenceNode)
|
||||||
{
|
{
|
||||||
if( nodeObject is Object )
|
if (nodeObject is Object unityObject)
|
||||||
{
|
{
|
||||||
if( searchedUnityObjects.TryGetValue( nodeObject.GetHashCode(), out referenceNode ) )
|
if (searchedUnityObjects.TryGetValue(unityObject.GetEntityId(), out referenceNode))
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if( searchedObjects.TryGetValue( GetNodeObjectHash( nodeObject ), out referenceNode ) )
|
else if (searchedObjects.TryGetValue(GetNodeObjectHash(nodeObject), out referenceNode))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
referenceNode = null;
|
referenceNode = null;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get reference node for object
|
// Get reference node for object
|
||||||
private ReferenceNode GetReferenceNode( object nodeObject )
|
private ReferenceNode GetReferenceNode(object nodeObject)
|
||||||
{
|
{
|
||||||
ReferenceNode result;
|
ReferenceNode result;
|
||||||
if( nodeObject is Object )
|
if (nodeObject is Object unityObject)
|
||||||
{
|
{
|
||||||
int hash = nodeObject.GetHashCode();
|
EntityId hash = unityObject.GetEntityId();
|
||||||
if( !searchedUnityObjects.TryGetValue( hash, out result ) || result == null )
|
if (!searchedUnityObjects.TryGetValue(hash, out result) || result == null)
|
||||||
{
|
{
|
||||||
result = PopReferenceNode( nodeObject );
|
result = PopReferenceNode(nodeObject);
|
||||||
searchedUnityObjects[hash] = result;
|
searchedUnityObjects[hash] = result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
string hash = GetNodeObjectHash( nodeObject );
|
string hash = GetNodeObjectHash(nodeObject);
|
||||||
if( !searchedObjects.TryGetValue( hash, out result ) || result == null )
|
if (!searchedObjects.TryGetValue(hash, out result) || result == null)
|
||||||
{
|
{
|
||||||
result = PopReferenceNode( nodeObject );
|
result = PopReferenceNode(nodeObject);
|
||||||
searchedObjects[hash] = result;
|
searchedObjects[hash] = result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fetch a reference node from pool
|
// Fetch a reference node from pool
|
||||||
private ReferenceNode PopReferenceNode( object nodeObject )
|
private ReferenceNode PopReferenceNode( object nodeObject )
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -96,6 +96,13 @@ namespace AssetUsageDetectorNamespace
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Other Settings
|
#region Other Settings
|
||||||
|
private static bool? m_showRootAssetName = null;
|
||||||
|
public static bool ShowRootAssetName
|
||||||
|
{
|
||||||
|
get { if( m_showRootAssetName == null ) m_showRootAssetName = EditorPrefs.GetBool( "AUD_ShowRootAssetName", true ); return m_showRootAssetName.Value; }
|
||||||
|
set { if( m_showRootAssetName == value ) return; m_showRootAssetName = value; EditorPrefs.SetBool( "AUD_ShowRootAssetName", value ); }
|
||||||
|
}
|
||||||
|
|
||||||
private static bool? m_pingClickedObjects = null;
|
private static bool? m_pingClickedObjects = null;
|
||||||
public static bool PingClickedObjects
|
public static bool PingClickedObjects
|
||||||
{
|
{
|
||||||
@@ -117,6 +124,13 @@ namespace AssetUsageDetectorNamespace
|
|||||||
set { if( m_selectDoubleClickedObjects == value ) return; m_selectDoubleClickedObjects = value; EditorPrefs.SetBool( "AUD_SelectDoubleClickedObj", value ); }
|
set { if( m_selectDoubleClickedObjects == value ) return; m_selectDoubleClickedObjects = value; EditorPrefs.SetBool( "AUD_SelectDoubleClickedObj", value ); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static bool? m_markUsedAssetsSubAssetsAsUsed = null;
|
||||||
|
public static bool MarkUsedAssetsSubAssetsAsUsed
|
||||||
|
{
|
||||||
|
get { if( m_markUsedAssetsSubAssetsAsUsed == null ) m_markUsedAssetsSubAssetsAsUsed = EditorPrefs.GetBool( "AUD_MarkUsedAssetsSubAssetsAsUsed", true ); return m_markUsedAssetsSubAssetsAsUsed.Value; }
|
||||||
|
set { if( m_markUsedAssetsSubAssetsAsUsed == value ) return; m_markUsedAssetsSubAssetsAsUsed = value; EditorPrefs.SetBool( "AUD_MarkUsedAssetsSubAssetsAsUsed", value ); }
|
||||||
|
}
|
||||||
|
|
||||||
private static bool? m_showUnityTooltip = null;
|
private static bool? m_showUnityTooltip = null;
|
||||||
public static bool ShowUnityTooltip
|
public static bool ShowUnityTooltip
|
||||||
{
|
{
|
||||||
@@ -153,7 +167,6 @@ namespace AssetUsageDetectorNamespace
|
|||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#if UNITY_2018_3_OR_NEWER
|
|
||||||
[SettingsProvider]
|
[SettingsProvider]
|
||||||
public static SettingsProvider CreatePreferencesGUI()
|
public static SettingsProvider CreatePreferencesGUI()
|
||||||
{
|
{
|
||||||
@@ -163,34 +176,30 @@ namespace AssetUsageDetectorNamespace
|
|||||||
keywords = new System.Collections.Generic.HashSet<string>() { "Asset", "Usage", "Detector" }
|
keywords = new System.Collections.Generic.HashSet<string>() { "Asset", "Usage", "Detector" }
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
#if !UNITY_2018_3_OR_NEWER
|
|
||||||
[PreferenceItem( "Asset Usage Detector" )]
|
|
||||||
#endif
|
|
||||||
public static void PreferencesGUI()
|
public static void PreferencesGUI()
|
||||||
{
|
{
|
||||||
float labelWidth = EditorGUIUtility.labelWidth;
|
float labelWidth = EditorGUIUtility.labelWidth;
|
||||||
#if UNITY_2018_3_OR_NEWER
|
|
||||||
EditorGUIUtility.labelWidth += 60f;
|
EditorGUIUtility.labelWidth += 60f;
|
||||||
#else
|
|
||||||
EditorGUIUtility.labelWidth += 20f;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
EditorGUI.BeginChangeCheck();
|
EditorGUI.BeginChangeCheck();
|
||||||
|
|
||||||
SettingsHeaderColor = ColorField( "Settings Header Color", SettingsHeaderColor, Color.cyan );
|
ShowRootAssetName = AssetUsageDetectorWindow.WordWrappingToggleLeft( "Show Root Asset's Name For Sub-Assets (Requires Refresh)", ShowRootAssetName );
|
||||||
|
|
||||||
EditorGUILayout.Space();
|
EditorGUILayout.Space();
|
||||||
|
|
||||||
PingClickedObjects = EditorGUILayout.Toggle( "Ping Clicked Objects", PingClickedObjects );
|
PingClickedObjects = AssetUsageDetectorWindow.WordWrappingToggleLeft( "Ping Clicked Objects", PingClickedObjects );
|
||||||
SelectClickedObjects = EditorGUILayout.Toggle( "Select Clicked Objects", SelectClickedObjects );
|
SelectClickedObjects = AssetUsageDetectorWindow.WordWrappingToggleLeft( "Select Clicked Objects", SelectClickedObjects );
|
||||||
SelectDoubleClickedObjects = EditorGUILayout.Toggle( "Select Double Clicked Objects", SelectDoubleClickedObjects );
|
SelectDoubleClickedObjects = AssetUsageDetectorWindow.WordWrappingToggleLeft( "Select Double Clicked Objects", SelectDoubleClickedObjects );
|
||||||
|
|
||||||
EditorGUILayout.Space();
|
EditorGUILayout.Space();
|
||||||
|
|
||||||
ShowUnityTooltip = EditorGUILayout.Toggle( "Show Unity Tooltip", ShowUnityTooltip );
|
MarkUsedAssetsSubAssetsAsUsed = AssetUsageDetectorWindow.WordWrappingToggleLeft( "Hide unused sub-assets in \"Unused Objects\" list if their parent assets are used (Requires Refresh)", MarkUsedAssetsSubAssetsAsUsed );
|
||||||
ShowCustomTooltip = EditorGUILayout.Toggle( "Show Custom Tooltip", ShowCustomTooltip );
|
|
||||||
|
EditorGUILayout.Space();
|
||||||
|
|
||||||
|
ShowUnityTooltip = AssetUsageDetectorWindow.WordWrappingToggleLeft( "Show Unity Tooltip", ShowUnityTooltip );
|
||||||
|
ShowCustomTooltip = AssetUsageDetectorWindow.WordWrappingToggleLeft( "Show Custom Tooltip", ShowCustomTooltip );
|
||||||
EditorGUI.indentLevel++;
|
EditorGUI.indentLevel++;
|
||||||
CustomTooltipDelay = FloatField( "Delay", CustomTooltipDelay, 0.7f );
|
CustomTooltipDelay = FloatField( "Delay", CustomTooltipDelay, 0.7f );
|
||||||
EditorGUI.indentLevel--;
|
EditorGUI.indentLevel--;
|
||||||
@@ -202,6 +211,7 @@ namespace AssetUsageDetectorNamespace
|
|||||||
|
|
||||||
EditorGUILayout.Space();
|
EditorGUILayout.Space();
|
||||||
|
|
||||||
|
SettingsHeaderColor = ColorField( "Settings Header Color", SettingsHeaderColor, Color.cyan );
|
||||||
SearchResultGroupHeaderColor = ColorField( "Group Header Color", SearchResultGroupHeaderColor, 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 ) );
|
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 ) );
|
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 ) );
|
||||||
@@ -213,7 +223,7 @@ namespace AssetUsageDetectorNamespace
|
|||||||
SelectedRowOccurrencesColor = ColorField( "Selected Row All Occurrences Tint", SelectedRowOccurrencesColor, EditorGUIUtility.isProSkin ? new Color( 0f, 0.3f, 0.75f, 1f ) : new Color( 0.25f, 0.75f, 1f, 1f ) );
|
SelectedRowOccurrencesColor = ColorField( "Selected Row All Occurrences Tint", SelectedRowOccurrencesColor, EditorGUIUtility.isProSkin ? new Color( 0f, 0.3f, 0.75f, 1f ) : new Color( 0.25f, 0.75f, 1f, 1f ) );
|
||||||
SearchMatchingTextColor = ColorField( "Matching Search Text Color", SearchMatchingTextColor, Color.red );
|
SearchMatchingTextColor = ColorField( "Matching Search Text Color", SearchMatchingTextColor, Color.red );
|
||||||
|
|
||||||
ShowTreeLines = EditorGUILayout.Toggle( "Show Tree Lines", ShowTreeLines );
|
ShowTreeLines = AssetUsageDetectorWindow.WordWrappingToggleLeft( "Show Tree Lines", ShowTreeLines );
|
||||||
EditorGUI.indentLevel++;
|
EditorGUI.indentLevel++;
|
||||||
TreeLinesColor = ColorField( "Normal Color", TreeLinesColor, EditorGUIUtility.isProSkin ? new Color( 0.65f, 0.65f, 0.65f, 1f ) : new Color( 0.375f, 0.375f, 0.375f, 1f ) );
|
TreeLinesColor = ColorField( "Normal Color", TreeLinesColor, EditorGUIUtility.isProSkin ? new Color( 0.65f, 0.65f, 0.65f, 1f ) : new Color( 0.375f, 0.375f, 0.375f, 1f ) );
|
||||||
HighlightedTreeLinesColor = ColorField( "Highlighted Color", HighlightedTreeLinesColor, Color.cyan );
|
HighlightedTreeLinesColor = ColorField( "Highlighted Color", HighlightedTreeLinesColor, Color.cyan );
|
||||||
|
|||||||
@@ -1,17 +1,9 @@
|
|||||||
// Asset Usage Detector - by Suleyman Yasir KULA (yasirkula@gmail.com)
|
|
||||||
|
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEditor;
|
using UnityEditor;
|
||||||
|
using UnityEditor.SceneManagement;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using Object = UnityEngine.Object;
|
using Object = UnityEngine.Object;
|
||||||
#if UNITY_2021_2_OR_NEWER
|
|
||||||
using PrefabStage = UnityEditor.SceneManagement.PrefabStage;
|
|
||||||
using PrefabStageUtility = UnityEditor.SceneManagement.PrefabStageUtility;
|
|
||||||
#elif UNITY_2018_3_OR_NEWER
|
|
||||||
using PrefabStage = UnityEditor.Experimental.SceneManagement.PrefabStage;
|
|
||||||
using PrefabStageUtility = UnityEditor.Experimental.SceneManagement.PrefabStageUtility;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace AssetUsageDetectorNamespace
|
namespace AssetUsageDetectorNamespace
|
||||||
{
|
{
|
||||||
@@ -22,25 +14,35 @@ namespace AssetUsageDetectorNamespace
|
|||||||
private enum WindowFilter { AlwaysReturnActive, ReturnActiveIfNotLocked, AlwaysReturnNew };
|
private enum WindowFilter { AlwaysReturnActive, ReturnActiveIfNotLocked, AlwaysReturnNew };
|
||||||
|
|
||||||
private const string PREFS_SEARCH_SCENES = "AUD_SceneSearch";
|
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_ASSETS = "AUD_AssetsSearch";
|
||||||
private const string PREFS_SEARCH_PROJECT_SETTINGS = "AUD_ProjectSettingsSearch";
|
private const string PREFS_SEARCH_PROJECT_SETTINGS = "AUD_ProjectSettingsSearch";
|
||||||
private const string PREFS_DONT_SEARCH_SOURCE_ASSETS = "AUD_AssetsExcludeSrc";
|
private const string PREFS_DONT_SEARCH_SOURCE_ASSETS = "AUD_AssetsExcludeSrc";
|
||||||
private const string PREFS_SEARCH_DEPTH_LIMIT = "AUD_Depth";
|
|
||||||
private const string PREFS_SEARCH_FIELDS = "AUD_Fields";
|
|
||||||
private const string PREFS_SEARCH_PROPERTIES = "AUD_Properties";
|
|
||||||
private const string PREFS_SEARCH_NON_SERIALIZABLES = "AUD_NonSerializables";
|
|
||||||
private const string PREFS_SEARCH_UNUSED_MATERIAL_PROPERTIES = "AUD_SearchUnusedMaterialProps";
|
private const string PREFS_SEARCH_UNUSED_MATERIAL_PROPERTIES = "AUD_SearchUnusedMaterialProps";
|
||||||
private const string PREFS_LAZY_SCENE_SEARCH = "AUD_LazySceneSearch";
|
private const string PREFS_LAZY_SCENE_SEARCH = "AUD_LazySceneSearch";
|
||||||
|
#if ASSET_USAGE_ADDRESSABLES
|
||||||
private const string PREFS_ADDRESSABLES_SUPPORT = "AUD_AddressablesSupport";
|
private const string PREFS_ADDRESSABLES_SUPPORT = "AUD_AddressablesSupport";
|
||||||
|
#endif
|
||||||
private const string PREFS_CALCULATE_UNUSED_OBJECTS = "AUD_FindUnusedObjs";
|
private const string PREFS_CALCULATE_UNUSED_OBJECTS = "AUD_FindUnusedObjs";
|
||||||
private const string PREFS_HIDE_DUPLICATE_ROWS = "AUD_HideDuplicates";
|
private const string PREFS_HIDE_DUPLICATE_ROWS = "AUD_HideDuplicates";
|
||||||
private const string PREFS_HIDE_REDUNDANT_PREFAB_VARIANT_LINKS = "AUD_HideRedundantPVariantLinks";
|
private const string PREFS_HIDE_REDUNDANT_PREFAB_REFERENCES_IN_ASSETS = "AUD_HideRedundantPRefsInAssets";
|
||||||
|
private const string PREFS_HIDE_REDUNDANT_PREFAB_REFERENCES_IN_SCENES = "AUD_HideRedundantPRefsInScenes";
|
||||||
private const string PREFS_SHOW_PROGRESS = "AUD_Progress";
|
private const string PREFS_SHOW_PROGRESS = "AUD_Progress";
|
||||||
|
|
||||||
private static readonly GUIContent windowTitle = new GUIContent( "Asset Usage Detector" );
|
private static readonly GUIContent windowTitle = new GUIContent( "Asset Usage Detector" );
|
||||||
private static readonly Vector2 windowMinSize = new Vector2( 325f, 220f );
|
private static readonly Vector2 windowMinSize = new Vector2( 325f, 220f );
|
||||||
|
|
||||||
private readonly GUILayoutOption GL_WIDTH_12 = GUILayout.Width( 12f );
|
private static readonly GUILayoutOption GL_WIDTH_12 = GUILayout.Width( 12f );
|
||||||
|
|
||||||
|
private static readonly GUIContent sharedGUIContent = new GUIContent();
|
||||||
|
|
||||||
|
private readonly GUIContent hideRedundantPrefabReferencesInAssetsLabel = new GUIContent( "Hide redundant prefab references in Assets", "Hides redundant/non-overridden references in prefab variants and nested prefabs. " +
|
||||||
|
"This will help focus on only the references that actually matter. For example:\n\n" +
|
||||||
|
"- Material CloudMat is assigned to prefab Cloud and its variant CloudBig. Since changing Cloud's material will also affect CloudBig, search results won't show CloudBig's reference" );
|
||||||
|
private readonly GUIContent hideRedundantPrefabReferencesInScenesLabel = new GUIContent( "Hide redundant prefab references in Scenes", "Hides redundant/non-overridden references in prefab instances. " +
|
||||||
|
"This will help focus on only the references that actually matter. For example:\n\n" +
|
||||||
|
"- Prefab Healthbar is nested inside prefab Player. An instance of Player exists in the current scene and its Healthbar isn't modified. Since modifying Healthbar in Player prefab will also affect " +
|
||||||
|
"the instance in the scene, search results won't show the instance in the scene while searching for Healthbar's references" );
|
||||||
|
|
||||||
private GUIStyle lockButtonStyle;
|
private GUIStyle lockButtonStyle;
|
||||||
|
|
||||||
@@ -50,7 +52,6 @@ namespace AssetUsageDetectorNamespace
|
|||||||
// This isn't readonly so that it can be serialized
|
// This isn't readonly so that it can be serialized
|
||||||
private List<ObjectToSearch> objectsToSearch = new List<ObjectToSearch>() { new ObjectToSearch( null ) };
|
private List<ObjectToSearch> objectsToSearch = new List<ObjectToSearch>() { new ObjectToSearch( null ) };
|
||||||
|
|
||||||
#pragma warning disable 0649
|
|
||||||
[SerializeField] // Since titleContent persists between Editor sessions, so should the IsLocked property because otherwise, "[L]" in title becomes confusing when the EditorWindow isn't actually locked
|
[SerializeField] // Since titleContent persists between Editor sessions, so should the IsLocked property because otherwise, "[L]" in title becomes confusing when the EditorWindow isn't actually locked
|
||||||
private bool m_isLocked;
|
private bool m_isLocked;
|
||||||
private bool IsLocked
|
private bool IsLocked
|
||||||
@@ -65,7 +66,6 @@ namespace AssetUsageDetectorNamespace
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#pragma warning restore 0649
|
|
||||||
|
|
||||||
private Phase currentPhase = Phase.Setup;
|
private Phase currentPhase = Phase.Setup;
|
||||||
|
|
||||||
@@ -73,6 +73,7 @@ namespace AssetUsageDetectorNamespace
|
|||||||
private bool searchInScenesInBuild = true; // Scenes in build
|
private bool searchInScenesInBuild = true; // Scenes in build
|
||||||
private bool searchInScenesInBuildTickedOnly = true; // Scenes in build (ticked only or not)
|
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 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 searchInAssetsFolder = true; // Assets in Project window
|
||||||
private bool dontSearchInSourceAssets = true; // objectsToSearch won't be searched for internal references
|
private bool dontSearchInSourceAssets = true; // objectsToSearch won't be searched for internal references
|
||||||
private bool searchInProjectSettings = true; // Player Settings, Graphics Settings etc.
|
private bool searchInProjectSettings = true; // Player Settings, Graphics Settings etc.
|
||||||
@@ -81,22 +82,18 @@ namespace AssetUsageDetectorNamespace
|
|||||||
private List<Object> excludedAssets = new List<Object>() { null }; // These assets won't be searched for references
|
private List<Object> excludedAssets = new List<Object>() { null }; // These assets won't be searched for references
|
||||||
private List<Object> excludedScenes = new List<Object>() { null }; // These scenes won't be searched for references
|
private List<Object> excludedScenes = new List<Object>() { null }; // These scenes won't be searched for references
|
||||||
|
|
||||||
private int searchDepthLimit = 4; // Depth limit for recursively searching variables of objects
|
|
||||||
|
|
||||||
private bool lazySceneSearch = true;
|
private bool lazySceneSearch = true;
|
||||||
#if ASSET_USAGE_ADDRESSABLES
|
#if ASSET_USAGE_ADDRESSABLES
|
||||||
private bool addressablesSupport = false;
|
private bool addressablesSupport = false;
|
||||||
#endif
|
#endif
|
||||||
private bool searchNonSerializableVariables = true;
|
|
||||||
private bool searchUnusedMaterialProperties = true;
|
private bool searchUnusedMaterialProperties = true;
|
||||||
private bool calculateUnusedObjects = false;
|
private bool calculateUnusedObjects = false;
|
||||||
private bool hideDuplicateRows = true;
|
private bool hideDuplicateRows = true;
|
||||||
private bool hideReduntantPrefabVariantLinks = true;
|
private bool hideRedundantPrefabReferencesInAssets = false;
|
||||||
|
private bool hideRedundantPrefabReferencesInScenes = false;
|
||||||
private bool noAssetDatabaseChanges = false;
|
private bool noAssetDatabaseChanges = false;
|
||||||
private bool showDetailedProgressBar = true;
|
private bool showDetailedProgressBar = true;
|
||||||
|
|
||||||
private BindingFlags fieldModifiers, propertyModifiers;
|
|
||||||
|
|
||||||
private SearchRefactoring searchRefactoring = null; // Its value can be assigned via ShowAndSearch
|
private SearchRefactoring searchRefactoring = null; // Its value can be assigned via ShowAndSearch
|
||||||
|
|
||||||
private readonly ObjectToSearchListDrawer objectsToSearchDrawer = new ObjectToSearchListDrawer();
|
private readonly ObjectToSearchListDrawer objectsToSearchDrawer = new ObjectToSearchListDrawer();
|
||||||
@@ -115,37 +112,7 @@ namespace AssetUsageDetectorNamespace
|
|||||||
{
|
{
|
||||||
contextMenu.AddItem( new GUIContent( "Lock" ), IsLocked, () => IsLocked = !IsLocked );
|
contextMenu.AddItem( new GUIContent( "Lock" ), IsLocked, () => IsLocked = !IsLocked );
|
||||||
contextMenu.AddSeparator( "" );
|
contextMenu.AddSeparator( "" );
|
||||||
|
|
||||||
#if UNITY_2018_3_OR_NEWER
|
|
||||||
contextMenu.AddItem( new GUIContent( "Settings" ), false, () => SettingsService.OpenProjectSettings( "Project/yasirkula/Asset Usage Detector" ) );
|
contextMenu.AddItem( new GUIContent( "Settings" ), false, () => SettingsService.OpenProjectSettings( "Project/yasirkula/Asset Usage Detector" ) );
|
||||||
#else
|
|
||||||
contextMenu.AddItem( new GUIContent( "Settings" ), false, () =>
|
|
||||||
{
|
|
||||||
System.Type preferencesWindowType = typeof( EditorWindow ).Assembly.GetType( "UnityEditor.PreferencesWindow" );
|
|
||||||
preferencesWindowType.GetMethod( "ShowPreferencesWindow", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static ).Invoke( null, null );
|
|
||||||
|
|
||||||
EditorWindow preferencesWindow = GetWindow( preferencesWindowType );
|
|
||||||
if( (bool) preferencesWindowType.GetField( "m_RefreshCustomPreferences", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance ).GetValue( preferencesWindow ) )
|
|
||||||
{
|
|
||||||
preferencesWindowType.GetMethod( "AddCustomSections", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance ).Invoke( preferencesWindow, null );
|
|
||||||
preferencesWindowType.GetField( "m_RefreshCustomPreferences", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance ).SetValue( preferencesWindow, false );
|
|
||||||
}
|
|
||||||
|
|
||||||
int targetSectionIndex = -1;
|
|
||||||
System.Collections.IList sections = (System.Collections.IList) preferencesWindowType.GetField( "m_Sections", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance ).GetValue( preferencesWindow );
|
|
||||||
for( int i = 0; i < sections.Count; i++ )
|
|
||||||
{
|
|
||||||
if( ( (GUIContent) sections[i].GetType().GetField( "content", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance ).GetValue( sections[i] ) ).text == "Asset Usage Detector" )
|
|
||||||
{
|
|
||||||
targetSectionIndex = i;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if( targetSectionIndex >= 0 )
|
|
||||||
preferencesWindowType.GetProperty( "selectedSectionIndex", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance ).SetValue( preferencesWindow, targetSectionIndex, null );
|
|
||||||
} );
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if( currentPhase == Phase.Setup )
|
if( currentPhase == Phase.Setup )
|
||||||
{
|
{
|
||||||
@@ -313,13 +280,10 @@ namespace AssetUsageDetectorNamespace
|
|||||||
if( searchParameters != null )
|
if( searchParameters != null )
|
||||||
{
|
{
|
||||||
ParseSceneSearchMode( searchParameters.searchInScenes );
|
ParseSceneSearchMode( searchParameters.searchInScenes );
|
||||||
|
searchInSceneLightingSettings = searchParameters.searchInSceneLightingSettings;
|
||||||
searchInAssetsFolder = searchParameters.searchInAssetsFolder;
|
searchInAssetsFolder = searchParameters.searchInAssetsFolder;
|
||||||
dontSearchInSourceAssets = searchParameters.dontSearchInSourceAssets;
|
dontSearchInSourceAssets = searchParameters.dontSearchInSourceAssets;
|
||||||
searchInProjectSettings = searchParameters.searchInProjectSettings;
|
searchInProjectSettings = searchParameters.searchInProjectSettings;
|
||||||
searchDepthLimit = searchParameters.searchDepthLimit;
|
|
||||||
fieldModifiers = searchParameters.fieldModifiers;
|
|
||||||
propertyModifiers = searchParameters.propertyModifiers;
|
|
||||||
searchNonSerializableVariables = searchParameters.searchNonSerializableVariables;
|
|
||||||
searchUnusedMaterialProperties = searchParameters.searchUnusedMaterialProperties;
|
searchUnusedMaterialProperties = searchParameters.searchUnusedMaterialProperties;
|
||||||
searchRefactoring = searchParameters.searchRefactoring;
|
searchRefactoring = searchParameters.searchRefactoring;
|
||||||
lazySceneSearch = searchParameters.lazySceneSearch;
|
lazySceneSearch = searchParameters.lazySceneSearch;
|
||||||
@@ -328,7 +292,8 @@ namespace AssetUsageDetectorNamespace
|
|||||||
#endif
|
#endif
|
||||||
calculateUnusedObjects = searchParameters.calculateUnusedObjects;
|
calculateUnusedObjects = searchParameters.calculateUnusedObjects;
|
||||||
hideDuplicateRows = searchParameters.hideDuplicateRows;
|
hideDuplicateRows = searchParameters.hideDuplicateRows;
|
||||||
hideReduntantPrefabVariantLinks = searchParameters.hideReduntantPrefabVariantLinks;
|
hideRedundantPrefabReferencesInAssets = searchParameters.hideRedundantPrefabReferencesInAssets;
|
||||||
|
hideRedundantPrefabReferencesInScenes = searchParameters.hideRedundantPrefabReferencesInScenes;
|
||||||
noAssetDatabaseChanges = searchParameters.noAssetDatabaseChanges;
|
noAssetDatabaseChanges = searchParameters.noAssetDatabaseChanges;
|
||||||
showDetailedProgressBar = searchParameters.showDetailedProgressBar;
|
showDetailedProgressBar = searchParameters.showDetailedProgressBar;
|
||||||
|
|
||||||
@@ -368,17 +333,12 @@ namespace AssetUsageDetectorNamespace
|
|||||||
if( currentPhase == Phase.Complete && AssetUsageDetectorSettings.ShowCustomTooltip )
|
if( currentPhase == Phase.Complete && AssetUsageDetectorSettings.ShowCustomTooltip )
|
||||||
wantsMouseMove = wantsMouseEnterLeaveWindow = true; // These values aren't preserved during domain reload on Unity 2020.3.0f1
|
wantsMouseMove = wantsMouseEnterLeaveWindow = true; // These values aren't preserved during domain reload on Unity 2020.3.0f1
|
||||||
|
|
||||||
#if UNITY_2018_3_OR_NEWER
|
|
||||||
PrefabStage.prefabStageClosing -= ReplacePrefabStageObjectsWithAssets;
|
|
||||||
PrefabStage.prefabStageClosing += ReplacePrefabStageObjectsWithAssets;
|
PrefabStage.prefabStageClosing += ReplacePrefabStageObjectsWithAssets;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnDisable()
|
private void OnDisable()
|
||||||
{
|
{
|
||||||
#if UNITY_2018_3_OR_NEWER
|
|
||||||
PrefabStage.prefabStageClosing -= ReplacePrefabStageObjectsWithAssets;
|
PrefabStage.prefabStageClosing -= ReplacePrefabStageObjectsWithAssets;
|
||||||
#endif
|
|
||||||
SearchResultTooltip.Hide();
|
SearchResultTooltip.Hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -396,13 +356,10 @@ namespace AssetUsageDetectorNamespace
|
|||||||
private void SavePrefs()
|
private void SavePrefs()
|
||||||
{
|
{
|
||||||
EditorPrefs.SetInt( PREFS_SEARCH_SCENES, (int) GetSceneSearchMode( false ) );
|
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_SEARCH_ASSETS, searchInAssetsFolder );
|
||||||
EditorPrefs.SetBool( PREFS_DONT_SEARCH_SOURCE_ASSETS, dontSearchInSourceAssets );
|
EditorPrefs.SetBool( PREFS_DONT_SEARCH_SOURCE_ASSETS, dontSearchInSourceAssets );
|
||||||
EditorPrefs.SetBool( PREFS_SEARCH_PROJECT_SETTINGS, searchInProjectSettings );
|
EditorPrefs.SetBool( PREFS_SEARCH_PROJECT_SETTINGS, searchInProjectSettings );
|
||||||
EditorPrefs.SetInt( PREFS_SEARCH_DEPTH_LIMIT, searchDepthLimit );
|
|
||||||
EditorPrefs.SetInt( PREFS_SEARCH_FIELDS, (int) fieldModifiers );
|
|
||||||
EditorPrefs.SetInt( PREFS_SEARCH_PROPERTIES, (int) propertyModifiers );
|
|
||||||
EditorPrefs.SetBool( PREFS_SEARCH_NON_SERIALIZABLES, searchNonSerializableVariables );
|
|
||||||
EditorPrefs.SetBool( PREFS_SEARCH_UNUSED_MATERIAL_PROPERTIES, searchUnusedMaterialProperties );
|
EditorPrefs.SetBool( PREFS_SEARCH_UNUSED_MATERIAL_PROPERTIES, searchUnusedMaterialProperties );
|
||||||
EditorPrefs.SetBool( PREFS_LAZY_SCENE_SEARCH, lazySceneSearch );
|
EditorPrefs.SetBool( PREFS_LAZY_SCENE_SEARCH, lazySceneSearch );
|
||||||
#if ASSET_USAGE_ADDRESSABLES
|
#if ASSET_USAGE_ADDRESSABLES
|
||||||
@@ -410,21 +367,18 @@ namespace AssetUsageDetectorNamespace
|
|||||||
#endif
|
#endif
|
||||||
EditorPrefs.SetBool( PREFS_CALCULATE_UNUSED_OBJECTS, calculateUnusedObjects );
|
EditorPrefs.SetBool( PREFS_CALCULATE_UNUSED_OBJECTS, calculateUnusedObjects );
|
||||||
EditorPrefs.SetBool( PREFS_HIDE_DUPLICATE_ROWS, hideDuplicateRows );
|
EditorPrefs.SetBool( PREFS_HIDE_DUPLICATE_ROWS, hideDuplicateRows );
|
||||||
EditorPrefs.SetBool( PREFS_HIDE_REDUNDANT_PREFAB_VARIANT_LINKS, hideReduntantPrefabVariantLinks );
|
EditorPrefs.SetBool( PREFS_HIDE_REDUNDANT_PREFAB_REFERENCES_IN_ASSETS, hideRedundantPrefabReferencesInAssets );
|
||||||
|
EditorPrefs.SetBool( PREFS_HIDE_REDUNDANT_PREFAB_REFERENCES_IN_SCENES, hideRedundantPrefabReferencesInScenes );
|
||||||
EditorPrefs.SetBool( PREFS_SHOW_PROGRESS, showDetailedProgressBar );
|
EditorPrefs.SetBool( PREFS_SHOW_PROGRESS, showDetailedProgressBar );
|
||||||
}
|
}
|
||||||
|
|
||||||
private void LoadPrefs()
|
private void LoadPrefs()
|
||||||
{
|
{
|
||||||
ParseSceneSearchMode( (SceneSearchMode) EditorPrefs.GetInt( PREFS_SEARCH_SCENES, (int) ( SceneSearchMode.OpenScenes | SceneSearchMode.ScenesInBuildSettingsTickedOnly | SceneSearchMode.AllScenes ) ) );
|
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 );
|
searchInAssetsFolder = EditorPrefs.GetBool( PREFS_SEARCH_ASSETS, true );
|
||||||
dontSearchInSourceAssets = EditorPrefs.GetBool( PREFS_DONT_SEARCH_SOURCE_ASSETS, true );
|
dontSearchInSourceAssets = EditorPrefs.GetBool( PREFS_DONT_SEARCH_SOURCE_ASSETS, true );
|
||||||
searchInProjectSettings = EditorPrefs.GetBool( PREFS_SEARCH_PROJECT_SETTINGS, true );
|
searchInProjectSettings = EditorPrefs.GetBool( PREFS_SEARCH_PROJECT_SETTINGS, true );
|
||||||
searchDepthLimit = EditorPrefs.GetInt( PREFS_SEARCH_DEPTH_LIMIT, 4 );
|
|
||||||
fieldModifiers = (BindingFlags) EditorPrefs.GetInt( PREFS_SEARCH_FIELDS, (int) ( BindingFlags.Public | BindingFlags.NonPublic ) );
|
|
||||||
propertyModifiers = (BindingFlags) EditorPrefs.GetInt( PREFS_SEARCH_PROPERTIES, (int) ( BindingFlags.Public | BindingFlags.NonPublic ) );
|
|
||||||
searchNonSerializableVariables = EditorPrefs.GetBool( PREFS_SEARCH_NON_SERIALIZABLES, true );
|
|
||||||
searchUnusedMaterialProperties = EditorPrefs.GetBool( PREFS_SEARCH_UNUSED_MATERIAL_PROPERTIES, true );
|
searchUnusedMaterialProperties = EditorPrefs.GetBool( PREFS_SEARCH_UNUSED_MATERIAL_PROPERTIES, true );
|
||||||
lazySceneSearch = EditorPrefs.GetBool( PREFS_LAZY_SCENE_SEARCH, true );
|
lazySceneSearch = EditorPrefs.GetBool( PREFS_LAZY_SCENE_SEARCH, true );
|
||||||
#if ASSET_USAGE_ADDRESSABLES
|
#if ASSET_USAGE_ADDRESSABLES
|
||||||
@@ -432,7 +386,8 @@ namespace AssetUsageDetectorNamespace
|
|||||||
#endif
|
#endif
|
||||||
calculateUnusedObjects = EditorPrefs.GetBool( PREFS_CALCULATE_UNUSED_OBJECTS, false );
|
calculateUnusedObjects = EditorPrefs.GetBool( PREFS_CALCULATE_UNUSED_OBJECTS, false );
|
||||||
hideDuplicateRows = EditorPrefs.GetBool( PREFS_HIDE_DUPLICATE_ROWS, true );
|
hideDuplicateRows = EditorPrefs.GetBool( PREFS_HIDE_DUPLICATE_ROWS, true );
|
||||||
hideReduntantPrefabVariantLinks = EditorPrefs.GetBool( PREFS_HIDE_REDUNDANT_PREFAB_VARIANT_LINKS, true );
|
hideRedundantPrefabReferencesInAssets = EditorPrefs.GetBool( PREFS_HIDE_REDUNDANT_PREFAB_REFERENCES_IN_ASSETS, hideRedundantPrefabReferencesInAssets );
|
||||||
|
hideRedundantPrefabReferencesInScenes = EditorPrefs.GetBool( PREFS_HIDE_REDUNDANT_PREFAB_REFERENCES_IN_SCENES, hideRedundantPrefabReferencesInScenes );
|
||||||
showDetailedProgressBar = EditorPrefs.GetBool( PREFS_SHOW_PROGRESS, true );
|
showDetailedProgressBar = EditorPrefs.GetBool( PREFS_SHOW_PROGRESS, true );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -493,24 +448,16 @@ namespace AssetUsageDetectorNamespace
|
|||||||
|
|
||||||
GUILayout.Space( 10f );
|
GUILayout.Space( 10f );
|
||||||
|
|
||||||
Color c = GUI.backgroundColor;
|
Utilities.DrawHeader( "<b>SEARCH IN</b>" );
|
||||||
GUI.backgroundColor = AssetUsageDetectorSettings.SettingsHeaderColor;
|
|
||||||
GUILayout.Box( "<b>SEARCH IN</b>", Utilities.BoxGUIStyle, Utilities.GL_EXPAND_WIDTH );
|
|
||||||
GUI.backgroundColor = c;
|
|
||||||
|
|
||||||
searchInAssetsFolder = WordWrappingToggleLeft( "Project window (Assets folder)", searchInAssetsFolder );
|
searchInAssetsFolder = WordWrappingToggleLeft( "Project window (Assets folder)", searchInAssetsFolder );
|
||||||
|
|
||||||
if( searchInAssetsFolder )
|
if( searchInAssetsFolder )
|
||||||
{
|
{
|
||||||
GUILayout.BeginHorizontal();
|
BeginIndentedGUI();
|
||||||
GUILayout.Space( 35f );
|
|
||||||
GUILayout.BeginVertical();
|
|
||||||
|
|
||||||
searchInAssetsSubsetDrawer.Draw( searchInAssetsSubset );
|
searchInAssetsSubsetDrawer.Draw( searchInAssetsSubset );
|
||||||
excludedAssetsDrawer.Draw( excludedAssets );
|
excludedAssetsDrawer.Draw( excludedAssets );
|
||||||
|
EndIndentedGUI();
|
||||||
GUILayout.EndVertical();
|
|
||||||
GUILayout.EndHorizontal();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GUILayout.Space( 5f );
|
GUILayout.Space( 5f );
|
||||||
@@ -531,13 +478,10 @@ namespace AssetUsageDetectorNamespace
|
|||||||
|
|
||||||
if( searchInScenesInBuild )
|
if( searchInScenesInBuild )
|
||||||
{
|
{
|
||||||
GUILayout.BeginHorizontal();
|
BeginIndentedGUI( false );
|
||||||
GUILayout.Space( 35f );
|
|
||||||
|
|
||||||
searchInScenesInBuildTickedOnly = EditorGUILayout.ToggleLeft( "Ticked only", searchInScenesInBuildTickedOnly, Utilities.GL_WIDTH_100 );
|
searchInScenesInBuildTickedOnly = EditorGUILayout.ToggleLeft( "Ticked only", searchInScenesInBuildTickedOnly, Utilities.GL_WIDTH_100 );
|
||||||
searchInScenesInBuildTickedOnly = !EditorGUILayout.ToggleLeft( "All", !searchInScenesInBuildTickedOnly, Utilities.GL_WIDTH_100 );
|
searchInScenesInBuildTickedOnly = !EditorGUILayout.ToggleLeft( "All", !searchInScenesInBuildTickedOnly, Utilities.GL_WIDTH_100 );
|
||||||
|
EndIndentedGUI( false );
|
||||||
GUILayout.EndHorizontal();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GUI.enabled = true;
|
GUI.enabled = true;
|
||||||
@@ -545,14 +489,13 @@ namespace AssetUsageDetectorNamespace
|
|||||||
searchInAllScenes = WordWrappingToggleLeft( "All scenes in the project", searchInAllScenes );
|
searchInAllScenes = WordWrappingToggleLeft( "All scenes in the project", searchInAllScenes );
|
||||||
}
|
}
|
||||||
|
|
||||||
GUILayout.BeginHorizontal();
|
BeginIndentedGUI();
|
||||||
GUILayout.Space( 35f );
|
|
||||||
GUILayout.BeginVertical();
|
|
||||||
|
|
||||||
excludedScenesDrawer.Draw( excludedScenes );
|
excludedScenesDrawer.Draw( excludedScenes );
|
||||||
|
EndIndentedGUI();
|
||||||
|
|
||||||
GUILayout.EndVertical();
|
EditorGUI.BeginDisabledGroup( !searchInOpenScenes && !searchInScenesInBuild && !searchInAllScenes );
|
||||||
GUILayout.EndHorizontal();
|
searchInSceneLightingSettings = WordWrappingToggleLeft( "Scene Lighting Settings (WARNING: This may change the active scene during search)", searchInSceneLightingSettings );
|
||||||
|
EditorGUI.EndDisabledGroup();
|
||||||
|
|
||||||
Utilities.DrawSeparatorLine();
|
Utilities.DrawSeparatorLine();
|
||||||
|
|
||||||
@@ -560,9 +503,7 @@ namespace AssetUsageDetectorNamespace
|
|||||||
|
|
||||||
GUILayout.Space( 10f );
|
GUILayout.Space( 10f );
|
||||||
|
|
||||||
GUI.backgroundColor = AssetUsageDetectorSettings.SettingsHeaderColor;
|
Utilities.DrawHeader( "<b>SETTINGS</b>" );
|
||||||
GUILayout.Box( "<b>SETTINGS</b>", Utilities.BoxGUIStyle, Utilities.GL_EXPAND_WIDTH );
|
|
||||||
GUI.backgroundColor = c;
|
|
||||||
|
|
||||||
#if ASSET_USAGE_ADDRESSABLES
|
#if ASSET_USAGE_ADDRESSABLES
|
||||||
EditorGUI.BeginDisabledGroup( addressablesSupport );
|
EditorGUI.BeginDisabledGroup( addressablesSupport );
|
||||||
@@ -570,13 +511,12 @@ namespace AssetUsageDetectorNamespace
|
|||||||
lazySceneSearch = WordWrappingToggleLeft( "Lazy scene search: scenes are searched in detail only when they are manually refreshed (faster search)", lazySceneSearch );
|
lazySceneSearch = WordWrappingToggleLeft( "Lazy scene search: scenes are searched in detail only when they are manually refreshed (faster search)", lazySceneSearch );
|
||||||
#if ASSET_USAGE_ADDRESSABLES
|
#if ASSET_USAGE_ADDRESSABLES
|
||||||
EditorGUI.EndDisabledGroup();
|
EditorGUI.EndDisabledGroup();
|
||||||
addressablesSupport = WordWrappingToggleLeft( "Addressables support (WARNING: 'Lazy scene search' will be disabled) (slower search)", addressablesSupport );
|
addressablesSupport = WordWrappingToggleLeft( "Addressables support (Experimental) (WARNING: 'Lazy scene search' will be disabled) (slower search)", addressablesSupport );
|
||||||
#endif
|
#endif
|
||||||
calculateUnusedObjects = WordWrappingToggleLeft( "Calculate unused objects", calculateUnusedObjects );
|
calculateUnusedObjects = WordWrappingToggleLeft( "Calculate unused objects", calculateUnusedObjects );
|
||||||
hideDuplicateRows = WordWrappingToggleLeft( "Hide duplicate rows in search results", hideDuplicateRows );
|
hideDuplicateRows = WordWrappingToggleLeft( "Hide duplicate rows in search results", hideDuplicateRows );
|
||||||
#if UNITY_2018_3_OR_NEWER
|
hideRedundantPrefabReferencesInAssets = WordWrappingToggleLeft( hideRedundantPrefabReferencesInAssetsLabel, hideRedundantPrefabReferencesInAssets );
|
||||||
hideReduntantPrefabVariantLinks = WordWrappingToggleLeft( "Hide redundant prefab variant links (when the same value is assigned to the same Component of a prefab and its variant(s))", hideReduntantPrefabVariantLinks );
|
hideRedundantPrefabReferencesInScenes = WordWrappingToggleLeft( hideRedundantPrefabReferencesInScenesLabel, hideRedundantPrefabReferencesInScenes );
|
||||||
#endif
|
|
||||||
noAssetDatabaseChanges = WordWrappingToggleLeft( "I haven't modified any assets/scenes since the last search (faster search)", noAssetDatabaseChanges );
|
noAssetDatabaseChanges = WordWrappingToggleLeft( "I haven't modified any assets/scenes since the last search (faster search)", noAssetDatabaseChanges );
|
||||||
showDetailedProgressBar = WordWrappingToggleLeft( "Update search progress bar more often (cancelable search) (slower search)", showDetailedProgressBar );
|
showDetailedProgressBar = WordWrappingToggleLeft( "Update search progress bar more often (cancelable search) (slower search)", showDetailedProgressBar );
|
||||||
|
|
||||||
@@ -650,10 +590,7 @@ namespace AssetUsageDetectorNamespace
|
|||||||
|
|
||||||
private void DrawObjectsToSearchSection()
|
private void DrawObjectsToSearchSection()
|
||||||
{
|
{
|
||||||
Color c = GUI.backgroundColor;
|
Utilities.DrawHeader( "<b>SEARCHED OBJECTS</b>" );
|
||||||
GUI.backgroundColor = AssetUsageDetectorSettings.SettingsHeaderColor;
|
|
||||||
GUILayout.Box( "<b>SEARCHED OBJECTS</b>", Utilities.BoxGUIStyle, Utilities.GL_EXPAND_WIDTH );
|
|
||||||
GUI.backgroundColor = c;
|
|
||||||
|
|
||||||
Rect searchedObjectsHeaderRect = GUILayoutUtility.GetLastRect();
|
Rect searchedObjectsHeaderRect = GUILayoutUtility.GetLastRect();
|
||||||
searchedObjectsHeaderRect.x += 5f;
|
searchedObjectsHeaderRect.x += 5f;
|
||||||
@@ -666,7 +603,31 @@ namespace AssetUsageDetectorNamespace
|
|||||||
objectsToSearchDrawer.Draw( objectsToSearch );
|
objectsToSearchDrawer.Draw( objectsToSearch );
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool WordWrappingToggleLeft( string label, bool value )
|
private void BeginIndentedGUI( bool isVertical = true )
|
||||||
|
{
|
||||||
|
GUILayout.BeginHorizontal();
|
||||||
|
GUILayout.Space( 35f );
|
||||||
|
|
||||||
|
if( isVertical )
|
||||||
|
GUILayout.BeginVertical();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void EndIndentedGUI( bool isVertical = true )
|
||||||
|
{
|
||||||
|
if( isVertical )
|
||||||
|
GUILayout.EndVertical();
|
||||||
|
|
||||||
|
GUILayout.EndHorizontal();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool WordWrappingToggleLeft( string label, bool value )
|
||||||
|
{
|
||||||
|
sharedGUIContent.text = label;
|
||||||
|
sharedGUIContent.tooltip = null;
|
||||||
|
return WordWrappingToggleLeft( sharedGUIContent, value );
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool WordWrappingToggleLeft( GUIContent label, bool value )
|
||||||
{
|
{
|
||||||
GUILayout.BeginHorizontal();
|
GUILayout.BeginHorizontal();
|
||||||
bool result = EditorGUILayout.ToggleLeft( GUIContent.none, value, GL_WIDTH_12 );
|
bool result = EditorGUILayout.ToggleLeft( GUIContent.none, value, GL_WIDTH_12 );
|
||||||
@@ -685,26 +646,20 @@ namespace AssetUsageDetectorNamespace
|
|||||||
currentPhase = Phase.Processing;
|
currentPhase = Phase.Processing;
|
||||||
|
|
||||||
SavePrefs();
|
SavePrefs();
|
||||||
|
|
||||||
#if UNITY_2018_3_OR_NEWER
|
|
||||||
ReplacePrefabStageObjectsWithAssets( PrefabStageUtility.GetCurrentPrefabStage() );
|
ReplacePrefabStageObjectsWithAssets( PrefabStageUtility.GetCurrentPrefabStage() );
|
||||||
#endif
|
|
||||||
|
|
||||||
// Start searching
|
// Start searching
|
||||||
searchResult = core.Run( new AssetUsageDetector.Parameters()
|
searchResult = core.Run( new AssetUsageDetector.Parameters()
|
||||||
{
|
{
|
||||||
objectsToSearch = !objectsToSearch.IsEmpty() ? new ObjectToSearchEnumerator( objectsToSearch ).ToArray() : null,
|
objectsToSearch = !objectsToSearch.IsEmpty() ? new ObjectToSearchEnumerator( objectsToSearch ).ToArray() : null,
|
||||||
searchInScenes = GetSceneSearchMode( true ),
|
searchInScenes = GetSceneSearchMode( true ),
|
||||||
|
searchInSceneLightingSettings = searchInSceneLightingSettings,
|
||||||
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,
|
|
||||||
//propertyModifiers = propertyModifiers,
|
|
||||||
//searchDepthLimit = searchDepthLimit,
|
|
||||||
//searchNonSerializableVariables = searchNonSerializableVariables,
|
|
||||||
searchUnusedMaterialProperties = searchUnusedMaterialProperties,
|
searchUnusedMaterialProperties = searchUnusedMaterialProperties,
|
||||||
searchRefactoring = searchRefactoring,
|
searchRefactoring = searchRefactoring,
|
||||||
#if ASSET_USAGE_ADDRESSABLES
|
#if ASSET_USAGE_ADDRESSABLES
|
||||||
@@ -715,7 +670,8 @@ namespace AssetUsageDetectorNamespace
|
|||||||
#endif
|
#endif
|
||||||
calculateUnusedObjects = calculateUnusedObjects,
|
calculateUnusedObjects = calculateUnusedObjects,
|
||||||
hideDuplicateRows = hideDuplicateRows,
|
hideDuplicateRows = hideDuplicateRows,
|
||||||
hideReduntantPrefabVariantLinks = hideReduntantPrefabVariantLinks,
|
hideRedundantPrefabReferencesInAssets = hideRedundantPrefabReferencesInAssets,
|
||||||
|
hideRedundantPrefabReferencesInScenes = hideRedundantPrefabReferencesInScenes && searchInAssetsFolder,
|
||||||
noAssetDatabaseChanges = noAssetDatabaseChanges,
|
noAssetDatabaseChanges = noAssetDatabaseChanges,
|
||||||
showDetailedProgressBar = showDetailedProgressBar
|
showDetailedProgressBar = showDetailedProgressBar
|
||||||
} );
|
} );
|
||||||
@@ -729,18 +685,13 @@ namespace AssetUsageDetectorNamespace
|
|||||||
wantsMouseMove = wantsMouseEnterLeaveWindow = true;
|
wantsMouseMove = wantsMouseEnterLeaveWindow = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if UNITY_2018_3_OR_NEWER
|
|
||||||
// Try replacing searched objects who are part of currently open prefab stage with their corresponding prefab assets
|
// Try replacing searched objects who are part of currently open prefab stage with their corresponding prefab assets
|
||||||
public void ReplacePrefabStageObjectsWithAssets( PrefabStage prefabStage )
|
public void ReplacePrefabStageObjectsWithAssets( PrefabStage prefabStage )
|
||||||
{
|
{
|
||||||
if( prefabStage == null || !prefabStage.stageHandle.IsValid() )
|
if( prefabStage == null || !prefabStage.stageHandle.IsValid() )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
#if UNITY_2020_1_OR_NEWER
|
|
||||||
GameObject prefabAsset = AssetDatabase.LoadAssetAtPath<GameObject>( prefabStage.assetPath );
|
GameObject prefabAsset = AssetDatabase.LoadAssetAtPath<GameObject>( prefabStage.assetPath );
|
||||||
#else
|
|
||||||
GameObject prefabAsset = AssetDatabase.LoadAssetAtPath<GameObject>( prefabStage.prefabAssetPath );
|
|
||||||
#endif
|
|
||||||
if( prefabAsset == null || prefabAsset.Equals( null ) )
|
if( prefabAsset == null || prefabAsset.Equals( null ) )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -767,7 +718,6 @@ namespace AssetUsageDetectorNamespace
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
private bool ReturnToSetupPhase()
|
private bool ReturnToSetupPhase()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using UnityEditor;
|
using UnityEditor;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
using UnityEngine.U2D;
|
||||||
using Object = UnityEngine.Object;
|
using Object = UnityEngine.Object;
|
||||||
|
|
||||||
namespace AssetUsageDetectorNamespace
|
namespace AssetUsageDetectorNamespace
|
||||||
@@ -95,6 +96,20 @@ namespace AssetUsageDetectorNamespace
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Add Sprites of SpriteAtlases to the sub-assets list
|
||||||
|
if( target is SpriteAtlas spriteAtlas )
|
||||||
|
{
|
||||||
|
Sprite[] packedSprites = AssetUsageDetector.spriteAtlasPackedSpritesGetter( spriteAtlas );
|
||||||
|
if( packedSprites != null )
|
||||||
|
{
|
||||||
|
for( int i = 0; i < packedSprites.Length; i++ )
|
||||||
|
{
|
||||||
|
if( packedSprites[i] != null && currentSubAssets.Add( packedSprites[i] ) )
|
||||||
|
subAssets.Add( new SubAsset( packedSprites[i], shouldSearchChildren ?? true ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Find sub-asset(s) of the asset (if any)
|
// Find sub-asset(s) of the asset (if any)
|
||||||
Object[] assets = AssetDatabase.LoadAllAssetsAtPath( AssetDatabase.GetAssetPath( target ) );
|
Object[] assets = AssetDatabase.LoadAllAssetsAtPath( AssetDatabase.GetAssetPath( target ) );
|
||||||
for( int i = 0; i < assets.Length; i++ )
|
for( int i = 0; i < assets.Length; i++ )
|
||||||
@@ -103,13 +118,11 @@ namespace AssetUsageDetectorNamespace
|
|||||||
if( asset == null || asset.Equals( null ) || asset is Component || asset == target )
|
if( asset == null || asset.Equals( null ) || asset is Component || asset == target )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
#if UNITY_2018_3_OR_NEWER
|
|
||||||
// Nested prefabs in prefab assets add an additional native object of type 'UnityEngine.PrefabInstance' to the prefab. Managed type of that native type
|
// Nested prefabs in prefab assets add an additional native object of type 'UnityEngine.PrefabInstance' to the prefab. Managed type of that native type
|
||||||
// is UnityEngine.Object (i.e. GetType() returns UnityEngine.Object, not UnityEngine.PrefabInstance). There are no possible references to these native
|
// is UnityEngine.Object (i.e. GetType() returns UnityEngine.Object, not UnityEngine.PrefabInstance). There are no possible references to these native
|
||||||
// objects so skip them (we're checking for UnityEngine.Prefab because it includes other native types like UnityEngine.PrefabCreation, as well)
|
// objects so skip them (we're checking for UnityEngine.Prefab because it includes other native types like UnityEngine.PrefabCreation, as well)
|
||||||
if( target is GameObject && asset.GetType() == typeof( Object ) && asset.ToString().Contains( "(UnityEngine.Prefab" ) )
|
if( target is GameObject && asset.GetType() == typeof( Object ) && asset.ToString().Contains( "(UnityEngine.Prefab" ) )
|
||||||
continue;
|
continue;
|
||||||
#endif
|
|
||||||
|
|
||||||
if( currentSubAssets.Add( asset ) )
|
if( currentSubAssets.Add( asset ) )
|
||||||
subAssets.Add( new SubAsset( asset, shouldSearchChildren ?? true ) );
|
subAssets.Add( new SubAsset( asset, shouldSearchChildren ?? true ) );
|
||||||
@@ -117,4 +130,4 @@ namespace AssetUsageDetectorNamespace
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ using System.Reflection;
|
|||||||
using UnityEditor;
|
using UnityEditor;
|
||||||
using UnityEditor.SceneManagement;
|
using UnityEditor.SceneManagement;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
using UnityEngine.Rendering;
|
||||||
using Object = UnityEngine.Object;
|
using Object = UnityEngine.Object;
|
||||||
|
|
||||||
namespace AssetUsageDetectorNamespace
|
namespace AssetUsageDetectorNamespace
|
||||||
@@ -152,9 +153,7 @@ namespace AssetUsageDetectorNamespace
|
|||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
#if UNITY_2019_3_OR_NEWER
|
|
||||||
case SerializedPropertyType.ManagedReference: SerializedProperty.managedReferenceValue = newValue; break;
|
case SerializedPropertyType.ManagedReference: SerializedProperty.managedReferenceValue = newValue; break;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SerializedProperty.serializedObject.ApplyModifiedPropertiesWithoutUndo();
|
SerializedProperty.serializedObject.ApplyModifiedPropertiesWithoutUndo();
|
||||||
@@ -267,7 +266,7 @@ namespace AssetUsageDetectorNamespace
|
|||||||
|
|
||||||
for( int i = 0; i < MonoScriptAllVariables.Length; i++ )
|
for( int i = 0; i < MonoScriptAllVariables.Length; i++ )
|
||||||
{
|
{
|
||||||
if( MonoScriptAllVariables[i].isSerializable && !MonoScriptAllVariables[i].IsProperty )
|
if (!MonoScriptAllVariables[i].IsProperty)
|
||||||
{
|
{
|
||||||
Object variableDefaultValue = monoImporter.GetDefaultReference( MonoScriptAllVariables[i].Name );
|
Object variableDefaultValue = monoImporter.GetDefaultReference( MonoScriptAllVariables[i].Name );
|
||||||
if( variableDefaultValue == Value && MonoScriptAllVariables[i].Name == Variable )
|
if( variableDefaultValue == Value && MonoScriptAllVariables[i].Name == Variable )
|
||||||
@@ -288,20 +287,17 @@ namespace AssetUsageDetectorNamespace
|
|||||||
|
|
||||||
List<string> textureNames = new List<string>( 16 );
|
List<string> textureNames = new List<string>( 16 );
|
||||||
List<Texture> textureValues = new List<Texture>( 16 );
|
List<Texture> textureValues = new List<Texture>( 16 );
|
||||||
#if UNITY_2018_1_OR_NEWER
|
|
||||||
List<string> nonModifiableTextureNames = new List<string>( 16 );
|
List<string> nonModifiableTextureNames = new List<string>( 16 );
|
||||||
List<Texture> nonModifiableTextureValues = new List<Texture>( 16 );
|
List<Texture> nonModifiableTextureValues = new List<Texture>( 16 );
|
||||||
#endif
|
|
||||||
|
|
||||||
int shaderPropertyCount = ShaderUtil.GetPropertyCount( shader );
|
int shaderPropertyCount = shader.GetPropertyCount();
|
||||||
for( int i = 0; i < shaderPropertyCount; i++ )
|
for( int i = 0; i < shaderPropertyCount; i++ )
|
||||||
{
|
{
|
||||||
if( ShaderUtil.GetPropertyType( shader, i ) != ShaderUtil.ShaderPropertyType.TexEnv )
|
if (shader.GetPropertyType(i) != ShaderPropertyType.Texture)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
string propertyName = ShaderUtil.GetPropertyName( shader, i );
|
string propertyName = shader.GetPropertyName(i);
|
||||||
#if UNITY_2018_1_OR_NEWER
|
if ((shader.GetPropertyFlags(i) & ShaderPropertyFlags.NonModifiableTextureData) != 0)
|
||||||
if( ShaderUtil.IsShaderPropertyNonModifiableTexureProperty( shader, i ) )
|
|
||||||
{
|
{
|
||||||
Texture propertyDefaultValue = shaderImporter.GetNonModifiableTexture( propertyName );
|
Texture propertyDefaultValue = shaderImporter.GetNonModifiableTexture( propertyName );
|
||||||
if( propertyDefaultValue == Value && propertyName == Variable )
|
if( propertyDefaultValue == Value && propertyName == Variable )
|
||||||
@@ -311,7 +307,6 @@ namespace AssetUsageDetectorNamespace
|
|||||||
nonModifiableTextureValues.Add( propertyDefaultValue );
|
nonModifiableTextureValues.Add( propertyDefaultValue );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
Texture propertyDefaultValue = shaderImporter.GetDefaultTexture( propertyName );
|
Texture propertyDefaultValue = shaderImporter.GetDefaultTexture( propertyName );
|
||||||
if( propertyDefaultValue == Value && propertyName == Variable )
|
if( propertyDefaultValue == Value && propertyName == Variable )
|
||||||
@@ -323,9 +318,7 @@ namespace AssetUsageDetectorNamespace
|
|||||||
}
|
}
|
||||||
|
|
||||||
shaderImporter.SetDefaultTextures( textureNames.ToArray(), textureValues.ToArray() );
|
shaderImporter.SetDefaultTextures( textureNames.ToArray(), textureValues.ToArray() );
|
||||||
#if UNITY_2018_1_OR_NEWER
|
|
||||||
shaderImporter.SetNonModifiableTextures( nonModifiableTextureNames.ToArray(), nonModifiableTextureValues.ToArray() );
|
shaderImporter.SetNonModifiableTextures( nonModifiableTextureNames.ToArray(), nonModifiableTextureValues.ToArray() );
|
||||||
#endif
|
|
||||||
AssetDatabase.ImportAsset( shaderImporter.assetPath );
|
AssetDatabase.ImportAsset( shaderImporter.assetPath );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using UnityEditor;
|
using UnityEditor;
|
||||||
using UnityEditor.IMGUI.Controls;
|
using UnityEditor.IMGUI.Controls;
|
||||||
@@ -8,6 +9,14 @@ using UnityEditor.SceneManagement;
|
|||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.SceneManagement;
|
using UnityEngine.SceneManagement;
|
||||||
using Object = UnityEngine.Object;
|
using Object = UnityEngine.Object;
|
||||||
|
#if UNITY_6000_3_OR_NEWER
|
||||||
|
using EntityId = UnityEngine.EntityId;
|
||||||
|
#else
|
||||||
|
using EntityId = System.Int32;
|
||||||
|
#endif
|
||||||
|
#if UNITY_6000_2_OR_NEWER
|
||||||
|
using TreeViewItem = UnityEditor.IMGUI.Controls.TreeViewItem<int>;
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace AssetUsageDetectorNamespace
|
namespace AssetUsageDetectorNamespace
|
||||||
{
|
{
|
||||||
@@ -22,6 +31,7 @@ namespace AssetUsageDetectorNamespace
|
|||||||
public SearchResultGroup.GroupType type;
|
public SearchResultGroup.GroupType type;
|
||||||
public bool isExpanded;
|
public bool isExpanded;
|
||||||
public bool pendingSearch;
|
public bool pendingSearch;
|
||||||
|
public int redundantReferences;
|
||||||
public SearchResultTreeViewState treeViewState;
|
public SearchResultTreeViewState treeViewState;
|
||||||
|
|
||||||
public List<int> initialSerializedNodes;
|
public List<int> initialSerializedNodes;
|
||||||
@@ -37,7 +47,7 @@ namespace AssetUsageDetectorNamespace
|
|||||||
}
|
}
|
||||||
|
|
||||||
public string label;
|
public string label;
|
||||||
public int instanceId;
|
public EntityId instanceId;
|
||||||
public bool isUnityObject, isMainReference;
|
public bool isUnityObject, isMainReference;
|
||||||
public ReferenceNode.UsedState usedState;
|
public ReferenceNode.UsedState usedState;
|
||||||
|
|
||||||
@@ -575,6 +585,9 @@ namespace AssetUsageDetectorNamespace
|
|||||||
public int NumberOfReferences { get { return references.Count; } }
|
public int NumberOfReferences { get { return references.Count; } }
|
||||||
public ReferenceNode this[int index] { get { return references[index]; } }
|
public ReferenceNode this[int index] { get { return references[index]; } }
|
||||||
|
|
||||||
|
public int NumberOfRedundantReferences { get; internal set; }
|
||||||
|
public bool AnyReferencesFound { get { return NumberOfReferences > 0 || NumberOfRedundantReferences > 0; } }
|
||||||
|
|
||||||
public SearchResultGroup( string title, GroupType type, bool isExpanded = true, bool pendingSearch = false )
|
public SearchResultGroup( string title, GroupType type, bool isExpanded = true, bool pendingSearch = false )
|
||||||
{
|
{
|
||||||
Title = title.StartsWith( "<b>" ) ? title : string.Concat( "<b>", title, "</b>" );
|
Title = title.StartsWith( "<b>" ) ? title : string.Concat( "<b>", title, "</b>" );
|
||||||
@@ -777,32 +790,57 @@ namespace AssetUsageDetectorNamespace
|
|||||||
IsExpanded = true;
|
IsExpanded = true;
|
||||||
} );
|
} );
|
||||||
|
|
||||||
if( searchResult != null && searchResult.NumberOfGroups > 1 && !string.IsNullOrEmpty( treeViewState.searchTerm ) )
|
if( !string.IsNullOrEmpty( treeViewState.searchTerm ) )
|
||||||
{
|
{
|
||||||
if( contextMenu.GetItemCount() > 0 )
|
if( contextMenu.GetItemCount() > 0 )
|
||||||
contextMenu.AddSeparator( "" );
|
contextMenu.AddSeparator( "" );
|
||||||
|
|
||||||
contextMenu.AddItem( new GUIContent( "Apply Search to All Results" ), false, () =>
|
if( searchResult != null && searchResult.NumberOfGroups > 1 )
|
||||||
{
|
{
|
||||||
for( int i = 0; i < searchResult.NumberOfGroups; i++ )
|
contextMenu.AddItem( new GUIContent( "Apply Search to All Results" ), false, () =>
|
||||||
{
|
{
|
||||||
if( searchResult[i].treeView == null )
|
for( int i = 0; i < searchResult.NumberOfGroups; i++ )
|
||||||
continue;
|
{
|
||||||
|
if( searchResult[i].treeView == null )
|
||||||
|
continue;
|
||||||
|
|
||||||
string previousSearchTerm = searchResult[i].treeViewState.searchTerm ?? "";
|
string previousSearchTerm = searchResult[i].treeViewState.searchTerm ?? "";
|
||||||
SearchResultTreeView.SearchMode previousSearchMode = searchResult[i].treeViewState.searchMode;
|
SearchResultTreeView.SearchMode previousSearchMode = searchResult[i].treeViewState.searchMode;
|
||||||
|
|
||||||
searchResult[i].treeViewState.searchTerm = treeViewState.searchTerm ?? "";
|
searchResult[i].treeViewState.searchTerm = treeViewState.searchTerm ?? "";
|
||||||
searchResult[i].treeViewState.searchMode = treeViewState.searchMode;
|
searchResult[i].treeViewState.searchMode = treeViewState.searchMode;
|
||||||
|
|
||||||
if( treeViewState.searchTerm != previousSearchTerm || treeViewState.searchMode != previousSearchMode )
|
if( treeViewState.searchTerm != previousSearchTerm || treeViewState.searchMode != previousSearchMode )
|
||||||
searchResult[i].treeView.RefreshSearch( previousSearchTerm );
|
searchResult[i].treeView.RefreshSearch( previousSearchTerm );
|
||||||
}
|
}
|
||||||
} );
|
} );
|
||||||
|
}
|
||||||
|
|
||||||
|
IList<TreeViewItem> treeViewRows = treeView.GetRows();
|
||||||
|
if( treeViewRows.Count > 1 ) // References are at depth 1 so if there are any references, at least 2 rows must exist
|
||||||
|
{
|
||||||
|
contextMenu.AddItem( new GUIContent( "Hide Search Results" ), false, () =>
|
||||||
|
{
|
||||||
|
List<int> removedRows = new List<int>( treeViewRows.Count );
|
||||||
|
for( int i = treeViewRows.Count - 1; i >= 0; i-- )
|
||||||
|
{
|
||||||
|
if( treeViewRows[i].depth > 0 )
|
||||||
|
removedRows.Add( treeViewRows[i].id );
|
||||||
|
}
|
||||||
|
|
||||||
|
treeView.ClearSearch();
|
||||||
|
treeView.HideItems( removedRows );
|
||||||
|
} );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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
|
// Show context menu when SearchResultGroup's header is right clicked
|
||||||
Scene scene = EditorSceneManager.GetSceneByPath( ScenePath );
|
Scene scene = EditorSceneManager.GetSceneByPath( ScenePath );
|
||||||
@@ -843,6 +881,9 @@ namespace AssetUsageDetectorNamespace
|
|||||||
|
|
||||||
if( IsExpanded )
|
if( IsExpanded )
|
||||||
{
|
{
|
||||||
|
if( NumberOfRedundantReferences > 0 )
|
||||||
|
EditorGUILayout.HelpBox( string.Concat( NumberOfRedundantReferences.ToString(), " redundant prefab reference(s) were skipped. Disable \"Hide redundant prefab references in ", ( Type == GroupType.Scene || Type == GroupType.DontDestroyOnLoad ) ? "Scenes" : "Assets", "\" to see them." ), MessageType.Info );
|
||||||
|
|
||||||
if( PendingSearch )
|
if( PendingSearch )
|
||||||
GUILayout.Box( "Lazy Search: this scene potentially has some references, hit Refresh to find them", Utilities.BoxGUIStyle );
|
GUILayout.Box( "Lazy Search: this scene potentially has some references, hit Refresh to find them", Utilities.BoxGUIStyle );
|
||||||
else if( references.Count == 0 )
|
else if( references.Count == 0 )
|
||||||
@@ -857,6 +898,9 @@ namespace AssetUsageDetectorNamespace
|
|||||||
if( searchResult != null && searchResult.SearchParameters.dontSearchInSourceAssets && searchResult.SearchParameters.objectsToSearch.Length > 1 )
|
if( searchResult != null && searchResult.SearchParameters.dontSearchInSourceAssets && searchResult.SearchParameters.objectsToSearch.Length > 1 )
|
||||||
EditorGUILayout.HelpBox( "'Don't search \"SEARCHED OBJECTS\" themselves for references' is enabled, some of these objects might be used by \"SEARCHED OBJECTS\".", MessageType.Warning );
|
EditorGUILayout.HelpBox( "'Don't search \"SEARCHED OBJECTS\" themselves for references' is enabled, some of these objects might be used by \"SEARCHED OBJECTS\".", MessageType.Warning );
|
||||||
|
|
||||||
|
if( !AssetUsageDetectorSettings.MarkUsedAssetsSubAssetsAsUsed )
|
||||||
|
EditorGUILayout.HelpBox( "'Hide unused sub-assets in \"Unused Objects\" list if their parent assets are used' is disabled, unused sub-assets' parent assets might be used.", MessageType.Warning );
|
||||||
|
|
||||||
EditorGUILayout.HelpBox( "Although no references to these objects are found, they might still be used somewhere (e.g. via Resources.Load). If you intend to delete these objects, consider creating a backup of your project first.", MessageType.Info );
|
EditorGUILayout.HelpBox( "Although no references to these objects are found, they might still be used somewhere (e.g. via Resources.Load). If you intend to delete these objects, consider creating a backup of your project first.", MessageType.Info );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -872,7 +916,7 @@ namespace AssetUsageDetectorNamespace
|
|||||||
if( shouldUpdateInitialTreeViewNodeId )
|
if( shouldUpdateInitialTreeViewNodeId )
|
||||||
treeViewState.initialNodeId = searchResult.nextTreeViewId;
|
treeViewState.initialNodeId = searchResult.nextTreeViewId;
|
||||||
|
|
||||||
treeView = new SearchResultTreeView( treeViewState, references, ( Type == GroupType.UnusedObjects ) ? SearchResultTreeView.TreeType.UnusedObjects : SearchResultTreeView.TreeType.Normal, searchResult != null ? searchResult.UsedObjects : null, searchResult != null && searchResult.SearchParameters.hideDuplicateRows, searchResult != null && searchResult.SearchParameters.hideReduntantPrefabVariantLinks, true );
|
treeView = new SearchResultTreeView( treeViewState, references, ( Type == GroupType.UnusedObjects ) ? SearchResultTreeView.TreeType.UnusedObjects : SearchResultTreeView.TreeType.Normal, searchResult != null ? searchResult.UsedObjects : null, searchResult != null && searchResult.SearchParameters.hideDuplicateRows, true );
|
||||||
|
|
||||||
if( isFirstInitialization )
|
if( isFirstInitialization )
|
||||||
{
|
{
|
||||||
@@ -944,19 +988,8 @@ namespace AssetUsageDetectorNamespace
|
|||||||
|
|
||||||
Rect treeViewRect = EditorGUILayout.GetControlRect( false, treeView.totalHeight );
|
Rect treeViewRect = EditorGUILayout.GetControlRect( false, treeView.totalHeight );
|
||||||
if( ev.type == EventType.Repaint )
|
if( ev.type == EventType.Repaint )
|
||||||
{
|
|
||||||
lastTreeViewRect = treeViewRect;
|
lastTreeViewRect = treeViewRect;
|
||||||
|
|
||||||
#if !UNITY_2018_2_OR_NEWER
|
|
||||||
// TreeView calls RowGUI for all rows instead of only the visible rows on early Unity versions which leads to performance issues. Do manual row culling on those versions
|
|
||||||
// Credit: https://github.com/Unity-Technologies/UnityCsReference/blob/a048de916b23331bf6dfe92c4a6c205989b83b4f/Editor/Mono/GUI/TreeView/TreeViewGUI.cs#L273-L276
|
|
||||||
float topPixel = scrollPosition - treeViewRect.y;
|
|
||||||
float heightInPixels = window.position.height;
|
|
||||||
treeView.visibleRowTop = (int) Mathf.Floor( topPixel / treeView.rowHeight );
|
|
||||||
treeView.visibleRowBottom = treeView.visibleRowTop + (int) Mathf.Ceil( heightInPixels / treeView.rowHeight );
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
treeView.OnGUI( treeViewRect );
|
treeView.OnGUI( treeViewRect );
|
||||||
|
|
||||||
if( treeViewKeyboardNavigation && treeView.HasFocus() && treeView.HasSelection() )
|
if( treeViewKeyboardNavigation && treeView.HasFocus() && treeView.HasSelection() )
|
||||||
@@ -1036,6 +1069,7 @@ namespace AssetUsageDetectorNamespace
|
|||||||
type = Type,
|
type = Type,
|
||||||
isExpanded = IsExpanded,
|
isExpanded = IsExpanded,
|
||||||
pendingSearch = PendingSearch,
|
pendingSearch = PendingSearch,
|
||||||
|
redundantReferences = NumberOfRedundantReferences,
|
||||||
treeViewState = treeViewState
|
treeViewState = treeViewState
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -1053,6 +1087,7 @@ namespace AssetUsageDetectorNamespace
|
|||||||
// Deserialize this result group from the serialized data
|
// Deserialize this result group from the serialized data
|
||||||
internal void Deserialize( SearchResult.SerializableResultGroup serializedResultGroup, List<ReferenceNode> allNodes )
|
internal void Deserialize( SearchResult.SerializableResultGroup serializedResultGroup, List<ReferenceNode> allNodes )
|
||||||
{
|
{
|
||||||
|
NumberOfRedundantReferences = serializedResultGroup.redundantReferences;
|
||||||
treeViewState = serializedResultGroup.treeViewState;
|
treeViewState = serializedResultGroup.treeViewState;
|
||||||
|
|
||||||
if( serializedResultGroup.initialSerializedNodes != null )
|
if( serializedResultGroup.initialSerializedNodes != null )
|
||||||
@@ -1100,8 +1135,8 @@ namespace AssetUsageDetectorNamespace
|
|||||||
public bool IsMainReference { get; private set; } // True: if belongs to a scene search result group, then it's an object in that scene. If belongs to the assets search result group, then it's an asset
|
public bool IsMainReference { get; private set; } // True: if belongs to a scene search result group, then it's an object in that scene. If belongs to the assets search result group, then it's an asset
|
||||||
|
|
||||||
internal object nodeObject;
|
internal object nodeObject;
|
||||||
private int? instanceId; // instanceId of the nodeObject if it is a Unity object, null otherwise
|
private EntityId? instanceId; // instanceId of the nodeObject if it is a Unity object, null otherwise
|
||||||
public Object UnityObject { get { return instanceId.HasValue ? EditorUtility.InstanceIDToObject( instanceId.Value ) : null; } }
|
public Object UnityObject => instanceId.HasValue ? Utilities.EntityIdToObject(instanceId.Value) : null;
|
||||||
|
|
||||||
private readonly List<Link> links = new List<Link>( 2 );
|
private readonly List<Link> links = new List<Link>( 2 );
|
||||||
public int NumberOfOutgoingLinks { get { return links.Count; } }
|
public int NumberOfOutgoingLinks { get { return links.Count; } }
|
||||||
@@ -1174,30 +1209,6 @@ namespace AssetUsageDetectorNamespace
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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 )
|
public void CopyReferencesTo( ReferenceNode other )
|
||||||
{
|
{
|
||||||
other.links.Clear();
|
other.links.Clear();
|
||||||
@@ -1219,8 +1230,15 @@ namespace AssetUsageDetectorNamespace
|
|||||||
Object unityObject = nodeObject as Object;
|
Object unityObject = nodeObject as Object;
|
||||||
if( unityObject != null )
|
if( unityObject != null )
|
||||||
{
|
{
|
||||||
instanceId = unityObject.GetInstanceID();
|
instanceId = unityObject.GetEntityId();
|
||||||
Label = unityObject.name + " (" + unityObject.GetType().Name + ")";
|
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 += " <in " + mainAssetName + ">";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if( nodeObject != null )
|
else if( nodeObject != null )
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -26,11 +26,20 @@ namespace AssetUsageDetectorNamespace
|
|||||||
|
|
||||||
public static void Show( Rect sourcePosition, string tooltip )
|
public static void Show( Rect sourcePosition, string tooltip )
|
||||||
{
|
{
|
||||||
|
// Don't lose focus to the previous window
|
||||||
|
EditorWindow prevFocusedWindow = focusedWindow;
|
||||||
|
|
||||||
|
if (!mainWindow)
|
||||||
|
{
|
||||||
|
mainWindow = CreateInstance<SearchResultTooltip>();
|
||||||
|
mainWindow.ShowPopup();
|
||||||
|
}
|
||||||
|
|
||||||
Vector2 preferredSize = Style.CalcSize( new GUIContent( tooltip ) ) + Style.contentOffset + new Vector2( Style.padding.horizontal + Style.margin.horizontal, Style.padding.vertical + Style.margin.vertical );
|
Vector2 preferredSize = Style.CalcSize( new GUIContent( tooltip ) ) + Style.contentOffset + new Vector2( Style.padding.horizontal + Style.margin.horizontal, Style.padding.vertical + Style.margin.vertical );
|
||||||
Rect preferredPosition;
|
Rect preferredPosition;
|
||||||
|
|
||||||
Rect positionLeft = new Rect( sourcePosition.position - new Vector2( preferredSize.x, 0f ), preferredSize );
|
Rect positionLeft = new Rect( sourcePosition.position - new Vector2( preferredSize.x, 0f ), preferredSize );
|
||||||
Rect screenFittedPositionLeft = Utilities.GetScreenFittedRect( positionLeft );
|
Rect screenFittedPositionLeft = Utilities.GetScreenFittedRect(positionLeft, mainWindow);
|
||||||
|
|
||||||
Vector2 positionOffset = positionLeft.position - screenFittedPositionLeft.position;
|
Vector2 positionOffset = positionLeft.position - screenFittedPositionLeft.position;
|
||||||
Vector2 sizeOffset = positionLeft.size - screenFittedPositionLeft.size;
|
Vector2 sizeOffset = positionLeft.size - screenFittedPositionLeft.size;
|
||||||
@@ -39,7 +48,7 @@ namespace AssetUsageDetectorNamespace
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
Rect positionRight = new Rect( sourcePosition.position + new Vector2( sourcePosition.width, 0f ), preferredSize );
|
Rect positionRight = new Rect( sourcePosition.position + new Vector2( sourcePosition.width, 0f ), preferredSize );
|
||||||
Rect screenFittedPositionRight = Utilities.GetScreenFittedRect( positionRight );
|
Rect screenFittedPositionRight = Utilities.GetScreenFittedRect(positionRight, mainWindow);
|
||||||
|
|
||||||
Vector2 positionOffset2 = positionRight.position - screenFittedPositionRight.position;
|
Vector2 positionOffset2 = positionRight.position - screenFittedPositionRight.position;
|
||||||
Vector2 sizeOffset2 = positionRight.size - screenFittedPositionRight.size;
|
Vector2 sizeOffset2 = positionRight.size - screenFittedPositionRight.size;
|
||||||
@@ -49,15 +58,6 @@ namespace AssetUsageDetectorNamespace
|
|||||||
preferredPosition = screenFittedPositionLeft;
|
preferredPosition = screenFittedPositionLeft;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Don't lose focus to the previous window
|
|
||||||
EditorWindow prevFocusedWindow = focusedWindow;
|
|
||||||
|
|
||||||
if( !mainWindow )
|
|
||||||
{
|
|
||||||
mainWindow = CreateInstance<SearchResultTooltip>();
|
|
||||||
mainWindow.ShowPopup();
|
|
||||||
}
|
|
||||||
|
|
||||||
SearchResultTooltip.tooltip = tooltip;
|
SearchResultTooltip.tooltip = tooltip;
|
||||||
mainWindow.minSize = preferredPosition.size;
|
mainWindow.minSize = preferredPosition.size;
|
||||||
mainWindow.position = preferredPosition;
|
mainWindow.position = preferredPosition;
|
||||||
|
|||||||
@@ -4,13 +4,12 @@ using System.Reflection;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using UnityEditor;
|
using UnityEditor;
|
||||||
using UnityEditor.IMGUI.Controls;
|
using UnityEditor.IMGUI.Controls;
|
||||||
|
using UnityEditor.SceneManagement;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
#if UNITY_2021_2_OR_NEWER
|
#if UNITY_6000_2_OR_NEWER
|
||||||
using PrefabStage = UnityEditor.SceneManagement.PrefabStage;
|
using TreeView = UnityEditor.IMGUI.Controls.TreeView<int>;
|
||||||
using PrefabStageUtility = UnityEditor.SceneManagement.PrefabStageUtility;
|
using TreeViewItem = UnityEditor.IMGUI.Controls.TreeViewItem<int>;
|
||||||
#elif UNITY_2018_3_OR_NEWER
|
using TreeViewState = UnityEditor.IMGUI.Controls.TreeViewState<int>;
|
||||||
using PrefabStage = UnityEditor.Experimental.SceneManagement.PrefabStage;
|
|
||||||
using PrefabStageUtility = UnityEditor.Experimental.SceneManagement.PrefabStageUtility;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace AssetUsageDetectorNamespace
|
namespace AssetUsageDetectorNamespace
|
||||||
@@ -104,11 +103,7 @@ namespace AssetUsageDetectorNamespace
|
|||||||
}
|
}
|
||||||
|
|
||||||
private const float SEARCHED_OBJECTS_BORDER_THICKNESS = 1f;
|
private const float SEARCHED_OBJECTS_BORDER_THICKNESS = 1f;
|
||||||
#if UNITY_2019_3_OR_NEWER
|
private const float TREE_VIEW_LINES_THICKNESS = 1.5f; // There are inexplicable spaces between the vertical and horizontal lines if we set this to 2.0f on 2019.3+
|
||||||
private const float TREE_VIEW_LINES_THICKNESS = 1.5f; // There are inexplicable spaces between the vertical and horizontal lines if we don't change thickness by 0.5f on 2019.3+
|
|
||||||
#else
|
|
||||||
private const float TREE_VIEW_LINES_THICKNESS = 2f;
|
|
||||||
#endif
|
|
||||||
private const float HIGHLIGHTED_TREE_VIEW_LINES_THICKNESS = TREE_VIEW_LINES_THICKNESS * 2f;
|
private const float HIGHLIGHTED_TREE_VIEW_LINES_THICKNESS = TREE_VIEW_LINES_THICKNESS * 2f;
|
||||||
|
|
||||||
private readonly new SearchResultTreeViewState state;
|
private readonly new SearchResultTreeViewState state;
|
||||||
@@ -124,14 +119,9 @@ namespace AssetUsageDetectorNamespace
|
|||||||
|
|
||||||
private readonly TreeType treeType;
|
private readonly TreeType treeType;
|
||||||
private readonly bool hideDuplicateRows;
|
private readonly bool hideDuplicateRows;
|
||||||
private readonly bool hideReduntantPrefabVariantLinks;
|
|
||||||
|
|
||||||
private bool isSearching;
|
private bool isSearching;
|
||||||
|
|
||||||
#if !UNITY_2018_2_OR_NEWER
|
|
||||||
public int visibleRowTop = 0, visibleRowBottom = int.MaxValue;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
private readonly CompareInfo textComparer = new CultureInfo( "en-US" ).CompareInfo;
|
private readonly CompareInfo textComparer = new CultureInfo( "en-US" ).CompareInfo;
|
||||||
private readonly CompareOptions textCompareOptions = CompareOptions.IgnoreCase | CompareOptions.IgnoreNonSpace;
|
private readonly CompareOptions textCompareOptions = CompareOptions.IgnoreCase | CompareOptions.IgnoreNonSpace;
|
||||||
|
|
||||||
@@ -151,26 +141,19 @@ namespace AssetUsageDetectorNamespace
|
|||||||
public new float rowHeight
|
public new float rowHeight
|
||||||
{
|
{
|
||||||
get { return base.rowHeight; }
|
get { return base.rowHeight; }
|
||||||
set
|
set { base.rowHeight = value; }
|
||||||
{
|
|
||||||
base.rowHeight = value;
|
|
||||||
#if !UNITY_2019_3_OR_NEWER
|
|
||||||
customFoldoutYOffset = ( value - EditorGUIUtility.singleLineHeight ) * 0.5f;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Avoid using these properties of TreeView by mistake
|
// Avoid using these properties of TreeView by mistake
|
||||||
[System.Obsolete] private new string searchString { get; }
|
[System.Obsolete] private new string searchString { get; }
|
||||||
[System.Obsolete] private new bool hasSearch { get; }
|
[System.Obsolete] private new bool hasSearch { get; }
|
||||||
|
|
||||||
public SearchResultTreeView( SearchResultTreeViewState state, List<ReferenceNode> references, TreeType treeType, HashSet<Object> usedObjectsSet, bool hideDuplicateRows, bool hideReduntantPrefabVariantLinks, bool usesExternalScrollView ) : base( state )
|
public SearchResultTreeView( SearchResultTreeViewState state, List<ReferenceNode> references, TreeType treeType, HashSet<Object> usedObjectsSet, bool hideDuplicateRows, bool usesExternalScrollView ) : base( state )
|
||||||
{
|
{
|
||||||
this.state = state;
|
this.state = state;
|
||||||
this.references = references;
|
this.references = references;
|
||||||
this.treeType = treeType;
|
this.treeType = treeType;
|
||||||
this.hideDuplicateRows = hideDuplicateRows;
|
this.hideDuplicateRows = hideDuplicateRows;
|
||||||
this.hideReduntantPrefabVariantLinks = hideReduntantPrefabVariantLinks;
|
|
||||||
|
|
||||||
highlightedSearchTextColor = "<color=#" + ColorUtility.ToHtmlStringRGBA( AssetUsageDetectorSettings.SearchMatchingTextColor ) + ">";
|
highlightedSearchTextColor = "<color=#" + ColorUtility.ToHtmlStringRGBA( AssetUsageDetectorSettings.SearchMatchingTextColor ) + ">";
|
||||||
|
|
||||||
@@ -185,13 +168,7 @@ namespace AssetUsageDetectorNamespace
|
|||||||
if( treeType != TreeType.IsolatedView )
|
if( treeType != TreeType.IsolatedView )
|
||||||
{
|
{
|
||||||
// Draw only the visible rows. This requires setting useScrollView to false because we are using an external scroll view: https://docs.unity3d.com/ScriptReference/IMGUI.Controls.TreeView-useScrollView.html
|
// Draw only the visible rows. This requires setting useScrollView to false because we are using an external scroll view: https://docs.unity3d.com/ScriptReference/IMGUI.Controls.TreeView-useScrollView.html
|
||||||
#if UNITY_2018_2_OR_NEWER
|
|
||||||
useScrollView = false;
|
useScrollView = false;
|
||||||
#else
|
|
||||||
// In my tests, SetUseScrollView seems to have no effect unfortunately but let's keep this line in case it fixes some other issues with the external scroll view
|
|
||||||
object treeViewController = typeof( TreeView ).GetField( "m_TreeView", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance ).GetValue( this );
|
|
||||||
treeViewController.GetType().GetMethod( "SetUseScrollView", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance ).Invoke( treeViewController, new object[1] { false } );
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
isSearching = !string.IsNullOrEmpty( state.searchTerm );
|
isSearching = !string.IsNullOrEmpty( state.searchTerm );
|
||||||
@@ -202,6 +179,13 @@ namespace AssetUsageDetectorNamespace
|
|||||||
RefreshSelectedNodes( GetSelection() );
|
RefreshSelectedNodes( GetSelection() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void ClearSearch()
|
||||||
|
{
|
||||||
|
string prevSearchTerm = state.searchTerm;
|
||||||
|
state.searchTerm = "";
|
||||||
|
RefreshSearch( prevSearchTerm );
|
||||||
|
}
|
||||||
|
|
||||||
public void RefreshSearch( string prevSearchTerm )
|
public void RefreshSearch( string prevSearchTerm )
|
||||||
{
|
{
|
||||||
bool wasSearchTermEmpty = string.IsNullOrEmpty( prevSearchTerm );
|
bool wasSearchTermEmpty = string.IsNullOrEmpty( prevSearchTerm );
|
||||||
@@ -287,25 +271,6 @@ namespace AssetUsageDetectorNamespace
|
|||||||
|
|
||||||
private bool GenerateRowsRecursive( TreeViewItem parent, ReferenceNode referenceNode, ReferenceNodeData parentData, int siblingIndex, int depth, bool? itemForcedVisibility, List<ReferenceNode> stack, HashSet<ReferenceNode> processedNodes, ref int id )
|
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.GetHashCode(), linkDescriptions ) )
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
TreeViewItem item = new TreeViewItem( id++, depth, "" );
|
TreeViewItem item = new TreeViewItem( id++, depth, "" );
|
||||||
ReferenceNodeData data = new ReferenceNodeData( item, referenceNode, parentData, siblingIndex );
|
ReferenceNodeData data = new ReferenceNodeData( item, referenceNode, parentData, siblingIndex );
|
||||||
|
|
||||||
@@ -437,12 +402,6 @@ namespace AssetUsageDetectorNamespace
|
|||||||
|
|
||||||
protected override void RowGUI( RowGUIArgs args )
|
protected override void RowGUI( RowGUIArgs args )
|
||||||
{
|
{
|
||||||
#if !UNITY_2018_2_OR_NEWER
|
|
||||||
// Do manual row culling on early Unity versions
|
|
||||||
if( args.row < visibleRowTop || args.row > visibleRowBottom )
|
|
||||||
return;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if( isTreeViewEmpty )
|
if( isTreeViewEmpty )
|
||||||
{
|
{
|
||||||
EditorGUI.LabelField( args.rowRect, "No matching results..." );
|
EditorGUI.LabelField( args.rowRect, "No matching results..." );
|
||||||
@@ -680,9 +639,6 @@ namespace AssetUsageDetectorNamespace
|
|||||||
|
|
||||||
rect.xMin += GetContentIndent( args.item );
|
rect.xMin += GetContentIndent( args.item );
|
||||||
rect.y += AssetUsageDetectorSettings.ExtraRowHeight * 0.5f;
|
rect.y += AssetUsageDetectorSettings.ExtraRowHeight * 0.5f;
|
||||||
#if !UNITY_2019_3_OR_NEWER
|
|
||||||
rect.y -= 2f;
|
|
||||||
#endif
|
|
||||||
rect.height += 4f; // Incrementing height fixes cropped icon issue on Unity 2019.2 or earlier
|
rect.height += 4f; // Incrementing height fixes cropped icon issue on Unity 2019.2 or earlier
|
||||||
|
|
||||||
if( foldoutLabelStyle == null )
|
if( foldoutLabelStyle == null )
|
||||||
@@ -759,7 +715,6 @@ namespace AssetUsageDetectorNamespace
|
|||||||
isLMBDown = false;
|
isLMBDown = false;
|
||||||
|
|
||||||
Object clickedObject = GetDataFromId( id ).node.UnityObject;
|
Object clickedObject = GetDataFromId( id ).node.UnityObject;
|
||||||
#if UNITY_2018_3_OR_NEWER
|
|
||||||
if( clickedObject && clickedObject.IsAsset() )
|
if( clickedObject && clickedObject.IsAsset() )
|
||||||
{
|
{
|
||||||
GameObject clickedPrefabRoot = null;
|
GameObject clickedPrefabRoot = null;
|
||||||
@@ -776,16 +731,11 @@ namespace AssetUsageDetectorNamespace
|
|||||||
// Try to open the prefab stage of this prefab
|
// Try to open the prefab stage of this prefab
|
||||||
string assetPath = AssetDatabase.GetAssetPath( clickedPrefabRoot );
|
string assetPath = AssetDatabase.GetAssetPath( clickedPrefabRoot );
|
||||||
PrefabStage openPrefabStage = PrefabStageUtility.GetCurrentPrefabStage();
|
PrefabStage openPrefabStage = PrefabStageUtility.GetCurrentPrefabStage();
|
||||||
#if UNITY_2020_1_OR_NEWER
|
|
||||||
if( openPrefabStage == null || !openPrefabStage.stageHandle.IsValid() || assetPath != openPrefabStage.assetPath )
|
if( openPrefabStage == null || !openPrefabStage.stageHandle.IsValid() || assetPath != openPrefabStage.assetPath )
|
||||||
#else
|
|
||||||
if( openPrefabStage == null || !openPrefabStage.stageHandle.IsValid() || assetPath != openPrefabStage.prefabAssetPath )
|
|
||||||
#endif
|
|
||||||
AssetDatabase.OpenAsset( clickedPrefabRoot );
|
AssetDatabase.OpenAsset( clickedPrefabRoot );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
// Ping the clicked GameObject in the open prefab stage
|
// Ping the clicked GameObject in the open prefab stage
|
||||||
Object selection, pingTarget;
|
Object selection, pingTarget;
|
||||||
@@ -966,6 +916,8 @@ namespace AssetUsageDetectorNamespace
|
|||||||
for( int i = 0; i < item.children.Count; i++ )
|
for( int i = 0; i < item.children.Count; i++ )
|
||||||
shouldExpand |= GetMainReferenceIdsRecursive( item.children[i], ids );
|
shouldExpand |= GetMainReferenceIdsRecursive( item.children[i], ids );
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
shouldExpand = true; // No main reference is encountered in this branch; expand the whole branch
|
||||||
|
|
||||||
if( shouldExpand )
|
if( shouldExpand )
|
||||||
ids.Add( item.id );
|
ids.Add( item.id );
|
||||||
@@ -1010,7 +962,7 @@ namespace AssetUsageDetectorNamespace
|
|||||||
return referenceNodes.Contains( GetDataFromId( item.id ).node );
|
return referenceNodes.Contains( GetDataFromId( item.id ).node );
|
||||||
}
|
}
|
||||||
|
|
||||||
private void HideItems( IList<int> ids )
|
public void HideItems( IList<int> ids )
|
||||||
{
|
{
|
||||||
if( ids.Count > 0 )
|
if( ids.Count > 0 )
|
||||||
{
|
{
|
||||||
@@ -1175,10 +1127,10 @@ namespace AssetUsageDetectorNamespace
|
|||||||
|
|
||||||
if( selectedNodes.Count > 0 )
|
if( selectedNodes.Count > 0 )
|
||||||
{
|
{
|
||||||
SearchResultTreeView isolatedTreeView = new SearchResultTreeView( new SearchResultTreeViewState(), selectedNodes, TreeType.IsolatedView, null, hideDuplicateRows, hideReduntantPrefabVariantLinks, false );
|
SearchResultTreeView isolatedTreeView = new SearchResultTreeView( new SearchResultTreeViewState(), selectedNodes, TreeType.IsolatedView, null, hideDuplicateRows, false );
|
||||||
isolatedTreeView.ExpandMainReferences();
|
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 +1284,7 @@ namespace AssetUsageDetectorNamespace
|
|||||||
SearchResultTreeViewIsolatedView window = CreateInstance<SearchResultTreeViewIsolatedView>();
|
SearchResultTreeViewIsolatedView window = CreateInstance<SearchResultTreeViewIsolatedView>();
|
||||||
window.treeView = treeView;
|
window.treeView = treeView;
|
||||||
window.titleContent = title;
|
window.titleContent = title;
|
||||||
window.ShowAuxWindow();
|
window.Show();
|
||||||
|
|
||||||
window.minSize = new Vector2( 150f, Mathf.Min( preferredSize.y, EditorGUIUtility.singleLineHeight * 2f ) );
|
window.minSize = new Vector2( 150f, Mathf.Min( preferredSize.y, EditorGUIUtility.singleLineHeight * 2f ) );
|
||||||
window.position = new Rect( new Vector2( -9999f, -9999f ), preferredSize );
|
window.position = new Rect( new Vector2( -9999f, -9999f ), preferredSize );
|
||||||
@@ -1358,7 +1310,7 @@ namespace AssetUsageDetectorNamespace
|
|||||||
if( preferredHeight > 10f )
|
if( preferredHeight > 10f )
|
||||||
{
|
{
|
||||||
Vector2 size = position.size;
|
Vector2 size = position.size;
|
||||||
position = Utilities.GetScreenFittedRect( new Rect( GUIUtility.GUIToScreenPoint( Event.current.mousePosition ) + new Vector2( size.x * -0.5f, 10f ), size ) );
|
position = Utilities.GetScreenFittedRect(new Rect(GUIUtility.GUIToScreenPoint(Event.current.mousePosition) + new Vector2(size.x * -0.5f, 10f), size), this);
|
||||||
|
|
||||||
shouldRepositionSelf = false;
|
shouldRepositionSelf = false;
|
||||||
GUIUtility.ExitGUI();
|
GUIUtility.ExitGUI();
|
||||||
|
|||||||
@@ -2,18 +2,12 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
#if UNITY_2018_1_OR_NEWER
|
|
||||||
using Unity.Collections;
|
using Unity.Collections;
|
||||||
#endif
|
|
||||||
using UnityEditor;
|
using UnityEditor;
|
||||||
using UnityEditor.SceneManagement;
|
using UnityEditor.SceneManagement;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.SceneManagement;
|
using UnityEngine.SceneManagement;
|
||||||
using Object = UnityEngine.Object;
|
using Object = UnityEngine.Object;
|
||||||
#if UNITY_2018_3_OR_NEWER && !UNITY_2021_2_OR_NEWER
|
|
||||||
using PrefabStage = UnityEditor.Experimental.SceneManagement.PrefabStage;
|
|
||||||
using PrefabStageUtility = UnityEditor.Experimental.SceneManagement.PrefabStageUtility;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace AssetUsageDetectorNamespace
|
namespace AssetUsageDetectorNamespace
|
||||||
{
|
{
|
||||||
@@ -37,19 +31,19 @@ namespace AssetUsageDetectorNamespace
|
|||||||
typeof( List<Vector4> ), typeof( List<Vector3> ), typeof( List<Vector2> ), typeof( List<Rect> ),
|
typeof( List<Vector4> ), typeof( List<Vector3> ), typeof( List<Vector2> ), typeof( List<Rect> ),
|
||||||
typeof( List<Quaternion> ), typeof( List<Color> ), typeof( List<Color32> ), typeof( List<LayerMask> ), typeof( List<Bounds> ),
|
typeof( List<Quaternion> ), typeof( List<Color> ), typeof( List<Color32> ), typeof( List<LayerMask> ), typeof( List<Bounds> ),
|
||||||
typeof( List<Matrix4x4> ), typeof( List<AnimationCurve> ), typeof( List<Gradient> ), typeof( List<RectOffset> ),
|
typeof( List<Matrix4x4> ), typeof( List<AnimationCurve> ), typeof( List<Gradient> ), typeof( List<RectOffset> ),
|
||||||
#if UNITY_2017_2_OR_NEWER
|
|
||||||
typeof( Vector3Int ), typeof( Vector2Int ), typeof( RectInt ), typeof( BoundsInt ),
|
typeof( Vector3Int ), typeof( Vector2Int ), typeof( RectInt ), typeof( BoundsInt ),
|
||||||
typeof( Vector3Int[] ), typeof( Vector2Int[] ), typeof( RectInt[] ), typeof( BoundsInt[] ),
|
typeof( Vector3Int[] ), typeof( Vector2Int[] ), typeof( RectInt[] ), typeof( BoundsInt[] ),
|
||||||
typeof( List<Vector3Int> ), typeof( List<Vector2Int> ), typeof( List<RectInt> ), typeof( List<BoundsInt> )
|
typeof( List<Vector3Int> ), typeof( List<Vector2Int> ), typeof( List<RectInt> ), typeof( List<BoundsInt> )
|
||||||
#endif
|
|
||||||
};
|
};
|
||||||
|
|
||||||
private static readonly string reflectionNamespace = typeof( Assembly ).Namespace;
|
private static readonly string reflectionNamespace = typeof( Assembly ).Namespace;
|
||||||
#if UNITY_2018_1_OR_NEWER
|
|
||||||
private static readonly string nativeCollectionsNamespace = typeof( NativeArray<int> ).Namespace;
|
private static readonly string nativeCollectionsNamespace = typeof( NativeArray<int> ).Namespace;
|
||||||
#endif
|
|
||||||
|
|
||||||
private static MethodInfo screenFittedRectGetter;
|
private static MethodInfo screenFittedRectGetter;
|
||||||
|
private static FieldInfo editorWindowHostViewGetter;
|
||||||
|
private static PropertyInfo hostViewContainerWindowGetter;
|
||||||
|
|
||||||
|
private static readonly Func<Object, bool, bool> prefabHasAnyOverridesGetter = (Func<Object, bool, bool>) Delegate.CreateDelegate( typeof( Func<Object, bool, bool> ), typeof( PrefabUtility ).GetMethod( "HasObjectOverride", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static ) );
|
||||||
|
|
||||||
private static readonly HashSet<string> folderContentsSet = new HashSet<string>();
|
private static readonly HashSet<string> folderContentsSet = new HashSet<string>();
|
||||||
|
|
||||||
@@ -85,12 +79,7 @@ namespace AssetUsageDetectorNamespace
|
|||||||
m_boxGUIStyle.hover.textColor = textColor;
|
m_boxGUIStyle.hover.textColor = textColor;
|
||||||
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;
|
||||||
@@ -114,6 +103,99 @@ namespace AssetUsageDetectorNamespace
|
|||||||
return obj is DefaultAsset && AssetDatabase.IsValidFolder( AssetDatabase.GetAssetPath( obj ) );
|
return obj is DefaultAsset && AssetDatabase.IsValidFolder( AssetDatabase.GetAssetPath( obj ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static T GetPrefabParent<T>( this T obj ) where T : Object
|
||||||
|
{
|
||||||
|
return PrefabUtility.GetCorrespondingObjectFromSource( obj );
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool HasAnyPrefabOverrides( this Object obj )
|
||||||
|
{
|
||||||
|
if( obj.GetPrefabParent() == null )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return prefabHasAnyOverridesGetter( obj, false );
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool HasAnyPrefabOverrides( this GameObject gameObject )
|
||||||
|
{
|
||||||
|
if( gameObject.GetPrefabParent() == null )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if( !PrefabUtility.HasPrefabInstanceAnyOverrides( gameObject, false ) )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
Transform rootTransform = gameObject.transform;
|
||||||
|
List<Component> components = new List<Component>( 8 );
|
||||||
|
Stack<Transform> stack = new Stack<Transform>( 8 );
|
||||||
|
stack.Push( rootTransform );
|
||||||
|
|
||||||
|
while( stack.Count > 0 )
|
||||||
|
{
|
||||||
|
Transform transform = stack.Pop();
|
||||||
|
Transform prefab = transform.GetPrefabParent();
|
||||||
|
if( prefab == null ) // GameObject is added as override
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if( transform.childCount != prefab.childCount ) // Has some added/destroyed children as override
|
||||||
|
return true;
|
||||||
|
|
||||||
|
bool isRootTransform = ReferenceEquals( transform, rootTransform );
|
||||||
|
if( !isRootTransform && ( transform.gameObject as Object ).HasAnyPrefabOverrides() ) // GameObject's properties are modified (e.g. name or tag) (excluding root GameObject)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
components.Clear();
|
||||||
|
transform.GetComponents( components );
|
||||||
|
foreach( Component component in components )
|
||||||
|
{
|
||||||
|
if( component == null )
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if( component.GetPrefabParent() == null ) // Component is added as override
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if( ( !isRootTransform || !( component is Transform ) ) && component.HasAnyPrefabOverrides() ) // Component is modified (excluding root Transform)
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
int componentCount = components.Count;
|
||||||
|
components.Clear();
|
||||||
|
prefab.GetComponents( components );
|
||||||
|
if( components.Count != componentCount ) // Has some destroyed components as override
|
||||||
|
return true;
|
||||||
|
|
||||||
|
for( int i = 0, childCount = transform.childCount; i < childCount; i++ )
|
||||||
|
{
|
||||||
|
Transform child = transform.GetChild( i );
|
||||||
|
if( child != null )
|
||||||
|
stack.Push( child );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if UNITY_6000_3_OR_NEWER
|
||||||
|
public static EntityId GetEntityId(this Object obj)
|
||||||
|
{
|
||||||
|
return obj.GetEntityId();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Object EntityIdToObject(EntityId entityId)
|
||||||
|
{
|
||||||
|
return EditorUtility.EntityIdToObject(entityId);
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
public static int GetEntityId(this Object obj)
|
||||||
|
{
|
||||||
|
return obj.GetInstanceID();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Object EntityIdToObject(int instanceID)
|
||||||
|
{
|
||||||
|
return EditorUtility.InstanceIDToObject(instanceID);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// Returns an enumerator to iterate through all asset paths in the folder
|
// Returns an enumerator to iterate through all asset paths in the folder
|
||||||
public static IEnumerable<string> EnumerateFolderContents( Object folderAsset )
|
public static IEnumerable<string> EnumerateFolderContents( Object folderAsset )
|
||||||
{
|
{
|
||||||
@@ -151,7 +233,6 @@ namespace AssetUsageDetectorNamespace
|
|||||||
{
|
{
|
||||||
// Pinging a prefab only works if the pinged object is the root of the prefab or a direct child of it. Pinging any grandchildren
|
// Pinging a prefab only works if the pinged object is the root of the prefab or a direct child of it. Pinging any grandchildren
|
||||||
// of the prefab doesn't work; in which case, traverse the parent hierarchy until a pingable parent is reached
|
// of the prefab doesn't work; in which case, traverse the parent hierarchy until a pingable parent is reached
|
||||||
#if UNITY_2018_3_OR_NEWER
|
|
||||||
Transform objTR = ( (GameObject) obj ).transform.root;
|
Transform objTR = ( (GameObject) obj ).transform.root;
|
||||||
|
|
||||||
PrefabAssetType prefabAssetType = PrefabUtility.GetPrefabAssetType( objTR.gameObject );
|
PrefabAssetType prefabAssetType = PrefabUtility.GetPrefabAssetType( objTR.gameObject );
|
||||||
@@ -159,11 +240,7 @@ namespace AssetUsageDetectorNamespace
|
|||||||
{
|
{
|
||||||
string assetPath = AssetDatabase.GetAssetPath( objTR.gameObject );
|
string assetPath = AssetDatabase.GetAssetPath( objTR.gameObject );
|
||||||
PrefabStage openPrefabStage = PrefabStageUtility.GetCurrentPrefabStage();
|
PrefabStage openPrefabStage = PrefabStageUtility.GetCurrentPrefabStage();
|
||||||
#if UNITY_2020_1_OR_NEWER
|
|
||||||
if( openPrefabStage != null && openPrefabStage.stageHandle.IsValid() && assetPath == openPrefabStage.assetPath )
|
if( openPrefabStage != null && openPrefabStage.stageHandle.IsValid() && assetPath == openPrefabStage.assetPath )
|
||||||
#else
|
|
||||||
if( openPrefabStage != null && openPrefabStage.stageHandle.IsValid() && assetPath == openPrefabStage.prefabAssetPath )
|
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
GameObject prefabStageGO = FollowSymmetricHierarchy( (GameObject) obj, ( (GameObject) obj ).transform.root.gameObject, openPrefabStage.prefabContentsRoot );
|
GameObject prefabStageGO = FollowSymmetricHierarchy( (GameObject) obj, ( (GameObject) obj ).transform.root.gameObject, openPrefabStage.prefabContentsRoot );
|
||||||
if( prefabStageGO != null )
|
if( prefabStageGO != null )
|
||||||
@@ -172,16 +249,15 @@ namespace AssetUsageDetectorNamespace
|
|||||||
selection = objTR.gameObject;
|
selection = objTR.gameObject;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#if UNITY_2019_1_OR_NEWER
|
|
||||||
else if( obj != objTR.gameObject )
|
else if( obj != objTR.gameObject )
|
||||||
selection = objTR.gameObject;
|
selection = objTR.gameObject;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
#else
|
else if( prefabAssetType == PrefabAssetType.Model )
|
||||||
Transform objTR = ( (GameObject) obj ).transform;
|
{
|
||||||
while( objTR.parent != null && objTR.parent.parent != null )
|
objTR = ( (GameObject) obj ).transform;
|
||||||
objTR = objTR.parent;
|
while( objTR.parent != null && objTR.parent.parent != null )
|
||||||
#endif
|
objTR = objTR.parent;
|
||||||
|
}
|
||||||
|
|
||||||
pingTarget = objTR.gameObject;
|
pingTarget = objTR.gameObject;
|
||||||
}
|
}
|
||||||
@@ -190,6 +266,11 @@ namespace AssetUsageDetectorNamespace
|
|||||||
// Can't ping assets that are hidden from Project window (e.g. animator states of AnimatorController), ping the main asset at that path instead
|
// Can't ping assets that are hidden from Project window (e.g. animator states of AnimatorController), ping the main asset at that path instead
|
||||||
pingTarget = AssetDatabase.LoadMainAssetAtPath( AssetDatabase.GetAssetPath( obj ) );
|
pingTarget = AssetDatabase.LoadMainAssetAtPath( AssetDatabase.GetAssetPath( obj ) );
|
||||||
}
|
}
|
||||||
|
else if( !AssetDatabase.IsMainAsset( obj ) && Array.IndexOf( AssetDatabase.LoadAllAssetRepresentationsAtPath( AssetDatabase.GetAssetPath( obj ) ), obj ) < 0 )
|
||||||
|
{
|
||||||
|
// VFX Graph assets' nodes are serialized as part of the graph but they are invisible in the Project window even though their hideFlags is None (I don't know how)
|
||||||
|
pingTarget = AssetDatabase.LoadMainAssetAtPath( AssetDatabase.GetAssetPath( obj ) );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -264,89 +345,15 @@ namespace AssetUsageDetectorNamespace
|
|||||||
return t1.GetSiblingIndex() - t2.GetSiblingIndex();
|
return t1.GetSiblingIndex() - t2.GetSiblingIndex();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if the field is serializable
|
|
||||||
public static bool IsSerializable( this FieldInfo fieldInfo )
|
|
||||||
{
|
|
||||||
// See Serialization Rules: https://docs.unity3d.com/Manual/script-Serialization.html
|
|
||||||
if( fieldInfo.IsInitOnly )
|
|
||||||
return false;
|
|
||||||
|
|
||||||
#if UNITY_2019_3_OR_NEWER
|
|
||||||
// SerializeReference makes even System.Object fields serializable
|
|
||||||
if( Attribute.IsDefined( fieldInfo, typeof( SerializeReference ) ) )
|
|
||||||
return true;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if( ( !fieldInfo.IsPublic || fieldInfo.IsNotSerialized ) && !Attribute.IsDefined( fieldInfo, typeof( SerializeField ) ) )
|
|
||||||
return false;
|
|
||||||
|
|
||||||
return IsTypeSerializable( fieldInfo.FieldType );
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check if the property is serializable
|
|
||||||
public static bool IsSerializable( this PropertyInfo propertyInfo )
|
|
||||||
{
|
|
||||||
return IsTypeSerializable( propertyInfo.PropertyType );
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check if type is serializable
|
|
||||||
private static bool IsTypeSerializable( Type type )
|
|
||||||
{
|
|
||||||
// see Serialization Rules: https://docs.unity3d.com/Manual/script-Serialization.html
|
|
||||||
if( typeof( Object ).IsAssignableFrom( type ) )
|
|
||||||
return true;
|
|
||||||
|
|
||||||
if( type.IsArray )
|
|
||||||
{
|
|
||||||
if( type.GetArrayRank() != 1 )
|
|
||||||
return false;
|
|
||||||
|
|
||||||
type = type.GetElementType();
|
|
||||||
|
|
||||||
if( typeof( Object ).IsAssignableFrom( type ) )
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else if( type.IsGenericType )
|
|
||||||
{
|
|
||||||
// Generic types are allowed on 2020.1 and later
|
|
||||||
#if UNITY_2020_1_OR_NEWER
|
|
||||||
if( type.GetGenericTypeDefinition() == typeof( List<> ) )
|
|
||||||
{
|
|
||||||
type = type.GetGenericArguments()[0];
|
|
||||||
|
|
||||||
if( typeof( Object ).IsAssignableFrom( type ) )
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
if( type.GetGenericTypeDefinition() != typeof( List<> ) )
|
|
||||||
return false;
|
|
||||||
|
|
||||||
type = type.GetGenericArguments()[0];
|
|
||||||
|
|
||||||
if( typeof( Object ).IsAssignableFrom( type ) )
|
|
||||||
return true;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
#if !UNITY_2020_1_OR_NEWER
|
|
||||||
if( type.IsGenericType )
|
|
||||||
return false;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return Attribute.IsDefined( type, typeof( SerializableAttribute ), false );
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check if instances of this type should be searched for references
|
// Check if instances of this type should be searched for references
|
||||||
public static bool IsIgnoredUnityType( this Type type )
|
public static bool IsIgnoredUnityType( this Type type )
|
||||||
{
|
{
|
||||||
if( type.IsPrimitive || primitiveUnityTypes.Contains( type ) || type.IsEnum )
|
if( type.IsPrimitive || primitiveUnityTypes.Contains( type ) || type.IsEnum )
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
#if UNITY_2018_1_OR_NEWER
|
|
||||||
// Searching NativeArrays for reference can throw InvalidOperationException if the collection is disposed
|
// Searching NativeArrays for reference can throw InvalidOperationException if the collection is disposed
|
||||||
if( type.Namespace == nativeCollectionsNamespace )
|
if( type.Namespace == nativeCollectionsNamespace )
|
||||||
return true;
|
return true;
|
||||||
#endif
|
|
||||||
|
|
||||||
// Searching assembly variables for reference throws InvalidCastException on .NET 4.0 runtime
|
// Searching assembly variables for reference throws InvalidCastException on .NET 4.0 runtime
|
||||||
if( typeof( Type ).IsAssignableFrom( type ) || type.Namespace == reflectionNamespace )
|
if( typeof( Type ).IsAssignableFrom( type ) || type.Namespace == reflectionNamespace )
|
||||||
@@ -405,9 +412,9 @@ namespace AssetUsageDetectorNamespace
|
|||||||
// Check if all open scenes are saved (not dirty)
|
// Check if all open scenes are saved (not dirty)
|
||||||
public static bool AreScenesSaved()
|
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 ) )
|
if( scene.isDirty || string.IsNullOrEmpty( scene.path ) )
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -435,6 +442,15 @@ namespace AssetUsageDetectorNamespace
|
|||||||
return stringBuilder.ToString();
|
return stringBuilder.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Draw header inside OnGUI
|
||||||
|
public static void DrawHeader( string label )
|
||||||
|
{
|
||||||
|
Color c = GUI.backgroundColor;
|
||||||
|
GUI.backgroundColor = AssetUsageDetectorSettings.SettingsHeaderColor;
|
||||||
|
GUILayout.Box( label, BoxGUIStyle, GL_EXPAND_WIDTH );
|
||||||
|
GUI.backgroundColor = c;
|
||||||
|
}
|
||||||
|
|
||||||
// Draw horizontal line inside OnGUI
|
// Draw horizontal line inside OnGUI
|
||||||
public static void DrawSeparatorLine()
|
public static void DrawSeparatorLine()
|
||||||
{
|
{
|
||||||
@@ -443,14 +459,25 @@ namespace AssetUsageDetectorNamespace
|
|||||||
GUILayout.Space( 4f );
|
GUILayout.Space( 4f );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Restricts the given Rect within the screen's bounds
|
/// <summary>
|
||||||
public static Rect GetScreenFittedRect( Rect originalRect )
|
/// Restricts the given Rect within the screen's bounds.
|
||||||
{
|
/// </summary>
|
||||||
if( screenFittedRectGetter == null )
|
public static Rect GetScreenFittedRect(Rect originalRect, EditorWindow editorWindow)
|
||||||
screenFittedRectGetter = typeof( EditorWindow ).Assembly.GetType( "UnityEditor.ContainerWindow" ).GetMethod( "FitRectToScreen", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static );
|
{
|
||||||
|
screenFittedRectGetter ??= typeof(EditorWindow).Assembly.GetType("UnityEditor.ContainerWindow").GetMethod("FitRectToScreen", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
|
||||||
|
|
||||||
return (Rect) screenFittedRectGetter.Invoke( null, new object[3] { originalRect, true, true } );
|
if (screenFittedRectGetter.GetParameters().Length == 3)
|
||||||
}
|
return (Rect)screenFittedRectGetter.Invoke(null, new object[] { originalRect, true, true });
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// New version introduced in Unity 2022.3.62f1, Unity 6.0.49f1 and Unity 6.1.0f1.
|
||||||
|
// Usage example: https://github.com/Unity-Technologies/UnityCsReference/blob/10f8718268a7e34844ba7d59792117c28d75a99b/Editor/Mono/EditorWindow.cs#L1264
|
||||||
|
editorWindowHostViewGetter ??= typeof(EditorWindow).GetField("m_Parent", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);
|
||||||
|
hostViewContainerWindowGetter ??= typeof(EditorWindow).Assembly.GetType("UnityEditor.HostView").GetProperty("window", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);
|
||||||
|
|
||||||
|
return (Rect)screenFittedRectGetter.Invoke(null, new object[] { originalRect, originalRect.center, true, hostViewContainerWindowGetter.GetValue(editorWindowHostViewGetter.GetValue(editorWindow), null) });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Check if all the objects inside the list are null
|
// Check if all the objects inside the list are null
|
||||||
public static bool IsEmpty( this List<ObjectToSearch> objectsToSearch )
|
public static bool IsEmpty( this List<ObjectToSearch> objectsToSearch )
|
||||||
@@ -460,7 +487,7 @@ namespace AssetUsageDetectorNamespace
|
|||||||
|
|
||||||
for( int i = 0; i < objectsToSearch.Count; i++ )
|
for( int i = 0; i < objectsToSearch.Count; i++ )
|
||||||
{
|
{
|
||||||
if( objectsToSearch[i].obj != null && !objectsToSearch[i].obj.Equals( null ) )
|
if( objectsToSearch[i].obj != null )
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -468,38 +495,20 @@ namespace AssetUsageDetectorNamespace
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check if all the objects inside the list are null
|
// Check if all the objects inside the list are null
|
||||||
public static bool IsEmpty( this List<Object> objects )
|
public static bool IsEmpty<T>( this List<T> objects ) where T : Object
|
||||||
{
|
{
|
||||||
if( objects == null )
|
if( objects == null )
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
for( int i = 0; i < objects.Count; i++ )
|
for( int i = 0; i < objects.Count; i++ )
|
||||||
{
|
{
|
||||||
if( objects[i] != null && !objects[i].Equals( null ) )
|
if( objects[i] != null )
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if all the objects that are enumerated are null
|
|
||||||
public static bool IsEmpty( this IEnumerable<Object> objects )
|
|
||||||
{
|
|
||||||
if( objects == null )
|
|
||||||
return true;
|
|
||||||
|
|
||||||
using( IEnumerator<Object> enumerator = objects.GetEnumerator() )
|
|
||||||
{
|
|
||||||
while( enumerator.MoveNext() )
|
|
||||||
{
|
|
||||||
if( enumerator.Current != null && !enumerator.Current.Equals( null ) )
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Returns true is str starts with prefix
|
// Returns true is str starts with prefix
|
||||||
public static bool StartsWithFast( this string str, string prefix )
|
public static bool StartsWithFast( this string str, string prefix )
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
using System.Text;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace AssetUsageDetectorNamespace
|
namespace AssetUsageDetectorNamespace
|
||||||
@@ -8,30 +9,27 @@ namespace AssetUsageDetectorNamespace
|
|||||||
public delegate object VariableGetVal( object obj );
|
public delegate object VariableGetVal( object obj );
|
||||||
|
|
||||||
// Custom struct to hold a variable, its important properties and its getter function
|
// Custom struct to hold a variable, its important properties and its getter function
|
||||||
public struct VariableGetterHolder
|
public readonly struct VariableGetterHolder
|
||||||
{
|
{
|
||||||
public readonly MemberInfo variable;
|
public readonly MemberInfo variable;
|
||||||
public readonly bool isSerializable;
|
|
||||||
private readonly VariableGetVal getter;
|
private readonly VariableGetVal getter;
|
||||||
|
|
||||||
public string Name { get { return variable.Name; } }
|
public readonly string Name { get { return variable.Name; } }
|
||||||
public bool IsProperty { get { return variable is PropertyInfo; } }
|
public readonly bool IsProperty { get { return variable is PropertyInfo; } }
|
||||||
|
|
||||||
public VariableGetterHolder( FieldInfo fieldInfo, VariableGetVal getter, bool isSerializable )
|
public VariableGetterHolder(FieldInfo fieldInfo, VariableGetVal getter)
|
||||||
{
|
{
|
||||||
this.variable = fieldInfo;
|
this.variable = fieldInfo;
|
||||||
this.isSerializable = isSerializable;
|
this.getter = getter;
|
||||||
this.getter = getter;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public VariableGetterHolder( PropertyInfo propertyInfo, VariableGetVal getter, bool isSerializable )
|
public VariableGetterHolder(PropertyInfo propertyInfo, VariableGetVal getter)
|
||||||
{
|
{
|
||||||
this.variable = propertyInfo;
|
this.variable = propertyInfo;
|
||||||
this.isSerializable = isSerializable;
|
this.getter = getter;
|
||||||
this.getter = getter;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public object Get( object obj )
|
public readonly object Get( object obj )
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -39,7 +37,12 @@ namespace AssetUsageDetectorNamespace
|
|||||||
}
|
}
|
||||||
catch( Exception e )
|
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;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,54 +1,4 @@
|
|||||||
= Asset Usage Detector (v2.3.0) =
|
= Asset Usage Detector (v2.6.0) =
|
||||||
|
|
||||||
Online documentation available at: https://github.com/yasirkula/UnityAssetUsageDetector
|
Documentation: https://github.com/yasirkula/UnityAssetUsageDetector
|
||||||
E-mail: yasirkula@gmail.com
|
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.
|
|
||||||
|
|
||||||
|
|
||||||
### ADDRESSABLES SUPPORT
|
|
||||||
This plugin has experimental support for Addressables package. However, the search may take significantly longer to finish when Addressables are searched. Some manual modifications are needed to enable Addressables support:
|
|
||||||
|
|
||||||
- The plugin mustn't be installed as a package, i.e. it must reside inside the Assets folder and not the Packages folder (it can reside inside a subfolder of Assets like Assets/Plugins)
|
|
||||||
- Add ASSET_USAGE_ADDRESSABLES compiler directive to "Player Settings/Scripting Define Symbols" (these symbols are platform specific, so if you change the active platform later, you'll have to add the compiler directive again)
|
|
||||||
- Add "Unity.Addressables" assembly to "AssetUsageDetector.Editor" Assembly Definition File's "Assembly Definition References" list
|
|
||||||
- Enable the "Addressables support" option in Asset Usage Detector window
|
|
||||||
|
|
||||||
|
|
||||||
### 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)
|
|
||||||
+1
-1
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "com.yasirkula.assetusagedetector",
|
"name": "com.yasirkula.assetusagedetector",
|
||||||
"displayName": "Asset Usage Detector",
|
"displayName": "Asset Usage Detector",
|
||||||
"version": "2.3.0",
|
"version": "2.6.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