Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: brian661 on April 02, 2014, 08:46:44 AM

Title: Change the texture of UItexture
Post by: brian661 on April 02, 2014, 08:46:44 AM
I would like to change the texture dynamically by using something like

  1. GameObject loadedPrefab = Resources.Load("item") as GameObject;
  2. loadedPrefab.transform.GetComponent<UITexture>().mainTexture="";
  3.  


where item is a Texture widget prefab, 
My image have been add to the atlas, or inside the Asset/Resources/image folder,
how can i set it to the mainTexture?
Title: Re: Change the texture of UItexture
Post by: brian661 on April 02, 2014, 08:57:26 AM
I find the ans
  1. loadedPrefab.transform.GetComponent<UITexture>().mainTexture=Resources.Load("your texture location") as Texture;
  2.