Skip to content

Commit

Permalink
Merge pull request #782 from garakutanokiseki/feature/fix-android-can…
Browse files Browse the repository at this point in the history
…t-read-animation-sprite

Fix crash at loading AnimationSprite on Android.
  • Loading branch information
lithiumtoast committed Oct 23, 2022
2 parents 0ebbbe5 + a47e066 commit cbbec7d
Showing 1 changed file with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,17 @@ public override object ReadJson(JsonReader reader, Type objectType, object exist
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);
}
}
Expand Down

0 comments on commit cbbec7d

Please sign in to comment.