Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: abhaya.agrawal on April 10, 2015, 01:26:13 PM

Title: I am changing the sprite image at runtime but its not changing.
Post by: abhaya.agrawal on April 10, 2015, 01:26:13 PM
When i am changing it on mouse click its changing and instantly going back to previous sprite.

this is the code i am using.

 public void Local()
    {
        localButtons.GetComponent<UISprite>().spriteName = "local_inner_shadow";
        cloudButtons.GetComponent<UISprite>().spriteName = "cloud";
    }

i also tried like this
public void Local()
    {
        UISprite sprite1 = localButtons.GetComponent<UISprite>();
        sprite1.spriteName = "local_inner_shadow";
        UISprite sprite2 = cloudButtons.GetComponent<UISprite>();
        sprite2.spriteName = "cloud";
    }

but same problem is there.
Title: Re: I am changing the sprite image at runtime but its not changing.
Post by: ArenMook on April 12, 2015, 04:32:25 PM
UIButton component will change the sprite. Do you have a button attached?
Title: Re: I am changing the sprite image at runtime but its not changing.
Post by: abhaya.agrawal on April 14, 2015, 07:16:21 PM
Yes button is attached.
Title: Re: I am changing the sprite image at runtime but its not changing.
Post by: ArenMook on April 16, 2015, 07:00:27 AM
So remove it. :P

As I said, button changes the sprite for you. If you want only color to change, use UIButtonColor instead.