I am working on a Unity C# game and I want my pause button to be GUI [with the pause and unpause image displayed on click].
Any help would be great.Thank you so much!!!
I am working on a Unity C# game and I want my pause button to be GUI [with the pause and unpause image displayed on click].
Any help would be great.Thank you so much!!!
The easiest way is to create new Button object, and add proper method for displaying correct image. Something like this:
public class ButtonStateHandler:MonoBehaviour
{
public bool isClicked;
public Button myBtn;
public Sprite Play;
public Sprite Pause;
public void Click(){
changeState();
}
private void changeState(){
isClicked = !isClicked;
if(isClicked) myBtn.image.sprite = Play;
else myBtn.image.sprite = Pause;
}
}
And then remember to add Click method in the inspector to OnClick list on Play/Pause button.