Search code examples
c#buttonunity-game-engineunityscript

Unity - change image onClick button (C#)


I make menu for my game (Android, C#) and i have simple problem. I want change image in button when the button is pressed. What is the best way currently? Not some preset way in Unity? Thanks


Solution

  • Use button animations. They can be auto generated. Change the sprite in the button press animation manually after generation.

    Cost efficient way would be changing sprite object sprite field by getting the UI Image component in the button object from script.