private static void ReplaceIfNecessary(string name, bool normalMap, bool mipmaps, bool readable, bool compressed) { if (GameDatabase.Instance.ExistsTexture(name)) { GameDatabase.TextureInfo info = GameDatabase.Instance.GetTextureInfo(name); bool isReadable = false; try { info.texture.GetPixel(0, 0); isReadable = true; } catch { } bool hasMipmaps = info.texture.mipmapCount > 0; bool isCompressed = (info.texture.format == TextureFormat.DXT1 || info.texture.format == TextureFormat.DXT5); bool isNormalMap = info.isNormalMap; if (!isReadable || (isCompressed && !compressed) || (isNormalMap != normalMap)) { //Pretty ineficient to not check beforehand, but makes the logic much simpler by simply reloading the textures. info.isNormalMap = normalMap; info.isReadable = readable; info.isCompressed = compressed; TextureConverter.Reload(info, false, default(Vector2), null, mipmaps); info.texture.name = name; } else if (isReadable != readable || isCompressed != compressed || hasMipmaps != mipmaps) { if (compressed) { info.texture.Compress(true); } info.texture.Apply(mipmaps, !readable); } } }