From a47e066458e8cbc77aa45bedc619be620e8cff1b Mon Sep 17 00:00:00 2001 From: garakuta Date: Wed, 10 Aug 2022 08:04:04 +0900 Subject: [PATCH] If I use AnimationSprite on Android, App happened exception 'TitleContainer.OpenStream requires a relative path' at TextureAtlasJsonConverter. MonoGame's content loader need relative path on Android. This fix is load content by relative path if happened exception. --- .../TextureAtlases/TextureAtlasJsonConverter.cs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/cs/MonoGame.Extended/TextureAtlases/TextureAtlasJsonConverter.cs b/src/cs/MonoGame.Extended/TextureAtlases/TextureAtlasJsonConverter.cs index d9b67d6d..a0177582 100644 --- a/src/cs/MonoGame.Extended/TextureAtlases/TextureAtlasJsonConverter.cs +++ b/src/cs/MonoGame.Extended/TextureAtlases/TextureAtlasJsonConverter.cs @@ -53,8 +53,17 @@ namespace MonoGame.Extended.TextureAtlases var directory = Path.GetDirectoryName(_path); var relativePath = Path.Combine(_contentManager.RootDirectory, directory, textureDirectory, textureName); var resolvedAssetName = Path.GetFullPath(relativePath); - var texture = _contentManager.Load(resolvedAssetName); - + Texture2D texture; + try + { + texture = _contentManager.Load(resolvedAssetName); + } + catch (Exception ex) { + if (textureDirectory == null || textureDirectory == "") + texture = _contentManager.Load(textureName); + else + texture = _contentManager.Load(textureDirectory + "/" + textureName); + } return TextureAtlas.Create(resolvedAssetName, texture, metadata.RegionWidth, metadata.RegionHeight); } }