Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question Change the Image of a TMP Button?

Discussion in 'UGUI & TextMesh Pro' started by MindGem, Sep 3, 2023.

  1. MindGem

    MindGem

    Joined:
    May 11, 2017
    Posts:
    84
    Hi, I have a simple question.

    I would either like to change the state of a button on click (via Sprite Swap)
    or simply change the Image of the button on click.

    But I'm having problems, with the normal button it works as you would expect but with this TMP button it seems the components are different and I just can't find the documentation anywhere.

    Like changing the color of a text use to be thing.color = new color but now it took me an hour to figure out that the component of the TMP text is actually TMP_TEXT and not TEXT So i figure its something similar with this TMP Button.

    How do I do it? What's the correct component i need to access?
     
  2. wideeyenow_unity

    wideeyenow_unity

    Joined:
    Oct 7, 2020
    Posts:
    728
  3. MindGem

    MindGem

    Joined:
    May 11, 2017
    Posts:
    84
    cant find the answer in either link.

    is it not possible to set a buttons state at runtime?
     
  4. wideeyenow_unity

    wideeyenow_unity

    Joined:
    Oct 7, 2020
    Posts:
    728