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.

Interactable = true doesn't change button color

Discussion in 'UGUI & TextMesh Pro' started by chainsawpenguin, May 23, 2017.

  1. chainsawpenguin

    chainsawpenguin

    Joined:
    Sep 28, 2014
    Posts:
    107
    I have a button, and it correctly knows under what conditions it is (and is not) interactable. However, when it's interactable, it is not changing the graphic on the screen. In other words, it remains "greyed out" even when it's interactable.

    Is there some other step I should take in my code to make the graphic go to normal brightness other than:


    RPGButton.interactable = true;

    ??
     
  2. Otto_Oliveira

    Otto_Oliveira

    Joined:
    Jul 24, 2014
    Posts:
    33
    I'm having the same issue, but on the opposite side. Button doesn't change to disable color state color when setting to interactable = false
     
  3. henriqueranj

    henriqueranj

    Joined:
    Feb 18, 2016
    Posts:
    173
    Check two things:
    - The color multiplication between the Image component color and the Button state color;
    - If there is a CanvasGroup component in any parent of your Button.

    Color
    Check the color scheme you are using for the Image component and the Button component.

    Button's color transition uses color multiplication to apply the color according to the state. It may be that the color you set for the Image component does not visually change when multiplied to the state color that the Button transitioned to.

    Best behaviour is to set the Image component's color to White RGBA(1,1,1,1) and set the colors you want it to look like in the Button states: Normal/Highlight/Pressed/Disabled.

    CanvasGroup

    You may have a CanvasGroup in a parent of the Button that is setting interactable to False. Therefore, all Interactable children are being disabled.
     
    ow3n, roointan and Otto_Oliveira like this.
  4. Otto_Oliveira

    Otto_Oliveira

    Joined:
    Jul 24, 2014
    Posts:
    33
    Hi Henrique,
    thanks for the tips, but it's none of above. On my case it's due I'm using an extended button component and wasn't calling a base function to get the update status of the button.

    Thanks
     
    henriqueranj likes this.
  5. diegohartmann

    diegohartmann

    Joined:
    May 25, 2019
    Posts:
    1
    Check if the 'target graphic' from the button component is the same gameobject as the button gameobject itself
     
  6. Kolichikov

    Kolichikov

    Joined:
    Jul 21, 2014
    Posts:
    16
    Thank you! I was having an issue where hovering over one button would make a different disabled button look normal, and this was the issue (I had copied the button component values).
     
  7. turbolek

    turbolek

    Joined:
    Dec 30, 2016
    Posts:
    8
    What function was it? I have the same issue. Tried base.OnInspectorGUI(); in custom editor script, but it doesn't do the trick