Search Unity

Trigger button click (including sprite swap) through code

Discussion in 'UGUI & TextMesh Pro' started by MeteorStudio, Mar 15, 2019.

  1. MeteorStudio

    MeteorStudio

    Joined:
    Nov 11, 2017
    Posts:
    3
    I want to give the impression of an invisible cursor pressing a UI button even when the user isn't pressing it.

    I know you can call the onClick() functions or whatever from the code. But I can't figure out how to actually make the sprite swap happen on the button. It stays in the unpressed state even while the button onClick function is called in the script. Is there any way of setting the current state of the button without manually swapping out the sprites?