How to change Button Color??

How can it be that something so small takes up so much time as if it were impossible to change the color of a button yourself as soon as the button was pressed? And by that I don’t mean while pressing but after pressing! The button should turn green as soon as it was pressed.
but I try this now for hours on youtube and google!

A button uses a color block, which you can overwrite to apply your changes. You need to reassign the entire color block, as you seemingly cannot just overwrite a single color in it. A similar topic is discussed here, which was by the way the first google result i got:

1 Like

Depending on exactly what effect you are trying to accomplish…

First, I should point out that you likely want to set the color of the Image component, rather than the Button component.

Second, you might want to disable the Button’s built-in transitions so that they won’t interfere with the other colors you set.

Thanks, with your link I was finally able to find the remaining parts for my puzzle of c# codes successfully.
Now I was able to successfully program a button for a test, which keeps the pressed color for 5 seconds after each time it is pressed and only becomes clickable again after the 5 seconds. For those who want to do something similar, you can enrich yourself with my code:

using System.Collections;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class test_PressedButton : MonoBehaviour
{
    // Start
    public Button button;
    private float timeRemaining = 5;
    private bool timeraktiv = false;

    public void ChangeButtonColor()
    {
        ColorBlock Farbpalette = button.colors;
        Farbpalette.selectedColor = new Color(0.6196079f, 0.4627451f, 0.8f);
        Farbpalette.highlightedColor = new Color(0.6196079f, 0.4627451f, 0.8f);
        Farbpalette.normalColor = new Color(0.6196079f, 0.4627451f, 0.8f);
        button.colors = Farbpalette;

        timeraktiv = true;
    }


    private void Update()
    {
        // Started erst den Timer, wenn der Knopf gedrueckt wurde und durch das OnClick Event der "Timeraktiv" = "true" umgestellt wird.
        if (timeRemaining >= 0 && timeraktiv == true)
        {
            timeRemaining -= Time.deltaTime;
            Debug.Log("time: " + timeRemaining);

        }

        if (timeRemaining < 0.01)
        {
            button.interactable = true;
            timeRemaining = 5;
            timeraktiv = false;

            Debug.Log("completted: " + timeRemaining);

            ColorBlock Farbpalette = button.colors;
            // Resettet die Farben wieder...
            Farbpalette.selectedColor = new Color(0.9607843f, 0.9607843f, 0.9607843f);
            Farbpalette.highlightedColor = new Color(0.9607843f, 0.9607843f, 0.9607843f);
            Farbpalette.normalColor = new Color(0.9607843f, 0.9607843f, 0.9607843f);
            button.colors = Farbpalette;
        }
    }
}
}