With the following code I make sure that the revenues image from URL:
var modys : boolean = false;
var modus : boolean = false;
private var windowRect : Rect =new Rect (Screen.width/2, 300, 220, 200);
var Text : String = "";
var TextName : String = "";
var t : TextMesh;
var nameTexture : TextMesh;
function OnMouseDown() {
modys = !modys;
}
function OnGUI () {
if(modys){
// Register the window. Notice the 3rd parameter
windowRect = GUI.Window (0, windowRect, DoMyWindow, "My Window");
}
}
// Make the contents of the window
private function DoMyWindow (windowID : int) {
GUILayout.Label("URL");
Text = GUILayout.TextField (Text, 10000);
GUILayout.Label("NameImage");
TextName = GUILayout.TextField (TextName, 10000);
if(GUILayout.Button ("Save")) {
t.text = Text;
nameTexture.text = TextName;
modys = false;
Attive();
Debug.Log(t.text);
}
if(GUILayout.Button ("Close")) {
modys = false;
}
}
function Attive() {
var url = t.text;
// Create a texture in DXT1 format
renderer.material.mainTexture = new Texture2D(4, 4, TextureFormat.DXT1, false);
// Start a download of the given URL
www = new WWW(url);
yield www;
// assign the downloaded image to the main texture of the object
www.LoadImageIntoTexture(renderer.material.mainTexture);
Debug.Log(url);
}
I would like to save the instance of the image texture, how can I do?
The system is activated by clicking on the plan that has the texture you will be asked to put a link and the name of the future texture.
Then when you insert the texture is displayed in the plan, but has not yet created a new texture, so I need to create it, so I have to make sure that you save the texture taken from the URL, and that will give him the name chosen by the user , and subsequently recall to save to that particular GameObject (the plane) that determined texture.
Help me. Thank you.