public static void unloadWithoutRemoval(Texture2D tex) { for (int index = 0; index < TextureBank.textures.Count; ++index) { if (TextureBank.textures[index].tex.Equals((object)tex)) { if (TextureBank.textures[index].tex.IsDisposed) { TextureBank.textures.Remove(TextureBank.textures[index]); } else { LoadedTexture texture = TextureBank.textures[index]; --texture.retainCount; TextureBank.textures[index] = texture; break; } } } }
public static Texture2D load(string filename, ContentManager content) { for (int index = 0; index < TextureBank.textures.Count; ++index) { if (TextureBank.textures[index].path.Equals(filename)) { if (TextureBank.textures[index].tex.IsDisposed) { TextureBank.textures.Remove(TextureBank.textures[index]); } else { LoadedTexture texture = TextureBank.textures[index]; ++texture.retainCount; TextureBank.textures[index] = texture; return(texture.tex); } } } try { Texture2D texture2D = content.Load <Texture2D>(filename); TextureBank.textures.Add(new LoadedTexture() { tex = texture2D, path = filename, retainCount = 1 }); return(texture2D); } catch (Exception ex) { Console.WriteLine("File \"" + filename + "\" Experienced an Error in Loading\n" + (object)ex); return((Texture2D)null); } }