Author Topic: UIImage button sprite not change  (Read 2928 times)

Aastha

  • Newbie
  • *
  • Thank You
  • -Given: 2
  • -Receive: 0
  • Posts: 18
    • View Profile
UIImage button sprite not change
« on: September 18, 2013, 11:38:49 PM »
Hi,

I am new to unity and using ngui for widgets. I am changing the sprites of uiimage button on click but the problem is that hoversprite, pressedsprite and normal sprite are changing perfectly in editor but when build for device or xcode simulator the sprites are changing on second click even if the print shows correct sprite name on first click. can anyone please help me.
Here is my code:
void setButtonActiveSprite()
{
   imageButton.normalSprite = "yellowsprite";
   imageButton.hoverSprite = "yellowsprite";
   imageButton.pressedSprite = "yellowsprite";
   print (" setting active sprite "+ imageButton.normalSprite);
}

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIImage button sprite not change
« Reply #1 on: September 19, 2013, 04:21:12 PM »
Changing on second click? Eh?

Cawas

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 11
  • fucking programmer
    • View Profile
Re: UIImage button sprite not change
« Reply #2 on: September 19, 2013, 04:31:53 PM »
I'm also clueless on what's going on... Maybe you have more scripts you're not showing us or something you're not telling us.

Try doing it on a clean project. That usually helps to figure out how it works to begin with. Take a look at the NGUI's example folder. There's a lot of buttons working with hover sprites just fine there.

pahe

  • Newbie
  • *
  • Thank You
  • -Given: 2
  • -Receive: 1
  • Posts: 37
    • View Profile
Re: UIImage button sprite not change
« Reply #3 on: September 19, 2013, 05:05:54 PM »
Well, we saw some issues with broken references when you're using prefabs. We had to revert all buttons, but then it was okay again. Maybe this is a similar problem?