Mixing Colors

Hi there, i want to learn mixing colors. i created 3 color, 2 of em for mixing 1 of them for result.

So now i want to give 2 button and mix that colors for reach that color. i can mix colors but i cant reach that target color. its kinda like mix colors game, anyone know any solution?

public void ColorRandomizer()
    {
        rightButtonColor = new Color32( (byte)Random.Range(0, 256),
                                        (byte)Random.Range(0, 256),
                                        (byte)Random.Range(0, 256), 255);

        rightButton.GetComponent<Image>().color = rightButtonColor;

        leftButtonColor = new Color32(  (byte)Random.Range(0, 256),
                                        (byte)Random.Range(0, 256),
                                        (byte)Random.Range(0, 256), 255);

        leftButton.GetComponent<Image>().color = leftButtonColor;

        targetColor = new Color32((byte)((rightButtonColor.r + leftButtonColor.r) / 2),
                                         (byte)((rightButtonColor.g + leftButtonColor.g) / 2),
                                         (byte)((rightButtonColor.b + leftButtonColor.b)), 255);

        targetColorImage.GetComponent<Image>().color = targetColor;

        changeableColor = new Color32(0, 0, 0, 255);

        ChangeAbleImage.GetComponent<Image>().color = changeableColor;
    }
public void RightColorButton()
    {

changeableColor = new Color32((byte)(rightButtonColor.r / 10 ) ,(byte)(rightButtonColor.g / 10),(byte)(rightButtonColor.b/10), 0);


        ChangeAbleImage.GetComponent<Image>().color += changeableColor;
    }

Why are you using new Color32 (byte) instead of using new Color?

I use

 item.color = new Color(1f, 0.75f, 0.5f);

where the values within the parentheses are in RGB 0-1.0. RGB 0-255 values don’t work in code.

5278827--528972--Sans-titre-1.jpg

hi there, its working too and idk first time working with color. i can try your advice too. but the problem i cant have that random color with mixing 2 color

Sorry, I forgot about that. You can use ColorLerp to mix your two colours.

item.color = new ColorLerp(colour1, colour2, 0.5f);

that lerp can use with buttons ? i want same change with + / - buttons not automatic

Like this game

Sure. Just write a function that uses the code that APSchmidt suggested and assign that funciton to be the OnClick even handler for that button.

https://docs.unity3d.com/Manual/script-Button.html