mirror of
https://github.com/AlexMacocian/MonoGame.Extended.git
synced 2026-07-15 23:19:29 +00:00
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.
This commit is contained in:
@@ -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<Texture2D>(resolvedAssetName);
|
||||
|
||||
Texture2D texture;
|
||||
try
|
||||
{
|
||||
texture = _contentManager.Load<Texture2D>(resolvedAssetName);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
if (textureDirectory == null || textureDirectory == "")
|
||||
texture = _contentManager.Load<Texture2D>(textureName);
|
||||
else
|
||||
texture = _contentManager.Load<Texture2D>(textureDirectory + "/" + textureName);
|
||||
}
|
||||
return TextureAtlas.Create(resolvedAssetName, texture, metadata.RegionWidth, metadata.RegionHeight);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user