Question by
wrober · Aug 21, 2017 at 02:10 PM ·
unity 5imagebuttonsspriterenderer
Change Sprite/Image of Button by clicking another buttons
I am novice in unity, I tried to use this code from another post but it only worked for one image, so I got to click in one button and change the image, but if I clicked another button I changed the same image.
public Image UIImagen;
public void Start(){
UIImagen = GameObject.Fin("Image").GetComponent<Image>();
}
public void Update() {
If (Input.MouseDown(0)) {
UIImagen.sprite = Resources.Load<Sprite>("Sprite/Image1"); //
}
}
I added this script to all the buttons but changing Sprite/ImageX ... it did not work.
Also I tried to do it with gameObjects actives (true/false) but I did not work :(
gameObject.GetComponent().enabled = false;
At the beggining I thought It was a low level task but finally I could not get it :( Please find attached the image in order to clarify:
[1]: /storage/temp/100321-sin-titulo.png
Some piece of advice would be appreciate, thank you in advance!
sin-titulo.png
(9.5 kB)
Comment