Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Bug I can't change the "Normal Color" from a "Button" component.

Discussion in 'UGUI & TextMesh Pro' started by JohnnyConnor, Feb 23, 2022.

  1. JohnnyConnor


    Aug 10, 2020
    I've been searching for an answer and found a solution that appears to work for everyone but me (didn't find anyone with this problem so far): It consists of creating a ColorBlock and assigning it to the ColorBlock of your button. Then, change the normalColor from that ColorBlock and attribute the variable to your Button's ColorBlock.
    The following script is attached to my button.
    Code (CSharp):
    1. using UnityEngine;
    2. using UnityEngine.UI;
    4. public class PlayButton : MonoBehaviour
    5. {
    7.     private Button _button;
    8.     private Color _digitalGreen;
    9.     private ColorBlock _colorBlock;
    11.     private void Start()
    12.     {
    13.         _digitalGreen = new Color(12,224,9);
    14.         _button = GetComponent<Button>();
    16.         _colorBlock = _button.colors;
    17.         _colorBlock.normalColor = _digitalGreen;
    18.         _button.colors = _colorBlock;
    19.     }
    21. }
    If that's wasn't odd enough, whenever I click to edit the normal color during runtime, the color it was supposed to change into appears as selected, but the actual color is still the default one. Other colors works normally:

    The button's color only updates if I move the color selector.
    Last edited: Feb 23, 2022