if (GUI.Button(new Rect(20,435,140,70), "PNG texture",guiStyle))
{
//Texture2D texture = Resources.Load("Crate.tga") as Texture2D;
//GameObject.Find("Sphere").transform.renderer.materials.mainTexture[1]=texture;
//Object[] textures = Resources.LoadAll("Textures", typeof(Texture2D));
//WWW www = new WWW("http://l.yimg.com/rz/d/yahoo_frontpage_zh-Hant-HK_s_f_p_97.5x56_frontpage.png");
//yield return www;
//GameObject.Find("Sphere").transform.renderer.materials[1].mainTexture= www.texture;
//var filePath = Application.dataPath + "/Resources/tux.png";
//guiText.text = filePath;
//if (System.IO.File.Exists(filePath))
//{
// guiText.text += " EXISTS!!!";
// var bytes = System.IO.File.ReadAllBytes(filePath);
// var tex = new Texture2D(1, 1);
// tex.LoadImage(bytes);
//GameObject.Find("Sphere").transform.renderer.materials[0].mainTexture = tex;
//}
Object[] textures = Resources.LoadAll("Textures", typeof(Texture2D));
Texture2D texture = Resources.Load("UserInterface/Skins") as Texture2D;
GameObject.Find("Sphere").transform.renderer.materials[0].mainTexture = texture;
}
I have find a lot of method that about how to change the texture(PNG image) into the gameobject, however, i cannot make it work.Anyone can help mt to solve the problem?
btw, i can change the color of my gameObject during runtime.
Thanks!