This question was
closed Mar 23, 2017 at 05:21 PM by
Dibbie for the following reason:
The question is answered, right answer was accepted
Question by
winathere · Mar 23, 2017 at 04:34 PM ·
unity 5spritespritesspriterenderersprite renderer
Sprite didn't change more than once
Hey. I want to make mute button for my game. Mute function is working perfectly but sprite didn't change to muted again. Here is my script :
public void MuteMessage(Object ob)
{
Mutele = MuteObj.gameObject.GetComponent<AudioSource>();
if (Mutele.mute==true)
{
Mutele.mute = false;
MuteButton.gameObject.GetComponent<SpriteRenderer>().sprite = Unmuted;
MuteButton.gameObject.GetComponent<Button>().normalIcon = Unmuted;
MuteButton.gameObject.GetComponent<Button>().hoverIcon = Unmuted;
}
else
Mutele.mute = true;
MuteButton.gameObject.GetComponent<SpriteRenderer>().sprite = Muted;
MuteButton.gameObject.GetComponent<Button>().normalIcon = Muted;
MuteButton.gameObject.GetComponent<Button>().hoverIcon = Muted;
}
Comment
Ahh my bad.. I forget to put brackets.. It's working now i'm sorry for false alarm. I'm rookie :)
Follow this Question
Related Questions
Sprites Pink After Upgrading Unity 1 Answer
Change sprite size programmatically 0 Answers
Sprite invisible in both Scene and Game view, but only in some scenes. 1 Answer
2D-Sprite Bug? 1 Answer