Hi, I have a function that takes a screenshot of the main camera’s view. These screens are then saved to a folder in the root of my project. I was wondering how I would then take that screenshot, add it to a variable in code and add that to an array so I can call the image up and display it on screen. I have the display part sorted but I’m not sure how to access the file and add it to the array. I’m using Application.CaptureScreenshot, any help would be appreciated
The easiest way to solve your problem is to use Unity’s WWW class to load the file. You just specify a local file. Typically using the WWW class, your code yields, but given the load of a local file you may be able to get away with polling the ‘isDone’ flag. It depends on the number of images and load times of each image:
#pragma strict
var path = "file://e:/AngleAxis.jpg";
function Update () {
if (Input.GetKeyDown(KeyCode.Space)) {
renderer.material.mainTexture = LoadImage(path);
}
}
function LoadImage(name : String) : Texture {
var www = new WWW(path);
while (!www.isDone);
return www.texture;
}