Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: cdevl on June 24, 2013, 12:19:03 PM

Title: Changing a button's sprite seems to disable hover color and sprite's tint
Post by: cdevl on June 24, 2013, 12:19:03 PM
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.
Title: Re: Changing a button's sprite seems to disable hover color and sprite's tint
Post by: cdevl on June 25, 2013, 07:24:24 AM
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  :-[.