Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: armnotstrong on June 20, 2017, 05:13:10 AM

Title: Changing Color tint of UISprite runtime with NGUI
Post by: armnotstrong on June 20, 2017, 05:13:10 AM
Hi,

   I have this script to change the border tint color to red to show the error :
  1.     private void ShowErr(string errMsg)
  2.     {
  3.         gameObject.GetComponent<UIWidget>().color = Color.red;
  4.         //gameObject.GetComponent<UISprite>().color = Color.green;
  5.         transform.GetChild(0).gameObject.SetActive(true);
  6.         transform.GetChild(0).GetChild(0).GetComponent<UILabel>().text = errMsg;
  7.     }
  8.  

Have tried to set the tint color both with UIWidget and UISprite, both methods can change the color in the Inspector, but not the color in the play mode scene.

(https://i.stack.imgur.com/kl7wL.jpg)

(https://i.stack.imgur.com/8Egqy.jpg)



And I could see the color tint has been changed to red in the inspector during run time, but sprite in the scene still the origin color, What has I done wrong?
Title: Re: Changing Color tint of UISprite runtime with NGUI
Post by: ArenMook on June 27, 2017, 11:44:38 AM
Check what shader your atlas is using. It needs to be an NGUI shader (Unlit - Transparent Colored).

Which sprite is it anyway? If the sprite is entirely black, changing its color won't do anything. Black (0, 0, 0) times red (1, 0, 0) is still black.