From d5942a66c4b6d1e088a48811db2586d33c7bba32 Mon Sep 17 00:00:00 2001 From: yasirkula Date: Sat, 4 Dec 2021 17:04:19 +0300 Subject: [PATCH] "Open X in prefab mode to select and edit Y" messages aren't spammed --- Plugins/AssetUsageDetector/Editor/Utilities.cs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/Plugins/AssetUsageDetector/Editor/Utilities.cs b/Plugins/AssetUsageDetector/Editor/Utilities.cs index ea3707e..0660e9f 100644 --- a/Plugins/AssetUsageDetector/Editor/Utilities.cs +++ b/Plugins/AssetUsageDetector/Editor/Utilities.cs @@ -242,7 +242,8 @@ namespace AssetUsageDetectorNamespace PrefabStage openPrefabStage = PrefabStageUtility.GetCurrentPrefabStage(); // Try to open the prefab stage of pinged prefabs if they are double clicked - if( previousPingedPrefabInstanceId == objTR.GetInstanceID() && EditorApplication.timeSinceStartup - previousPingedPrefabPingTime <= 0.3f && + bool previousPingedPrefabIsDoubleClicked = previousPingedPrefabInstanceId == objTR.GetInstanceID(); + if( previousPingedPrefabIsDoubleClicked && EditorApplication.timeSinceStartup - previousPingedPrefabPingTime <= 0.3f && #if UNITY_2020_1_OR_NEWER ( openPrefabStage == null || !openPrefabStage.stageHandle.IsValid() || assetPath != openPrefabStage.assetPath ) ) #else @@ -272,12 +273,17 @@ namespace AssetUsageDetectorNamespace #if UNITY_2019_1_OR_NEWER else if( obj != objTR.gameObject ) { - Debug.Log( "Open " + assetPath + " in prefab mode to select and edit " + obj.name ); + if( !previousPingedPrefabIsDoubleClicked ) // Don't spam this log unnecessarily + Debug.Log( "Open " + assetPath + " in prefab mode to select and edit " + obj.name ); + selection = objTR.gameObject; } #else else - Debug.Log( "Open " + assetPath + " in prefab mode to select and edit " + obj.name ); + { + if( !previousPingedPrefabIsDoubleClicked ) // Don't spam this log unnecessarily + Debug.Log( "Open " + assetPath + " in prefab mode to select and edit " + obj.name ); + } #endif } #else