- Home /
how can I change the source image on a UI button in JS code? HELP?
I am trying to change the source image on the UI button when i click. Can someone help me with scripting this in JS? I cannot seem to figure it out. Thanks a lot in advance.
This is where I am right now: #pragma strict var button : UnityEngine.UI.Button; var sprite : Sprite; var newsprite : Sprite;
function Start () {
}
function OnMouseUpAsButton () {
button.GetComponent<Image>()= newsprite;
}
Comment
Answer by schiuma · May 24, 2017 at 10:32 AM
function OnMouseUpAsButton () {
button.GetComponent<Image>().sprite = newsprite;
}