Fix Texture2D saver in Mono and for non-readable textures

This commit is contained in:
sinaioutlander
2020-12-24 18:10:17 +11:00
parent ad7b05f721
commit 3b4ea31b50
3 changed files with 19 additions and 2 deletions

View File

@ -272,7 +272,14 @@ namespace UnityExplorer.Inspectors.Reflection
if (File.Exists(path))
File.Delete(path);
var data = tex.EncodeToPNG();
if (!tex.IsReadable())
tex = Texture2DHelpers.ForceReadTexture(tex);
#if CPP
byte[] data = tex.EncodeToPNG();
#else
byte[] data = tex.EncodeToPNGSafe();
#endif
File.WriteAllBytes(path, data);
}
});