- Home /
Is it possible to call texture from a ScreenShot into GUI Texture In Unity Build?
Hello,
I have a question to ask whether Unity can actually call or instantiate images recently taken from the scene itself using the "Application.CaptureScreenshot" in a Build. I've already tried inside the editor to call the images from the screenshots using the "Resources.LoadAll" code, and it worked! Except for these 2 problems:-
Newly taken snapshot is not imported into asset immediately and it requires the Unity to refresh its assets folder and may take a while.
When build player, "Resources" folder is compiled (I think) and won't call objects outside the compiled folder. The images of the screenshot is stored at the "Resources" then "Texture" folder, but doesn't work like it did inside the editor.
I already checked the path inside data folder of the build, and confirm that it's correct. I just want to make sure that it is possible to do that in Unity. Please tell me whether it's possible or not. Thank You.
Edited-
Error:
"You are trying to load data from a www stream which had the following error when downloading. Could not resolve host: C:; Host not found"
My Code:-
function Start ()
{
var go = new GameObject.CreatePrimitive(PrimitiveType.Cube);
//var Location = "http://mytutorblog.org/wp-content/uploads/2011/05/Prepare-for-a-test.jpg";
//var Location "C:\Documents and Settings\Administrator\Desktop\ScreenShot1.png"
var Location = Application.dataPath + "/Screenshots/" + "ScreenShot1.png";
go.renderer.material.mainTexture = new Texture2D(4, 4, TextureFormat.DXT1, false);
while(true)
{
// Start a download of the given URL
var www = new WWW(Location);
// wait until the download is done
yield www;
// assign the downloaded image to the main texture of the object
www.LoadImageIntoTexture(go.renderer.material.mainTexture);
}
}
Answer by DaveA · Jul 08, 2011 at 02:19 PM
Use the WWW class using file:// prefix on the file name. Not for web player.
Thanks for the answer, sorry for the late reply. I've tried using the WWW "LoadImageIntoTexture" but I got an error "You are trying to load data from a www stream which had the following error when downloading. Could not resolve host: C:; Host not found". As I have no clue how to fix this, I've include my code in the question above.
Okay, I've figured it out. I should put the file:// before the path and change all of the backslash to slash, sorry for not realizing what DaveA said earlier.
Your answer
Follow this Question
Related Questions
Dynamic Material & Textures 1 Answer
Using Screenshot as Texture 4 Answers
Sending e-mails with attachments from webplayer 1 Answer