diff --git a/Assets/PerfectWorld/Scripts/Addressable/AddressableManager.cs b/Assets/PerfectWorld/Scripts/Addressable/AddressableManager.cs index 2c47a3a28d..20589903b2 100644 --- a/Assets/PerfectWorld/Scripts/Addressable/AddressableManager.cs +++ b/Assets/PerfectWorld/Scripts/Addressable/AddressableManager.cs @@ -210,6 +210,9 @@ namespace BrewMonster.Scripts if (handle.OperationException != null) { BMLogger.Log($"AddressableManager: Failed to load Prefab '{assetPath}': {handle.OperationException.Message} {handle.OperationException.StackTrace}"); + #if UNITY_EDITOR + _invalidAssetPaths.Add(assetPath); + #endif return null; } _loadedPrefabAssets[assetPath] = handle; @@ -218,6 +221,9 @@ namespace BrewMonster.Scripts catch (System.Exception e) { BMLogger.Log($"AddressableManager: Failed to load Prefab '{assetPath}': {e.Message} {e.StackTrace}"); + #if UNITY_EDITOR + _invalidAssetPaths.Add(assetPath); + #endif return null; } } @@ -367,6 +373,10 @@ namespace BrewMonster.Scripts return _loadedPrefabAssets.ContainsKey(assetPath) && _loadedPrefabAssets[assetPath].IsValid(); } + #if UNITY_EDITOR + private HashSet _invalidAssetPaths = new(); + #endif + /// /// Checks if a given Addressable key or path exists in the current catalogs. /// @@ -375,6 +385,9 @@ namespace BrewMonster.Scripts /// True if the key exists, false otherwise. public static bool KeyExists(object key, System.Type type = null) { + #if UNITY_EDITOR + return !Instance._invalidAssetPaths.Contains(key.ToString()); + #else // Iterate through all loaded locators (catalogs) foreach (IResourceLocator locator in Addressables.ResourceLocators) { @@ -390,6 +403,7 @@ namespace BrewMonster.Scripts } return false; + #endif } #endregion