Our project uses ‘Sprite Atlas V1 - Enabled For Builds’ option. If ‘Use Existing Build’ option was enabled, sometimes SpriteAtlases were missing. It seems this issue happens in not only one situation. But there is a situation that it happens reproducibly (Tested using Unity 2020.3.38 and Addressables 1.20.5):
- Build Addressables
- Restart Editor
- Enter Play Mode with ‘Use Existing Build’ enabled
- The spriteatlas will be missing and there will be a warning in the Console window: SpriteAtlasManager.atlasRequested wasn’t listened to while XXX requested. XXX is the name of the spriteatlas
I submitted a bug report for this issue: IN-15497.
Altough it seems that it’s an issue in the engine side, but there is a simple workaround for Addressables to avoid it:
.../Editor/Build/DataBuilders/BuildScriptPackedPlayMode.cs | 3 +++
1 file changed, 3 insertions(+)
diff --git a/Packages/com.unity.addressables/Editor/Build/DataBuilders/BuildScriptPackedPlayMode.cs b/Packages/com.unity.addressables/Editor/Build/DataBuilders/BuildScriptPackedPlayMode.cs
index 8405227..4a55f2a 100644
--- a/Packages/com.unity.addressables/Editor/Build/DataBuilders/BuildScriptPackedPlayMode.cs
+++ b/Packages/com.unity.addressables/Editor/Build/DataBuilders/BuildScriptPackedPlayMode.cs
@@ -82,6 +82,9 @@ namespace UnityEditor.AddressableAssets.Build.DataBuilders
if (buildLogs.RuntimeBuildLogs.Count > 0)
File.WriteAllText(buildLogsPath, JsonUtility.ToJson(buildLogs));
+ if (EditorSettings.spritePackerMode == SpritePackerMode.BuildTimeOnlyAtlas)
+ UnityEditor.U2D.SpriteAtlasUtility.PackAllAtlases(EditorUserBuildSettings.activeBuildTarget);
+
//TODO: detect if the data that does exist is out of date..
var runtimeSettingsPath = "{UnityEngine.AddressableAssets.Addressables.RuntimePath}/settings.json";
PlayerPrefs.SetString(Addressables.kAddressablesRuntimeDataPath, runtimeSettingsPath);
Hope it can help someone.