简体   繁体   中英

Unity C# Change pressed sprite from button

How do I change the sprite from a button when the button is pressed? I already changed the normal sprite with: gameObject.GetComponent().sprite = Resources.Load ("MineScreenImages/" + Ge.player.ActiveDiggingTool.DiggingToolId.ToString ()+"Idle");

I already tryed finding pressedSprite or something along the lines of spriteState but it didn't work.

Try this

public Button bt;
public SpriteState st;

void Start () {
        bt.GetComponent<Image> ().sprite = newspr;
        st.pressedSprite = newspr1;
        bt.spriteState = st;
}   

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM