Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Question More target graphics on one Button? TMPro

Discussion in 'UGUI & TextMesh Pro' started by MartinMa_, Aug 7, 2021.

  1. MartinMa_


    Jan 3, 2021
    Hello guys can you please help me.

    I have Button script with 2 assignable variables , text and image.

    If this button is not interactable then i can set different color for text , but how can i set this also for image?
    I tried set alpha for <Image> but that is not working.

    I am using TMPro and on button i only can set targetable graphic for one item so i set it for text.

    Screens attached

    I want both text and image have lower alpha when button is not interactable.
    I think what i need is to be able to set more button "Target graphics" for one button.

    Thanks for help.

    Attached Files:

    Last edited: Aug 7, 2021
  2. GroZZleR


    Feb 1, 2015
    I don't think it's possible in the default button implementation. Write a little mini-component that matches another target graphic's alpha in LateUpdate, or extend your own Button class and override the functionality as needed.
  3. MartinMa_


    Jan 3, 2021
    Thanks for reply but i am not rly sure what do you mean by "override the functionality as needed" you mean edit TMP button component somehow?I

    EDIT : I found way how to do it i just get color from that interactable color for text target and use it for image and it is working.For some reason it wasnt working for me before but it is working now i probably made some mystake before.

    Code (CSharp):
    1. Button thisButton;
    2. public Image butImage;
    3. if(butImage != null&& !thisButton.interactable)
    4.             {
    5.                 butImage.color = thisButton.colors.disabledColor;
    6.             }
    Last edited: Aug 8, 2021