mirror of
https://github.com/yasirkula/UnityAssetUsageDetector.git
synced 2026-11-19 14:32:37 +08:00
While using the Search for References button in right-click menu, if current scene setup is different from the initial scene setup, plugin now asks user whether or not they want to restore the initial scene setup instead of automatically restoring the initial scene setup
This commit is contained in:
@@ -549,9 +549,28 @@ namespace AssetUsageDetectorNamespace
|
||||
{
|
||||
StringBuilder sb = new StringBuilder( objectsToSearchSet.Count * 50 + callStack.Count * 50 + 500 );
|
||||
sb.AppendLine( "<b>AssetUsageDetector Error:</b>" ).AppendLine().Append( e ).AppendLine();
|
||||
|
||||
Object latestUnityObjectInCallStack = null;
|
||||
if( callStack.Count > 0 )
|
||||
{
|
||||
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-- )
|
||||
{
|
||||
sb.Append( i ).Append( ": " );
|
||||
@@ -575,7 +594,7 @@ namespace AssetUsageDetectorNamespace
|
||||
sb.Append( obj.name ).Append( " (" ).Append( obj.GetType() ).AppendLine( ")" );
|
||||
}
|
||||
|
||||
Debug.LogError( sb.ToString() );
|
||||
Debug.LogError( sb.ToString(), latestUnityObjectInCallStack );
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
@@ -193,7 +193,7 @@ namespace AssetUsageDetectorNamespace
|
||||
|
||||
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!" );
|
||||
return;
|
||||
@@ -280,11 +280,8 @@ namespace AssetUsageDetectorNamespace
|
||||
|
||||
SavePrefs();
|
||||
|
||||
if( searchResult != null && currentPhase == Phase.Complete && !EditorApplication.isPlaying && searchResult.IsSceneSetupDifferentThanCurrentSetup() )
|
||||
{
|
||||
if( EditorUtility.DisplayDialog( "Scenes", "Restore initial scene setup?", "Yes", "Leave it as is" ) )
|
||||
searchResult.RestoreInitialSceneSetup();
|
||||
}
|
||||
if( searchResult != null && currentPhase == Phase.Complete )
|
||||
searchResult.RestoreInitialSceneSetup( true );
|
||||
}
|
||||
|
||||
private void OnFocus()
|
||||
@@ -399,7 +396,7 @@ namespace AssetUsageDetectorNamespace
|
||||
restoreInitialSceneSetup = EditorGUILayout.ToggleLeft( restoreInitialSceneSetupLabel, restoreInitialSceneSetup );
|
||||
|
||||
if( GUILayout.Button( "RETURN", Utilities.GL_HEIGHT_30 ) )
|
||||
ReturnToSetupPhase( restoreInitialSceneSetup );
|
||||
ReturnToSetupPhase( restoreInitialSceneSetup, false );
|
||||
}
|
||||
else if( currentPhase == Phase.Setup )
|
||||
{
|
||||
@@ -561,7 +558,7 @@ namespace AssetUsageDetectorNamespace
|
||||
restoreInitialSceneSetup = EditorGUILayout.ToggleLeft( restoreInitialSceneSetupLabel, restoreInitialSceneSetup );
|
||||
|
||||
if( GUILayout.Button( "Reset Search", Utilities.GL_HEIGHT_30 ) )
|
||||
ReturnToSetupPhase( restoreInitialSceneSetup );
|
||||
ReturnToSetupPhase( restoreInitialSceneSetup, false );
|
||||
|
||||
if( searchResult == null )
|
||||
{
|
||||
@@ -736,9 +733,9 @@ namespace AssetUsageDetectorNamespace
|
||||
}
|
||||
#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;
|
||||
|
||||
searchResult = null;
|
||||
|
||||
@@ -328,7 +328,7 @@ namespace AssetUsageDetectorNamespace
|
||||
|
||||
// Close the scenes that were not part of the initial scene setup
|
||||
// Returns true if initial scene setup is restored successfully
|
||||
public bool RestoreInitialSceneSetup()
|
||||
public bool RestoreInitialSceneSetup( bool optional )
|
||||
{
|
||||
if( initialSceneSetup == null || initialSceneSetup.Length == 0 )
|
||||
return true;
|
||||
@@ -336,6 +336,9 @@ namespace AssetUsageDetectorNamespace
|
||||
if( EditorApplication.isPlaying || !EditorSceneManager.SaveCurrentModifiedScenesIfUserWantsTo() )
|
||||
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++ )
|
||||
{
|
||||
Scene scene = EditorSceneManager.GetSceneByPath( initialSceneSetup[i].path );
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "com.yasirkula.assetusagedetector",
|
||||
"displayName": "Asset Usage Detector",
|
||||
"version": "1.8.9",
|
||||
"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!"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user