Skip to content

Commit

Permalink
Refactor to use TryGetRegion
Browse files Browse the repository at this point in the history
  • Loading branch information
AristurtleDev committed Aug 28, 2024
1 parent 8ff62a6 commit 1ead57b
Showing 1 changed file with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,14 @@ public TextureRegionService()

public Texture2DRegion GetTextureRegion(string name)
{
return TextureAtlases
.Select(textureAtlas => textureAtlas.GetRegion(name))
.FirstOrDefault(region => region != null);
foreach (Texture2DAtlas atlas in TextureAtlases)
{
if (atlas.TryGetRegion(name, out Texture2DRegion region))
{
return region;
}
}
return null;
}
}
}

0 comments on commit 1ead57b

Please sign in to comment.