x


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:-

  1. Newly taken snapshot is not imported into asset immediately and it requires the Unity to refresh its assets folder and may take a while.
  2. 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); 
         }

}
more ▼

asked Jul 08 '11 at 04:58 AM

Sixakoo_ gravatar image

Sixakoo_
100 8 9 10

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

Use the WWW class using file:// prefix on the file name. Not for web player.

more ▼

answered Jul 08 '11 at 02:19 PM

DaveA gravatar image

DaveA
26.8k 153 171 257

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.

Jul 11 '11 at 05:25 AM Sixakoo_

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.

Jul 11 '11 at 07:55 AM Sixakoo_
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x2275
x1725
x222
x106
x10

asked: Jul 08 '11 at 04:58 AM

Seen: 1825 times

Last Updated: Jul 11 '11 at 08:01 AM