- Home /
I can't change a texture from assests but from HTTP
I Dont know what I'm doing wrong I can change the texture from my GameObject "targetItem" to some random picture from the Internet. But when i try to change it to the Texure "wtexture" it just turns "targetItem" white. After i declared "wtexture" a Texture object I selected via the GUI which Texture from the assets should be linked to it none of the Texture from the assets work so I guess they are not correctly linked?
Thanks in advance
var targetItem : GameObject;
var wtexture : Texture;
function OnGUI () {
if (GUI.Button (Rect (10,10,150,50), "World Texture")) {
print ("You clicked the button!");
targetItem.renderer.material.mainTexture = wtexture;
}
if (GUI.Button (Rect (320,10,150,50), "Http Texture")) {
print ("You clicked the button!");
httpTextureLoad();
}
}
function httpTextureLoad() {
var url = "http://images.zeit.de/politik/ausland/2013-02/casa-pound/casa-pound-540x304.jpg";
// Start a download of the given URL
var www : WWW = new WWW (url);
// Wait for download to complete
yield www;
// assign texture
targetItem.renderer.material.mainTexture = www.texture;
}
Comment