Author Topic: UIButton reverts the sprite  (Read 2997 times)

kgd149

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 2
    • View Profile
UIButton reverts the sprite
« on: March 21, 2015, 05:32:47 AM »
  1. GetComponent<UISprite>().spriteName = spriteName;
  2. gameObject.SetActive(true);
  3.  

I have a disabled game object with UISprite & UIButton scripts on it. I'm setting a new sprite for it as above, but when I set it active, UIButton reverts the sprite again. Is this an intentional behaviour? Should I set both UISprite & UIButton sprites if the game object has both of them?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIButton reverts the sprite
« Reply #1 on: March 22, 2015, 08:11:03 AM »
You should be changing UIButton.normalSprite instead of setting the sprite directly. Buttons change sprites.

kgd149

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 2
    • View Profile
Re: UIButton reverts the sprite
« Reply #2 on: March 22, 2015, 12:35:24 PM »
Thanks for the solution.