How to make a Button display texture as if it is clicked, based on a condition in a script?

//store normal state
Texture2D buttonBg = GUI.skin.button.normal.background;
if (/custom condition/) //set active based on condition
GUI.skin.button.normal.background = GUI.skin.button.active.background;
/* button code*/
//revert to normal state
GUI.skin.button.normal.background = buttonBg;