Author Topic: Changing a button's sprite seems to disable hover color and sprite's tint  (Read 3667 times)

cdevl

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 11
    • View Profile
I'm using the latest NGUI version. I have a button that needs to change face under certain conditions. When I change a face the following occur:

1. Original button hover color does not take effect
2. Sprite's tint does not take effect. Note that without changing the face name - it works fine

Here is my code:

  1.        
  2. GameObject sprite_game_object = button_game_object.transform.FindChild("Background").gameObject;
  3. UISprite sprite = sprite_game_object.GetComponent(typeof(UISprite)) as UISprite;
  4.  
  5. sprite.color = Color.red; //this works without changing a face below
  6. sprite.spriteName = "name from Atlas"; //this changes the face but the color change above gets ignored; the hover effect on the button dissapears as well
  7. sprite.MakePixelPerfect();
  8.  
  9.  

One more thing. I've noticed that if I use a sliced image type on a sprite - after changing a face it get sized correctly. But if i use a simple image type then a new face does not get re-sized. Neither type solves the problem with tint or hover colors presented above.

If anyone has any ideas I would appreciate it greatly.
« Last Edit: June 24, 2013, 01:52:44 PM by cdevl »

cdevl

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 11
    • View Profile
Sorry. Never mind. Found my issue. The face tones were so close to black that neither hover effect nor color tint were visible. I'm stupid  :-[.