I have been able to tint a texture using SetPixels:
public Color tintColor;
Color[] texturaBasePixels;
Color[] texturaPixels;
void Start () {
texturaBasePixels = texturaBase.GetPixels();
texturaPixels = textura.GetPixels();
for (int i = 0; i < texturaPixels.Length; i++) {
texturaPixels_.r = texturaBasePixels*.r - (1.0f - tintColor.r);*_
texturaPixels_.g = texturaBasePixels*.g - (1.0f - tintColor.g);
texturaPixels.b = texturaBasePixels.b - (1.0f - tintColor.b);
}
textura.SetPixels(texturaPixels);
textura.Apply();
}
I want to use SetPixels32 because it’s faster, but I’m getting weird colors:
public Color tintColor;
Color32[] texturaBasePixels;
Color32[] texturaPixels;
void Start () {
texturaBasePixels = texturaBase.GetPixels32();
texturaPixels = textura.GetPixels32();
for (int i = 0; i < texturaPixels.Length; i++) {
texturaPixels.r = (byte)((int)texturaBasePixels.r - (255 - (int)tintColor.r));
texturaPixels.g = (byte)((int)texturaBasePixels.g - (255 - (int)tintColor.g));
texturaPixels.b = (byte)((int)texturaBasePixels.b - (255 - (int)tintColor.b));
}
textura.SetPixels32(texturaPixels);
textura.Apply();
}*
What am I doing wrong?_