1
NGUI 3 Support / Re: Change sprite on click
« on: July 27, 2014, 09:55:41 AM »
I managed to fix it like this:
I just noticed in the new version of NGUI, the button component also has a Sprite section.
So switch the sprite in the UIButton component instead, works correctly
- IEnumerator ButtonClick()
- {
- if (PlayerPrefs.GetInt("music") == 1)
- {
- //disable music
- gameObject.GetComponent<UIButton>().normalSprite = "music-off";
- PlayerPrefs.SetInt("music", 0);
- player.mute = true;
- }
- else if (PlayerPrefs.GetInt("music") == 0)
- {
- //enable music
- gameObject.GetComponent<UIButton>().normalSprite = "music";
- PlayerPrefs.SetInt("music", 1);
- player.mute = false;
- }
- pressAnimation.PlayQueued("Button");
- //gameObject.transform.localScale = new Vector3(1, 1, 1);
- }
I just noticed in the new version of NGUI, the button component also has a Sprite section.
So switch the sprite in the UIButton component instead, works correctly


