Hey guys,
Not sure if this is the right subforum, but I wasn’t sure where else to put it.
Basically, I’ve got an image, the pixel data of which I use to create certain objects. It’s a larger version of this one (basically a rough map of city-states of ancient Greece):

Of course, it has read/write enabled, filter mode point and compression none.
Now when I run this project straight after starting Unity, everything works as intended. On any subsequent runs, the project gave all kinds of errors. After a bit of debugging I think I’ve found the error, and frankly it baffles me. To test it, I’ve written the following code:
Texture2D map = Map.singleton.cityMap;
byte[] _bytes = map.EncodeToPNG();
System.IO.File.WriteAllBytes("testMAP.png", _bytes);
(The first line is just loading the texture, the next two lines are for testing.)
Now, after reloading the project (or, as I later found out, re-importing the texture), the resulting testMap.png looks exactly like the image above. If I run my code again without re-importing, however, testMap.png looks like this:

The image is suddenly flipped and the colours are all wrong?!
Of course, the base image is still the same.
I’ve checked my code, and nowhere do I write to that texture, in fact, the only functions/properties I use on it are GetPixel and getting its width and height. I also wrote the image to disk after calling those functions, and it makes no difference, the result is still right or wrong depending on if I re-imported it. Now why would this image only load correctly right after import? If it loads correctly the first time, and I don’t make any changes to it, why doesn’t it load correctly any subsequent times? Is there any obscure setting I might have missed? Is this a bug? Is there something else going on? ![]()
Thanks in advance for any help!