Author Topic: Changing Color tint of UISprite runtime with NGUI  (Read 5082 times)

armnotstrong

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 9
    • View Profile
Changing Color tint of UISprite runtime with NGUI
« 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.







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?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Changing Color tint of UISprite runtime with NGUI
« Reply #1 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.