- Home /
Screenshot and use it in GUITexture Script Help
This is a working script for Cature a screenshot and save it in file
after that i create a GUITexture and put the Texture to None(Texture)
when i screenshot and save,i wanted it to display it on GUITexture>can some1 help me thx i have no idea how to write it
using UnityEngine; using System.Collections;
public class TakeScreenshot : MonoBehaviour {
private int screenshotCount = 0;
// Check for screenshot key each frame
void Update()
{
// take screenshot on up->down transition of F9 key
if (Input.GetKeyDown("k"))
{
string screenshotFilename;
do
{
screenshotCount++;
screenshotFilename = "screenshot" + screenshotCount + ".png";
} while (System.IO.File.Exists(screenshotFilename));
Application.CaptureScreenshot(screenshotFilename);
}
}
}
Answer by flamy · Jan 04, 2012 at 04:33 AM
I found a similar post have a look at this..
lol got the link and some info but i dunno how to add inthis script lolT_T
after saving the screenshot you gotta retrive tht texture using WWW class check the www class example and jus change the url to ur file's address it would give u the texture back!!?
flamy,could you pls help me with it,as i got the screenshot script above,but i doesnt know how to add in my script pls help me Thx
when i press k it will screenshot and save as adobe fireworks name (screenshot1) in
Destop>Unity3d>Assets>CharacterCustomization>CharacterCustomization
do you $$anonymous$$d help me pls or $$anonymous$$ch me step by step.Thx again
var url = "your_path_tofile";
var _texture:Texture;
function LoadTexture() {
var www : WWW = new WWW (url);
yield www;
if (www.error != null)
Debug.Log(www.error);
else
_texture = www.texture;
}
function OnGUI()
{
if(_texture!=null)
GUI.DrawTexture(Rect(0,0,512,512),_texture);
}
this is just the basic outline add some flags and change it according to ur needs :)
i try alr and its not working why?have you try?
my script here,help need see if these any things wrong
var imageName = "picture";
// Take a shot immediately
function Update ()
{
if(Input.Get$$anonymous$$eyDown($$anonymous$$eyCode.P))
{
Application.CaptureScreenshot(Application.dataPath + "/" + imageName + ".png");
LoadTexture();
}
}
var url = "C:\User\student.INSL-PC-05\Desktop\Unity3d\Assets\CharacterCustomization\CharacterCustomization\Assets\picture.png";
var _texture:Texture;
function LoadTexture() {
var www : WWW = new WWW (url);
yield www;
if (www.error != null)
Debug.Log(www.error);
else
_texture = www.texture;
}
function OnGUI()
{
if(_texture!=null)
GUI.DrawTexture(Rect(0,0,512,512),_texture);
} this script got error say that error: U with this below:
var url = "C:\User\student.INSL-PC-05\Desktop\Unity3d\Assets\CharacterCustomization\CharacterCustomization\Assets\picture.png";