Help!
I’m trying to figure out what the correct datapath and everything is for using www.Texture to import a .png from the local project folder, and using it as a texture. I can’t find any reference for this on the Unity website–it only states how to load things from the web. When I attempt to do this on my own, it works, but I get a data path error first. Do you know how?
My script, in case you’re interested, is this:
var filePath;
function Start()
{
filePath = "myScreenshot.png";
print(filePath);
}
// Take a shot immediately
function Update ()
{
if(Input.GetKeyDown(KeyCode.P))
{
turnScreenShotIntoTexture();
}
}
function turnScreenShotIntoTexture()
{
yield WaitForEndOfFrame;
Application.CaptureScreenshot("file:\\" + Application.dataPath + filePath);
var www : WWW = new WWW (filePath);
yield www;
myTexture =
renderer.material.mainTexture = www.texture;
}