From 61e8b18403e84ae9500ac8b23100c6061d625dc7 Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Fri, 24 Jul 2020 00:39:04 +0200 Subject: [PATCH] make DataTextureAtlas not crash when a non-existent texture is queried --- MLEM/Textures/DataTextureAtlas.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/MLEM/Textures/DataTextureAtlas.cs b/MLEM/Textures/DataTextureAtlas.cs index 1c746da..2317ed4 100644 --- a/MLEM/Textures/DataTextureAtlas.cs +++ b/MLEM/Textures/DataTextureAtlas.cs @@ -19,10 +19,15 @@ namespace MLEM.Textures { /// public readonly Texture2D Texture; /// - /// Returns the texture region with the given name. + /// Returns the texture region with the given name, or null if it does not exist. /// /// The region's name - public TextureRegion this[string name] => this.regions[name]; + public TextureRegion this[string name] { + get { + this.regions.TryGetValue(name, out var ret); + return ret; + } + } /// /// Returns an enumerable of all of the s in this atlas. ///