#Copy texture file, modify and save as image.

1 messages · Page 1 of 1 (latest)

leaden pier
#

I want to take a texture, replace the colours with some colours and save the new one as a file.

My idea is

  • Copy file
  • Loop over pixels
  • Check if selected pixel colour is equal to one of the colours I wish to replace
  • if it is, replace colour
  • save file of modified texture to disk

is there unity API which lets me do this? I know there's texture2d.getpixels but I'm not sure if it lets you write. I also want to make a copy of the texture in memory so as to not mess up the original. Thanks!

unborn dawn
#

The Texture2D is already a copy of the image in the disk so you don't have to worry about messing up the original

leaden pier
unborn dawn
#

If you mean you want to make an editor extension window that does that, sure

#

If you already have the image as Texture2D, you don't have to read it from a file obviously

leaden pier
unborn dawn
#

You can construct a new one and use Graphics.CopyTexture