From aafe336aec8831c911be6802e0b678a46c036edf Mon Sep 17 00:00:00 2001 From: Le Duc Anh Date: Mon, 4 May 2026 11:22:08 +0700 Subject: [PATCH] fix the issue to load addressable on Editor --- .../Scripts/Addressable/AddressableManager.cs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) 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