Compare commits

...

2 Commits

5 changed files with 39 additions and 13 deletions
@@ -549,9 +549,28 @@ namespace AssetUsageDetectorNamespace
{ {
StringBuilder sb = new StringBuilder( objectsToSearchSet.Count * 50 + callStack.Count * 50 + 500 ); StringBuilder sb = new StringBuilder( objectsToSearchSet.Count * 50 + callStack.Count * 50 + 500 );
sb.AppendLine( "<b>AssetUsageDetector Error:</b>" ).AppendLine().Append( e ).AppendLine(); sb.AppendLine( "<b>AssetUsageDetector Error:</b>" ).AppendLine().Append( e ).AppendLine();
Object latestUnityObjectInCallStack = null;
if( callStack.Count > 0 ) if( callStack.Count > 0 )
{ {
sb.AppendLine( "Stack contents: " ); sb.AppendLine( "Stack contents: " );
for( int i = callStack.Count - 1; i >= 0; i-- )
{
latestUnityObjectInCallStack = callStack[i] as Object;
if( latestUnityObjectInCallStack )
{
if( !AssetDatabase.Contains( latestUnityObjectInCallStack ) )
{
string scenePath = AssetDatabase.GetAssetOrScenePath( latestUnityObjectInCallStack );
if( !string.IsNullOrEmpty( scenePath ) && SceneManager.GetSceneByPath( scenePath ).IsValid() )
sb.Append( "Scene: " ).AppendLine( scenePath );
}
break;
}
}
for( int i = callStack.Count - 1; i >= 0; i-- ) for( int i = callStack.Count - 1; i >= 0; i-- )
{ {
sb.Append( i ).Append( ": " ); sb.Append( i ).Append( ": " );
@@ -575,7 +594,7 @@ namespace AssetUsageDetectorNamespace
sb.Append( obj.name ).Append( " (" ).Append( obj.GetType() ).AppendLine( ")" ); sb.Append( obj.name ).Append( " (" ).Append( obj.GetType() ).AppendLine( ")" );
} }
Debug.LogError( sb.ToString() ); Debug.LogError( sb.ToString(), latestUnityObjectInCallStack );
try try
{ {
@@ -569,6 +569,13 @@ namespace AssetUsageDetectorNamespace
} }
else else
{ {
if( controller is AnimatorOverrideController )
{
RuntimeAnimatorController parentController = ( (AnimatorOverrideController) controller ).runtimeAnimatorController;
if( objectsToSearchSet.Contains( parentController ) )
referenceNode.AddLinkTo( GetReferenceNode( parentController ) );
}
AnimationClip[] animClips = controller.animationClips; AnimationClip[] animClips = controller.animationClips;
for( int i = 0; i < animClips.Length; i++ ) for( int i = 0; i < animClips.Length; i++ )
referenceNode.AddLinkTo( SearchObject( animClips[i] ) ); referenceNode.AddLinkTo( SearchObject( animClips[i] ) );
@@ -193,7 +193,7 @@ namespace AssetUsageDetectorNamespace
private static void ShowAndSearchInternal( IEnumerable<Object> searchObjects, AssetUsageDetector.Parameters searchParameters, bool? shouldSearchChildren ) private static void ShowAndSearchInternal( IEnumerable<Object> searchObjects, AssetUsageDetector.Parameters searchParameters, bool? shouldSearchChildren )
{ {
if( mainWindow != null && !mainWindow.ReturnToSetupPhase( true ) ) if( mainWindow != null && !mainWindow.ReturnToSetupPhase( true, true ) )
{ {
Debug.LogError( "Need to reset the previous search first!" ); Debug.LogError( "Need to reset the previous search first!" );
return; return;
@@ -280,11 +280,8 @@ namespace AssetUsageDetectorNamespace
SavePrefs(); SavePrefs();
if( searchResult != null && currentPhase == Phase.Complete && !EditorApplication.isPlaying && searchResult.IsSceneSetupDifferentThanCurrentSetup() ) if( searchResult != null && currentPhase == Phase.Complete )
{ searchResult.RestoreInitialSceneSetup( true );
if( EditorUtility.DisplayDialog( "Scenes", "Restore initial scene setup?", "Yes", "Leave it as is" ) )
searchResult.RestoreInitialSceneSetup();
}
} }
private void OnFocus() private void OnFocus()
@@ -399,7 +396,7 @@ namespace AssetUsageDetectorNamespace
restoreInitialSceneSetup = EditorGUILayout.ToggleLeft( restoreInitialSceneSetupLabel, restoreInitialSceneSetup ); restoreInitialSceneSetup = EditorGUILayout.ToggleLeft( restoreInitialSceneSetupLabel, restoreInitialSceneSetup );
if( GUILayout.Button( "RETURN", Utilities.GL_HEIGHT_30 ) ) if( GUILayout.Button( "RETURN", Utilities.GL_HEIGHT_30 ) )
ReturnToSetupPhase( restoreInitialSceneSetup ); ReturnToSetupPhase( restoreInitialSceneSetup, false );
} }
else if( currentPhase == Phase.Setup ) else if( currentPhase == Phase.Setup )
{ {
@@ -561,7 +558,7 @@ namespace AssetUsageDetectorNamespace
restoreInitialSceneSetup = EditorGUILayout.ToggleLeft( restoreInitialSceneSetupLabel, restoreInitialSceneSetup ); restoreInitialSceneSetup = EditorGUILayout.ToggleLeft( restoreInitialSceneSetupLabel, restoreInitialSceneSetup );
if( GUILayout.Button( "Reset Search", Utilities.GL_HEIGHT_30 ) ) if( GUILayout.Button( "Reset Search", Utilities.GL_HEIGHT_30 ) )
ReturnToSetupPhase( restoreInitialSceneSetup ); ReturnToSetupPhase( restoreInitialSceneSetup, false );
if( searchResult == null ) if( searchResult == null )
{ {
@@ -736,9 +733,9 @@ namespace AssetUsageDetectorNamespace
} }
#endif #endif
private bool ReturnToSetupPhase( bool restoreInitialSceneSetup ) private bool ReturnToSetupPhase( bool restoreInitialSceneSetup, bool sceneSetupRestorationIsOptional )
{ {
if( searchResult != null && restoreInitialSceneSetup && !EditorApplication.isPlaying && !searchResult.RestoreInitialSceneSetup() ) if( searchResult != null && restoreInitialSceneSetup && !EditorApplication.isPlaying && !searchResult.RestoreInitialSceneSetup( sceneSetupRestorationIsOptional ) )
return false; return false;
searchResult = null; searchResult = null;
@@ -328,7 +328,7 @@ namespace AssetUsageDetectorNamespace
// Close the scenes that were not part of the initial scene setup // Close the scenes that were not part of the initial scene setup
// Returns true if initial scene setup is restored successfully // Returns true if initial scene setup is restored successfully
public bool RestoreInitialSceneSetup() public bool RestoreInitialSceneSetup( bool optional )
{ {
if( initialSceneSetup == null || initialSceneSetup.Length == 0 ) if( initialSceneSetup == null || initialSceneSetup.Length == 0 )
return true; return true;
@@ -336,6 +336,9 @@ namespace AssetUsageDetectorNamespace
if( EditorApplication.isPlaying || !EditorSceneManager.SaveCurrentModifiedScenesIfUserWantsTo() ) if( EditorApplication.isPlaying || !EditorSceneManager.SaveCurrentModifiedScenesIfUserWantsTo() )
return false; return false;
if( optional && IsSceneSetupDifferentThanCurrentSetup() && !EditorUtility.DisplayDialog( "Scenes", "Restore initial scene setup?", "Yes", "Leave it as is" ) )
return true;
for( int i = 0; i < initialSceneSetup.Length; i++ ) for( int i = 0; i < initialSceneSetup.Length; i++ )
{ {
Scene scene = EditorSceneManager.GetSceneByPath( initialSceneSetup[i].path ); Scene scene = EditorSceneManager.GetSceneByPath( initialSceneSetup[i].path );
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "com.yasirkula.assetusagedetector", "name": "com.yasirkula.assetusagedetector",
"displayName": "Asset Usage Detector", "displayName": "Asset Usage Detector",
"version": "1.8.8", "version": "1.9.0",
"description": "This editor extension helps you figure out at which places an asset or GameObject is used, i.e. lists the objects that refer to the asset. It is possible to search for references in the Assets folder (Project view) and/or in the scene(s) of your project. You can also search for references while in Play mode!" "description": "This editor extension helps you figure out at which places an asset or GameObject is used, i.e. lists the objects that refer to the asset. It is possible to search for references in the Assets folder (Project view) and/or in the scene(s) of your project. You can also search for references while in Play mode!"
} }