Hi. I’m making a game in 2019.3 (2D) Pixel art and in cert zones (triggers) i want to make saturation = 0;
Hi @dragon_script, You might check the assets store for a plugin that will do want you want to individual textures. If nothing is there, perhaps the easiest way to do this just import a grayscale version of each image and switch it out at runtime, or hide and show it.
If you don’t want to do it that way, you can find the code for a grayscale shader (do a google search on ‘unity grayscale shader’, and then switch shaders in response to your trigger (search for that too.)
and if you don’t want to do that you can actually copy all the pixels from your texture to a new texture, and retain only the gray values of each pixel. Here is a bit of code I pulled off a search that does that:
function Start () {
var texClone = Instantiate (renderer.material.mainTexture);
renderer.material.mainTexture = texClone;
MakeGrayscale (texClone);
}
function MakeGrayscale (tex : Texture2D) {
var texColors = tex.GetPixels();
for (i = 0; i < texColors.Length; i++) {
var grayValue = texColors*.grayscale;*
texColors = Color(grayValue, grayValue, grayValue, texColors*.a);*
}
tex.SetPixels(texColors);
tex.Apply();
}
So, there are lots of ways of doing it. Search around and you’ll find many that have had the same question.