imagination XD

realizing dream

[Unity] Taking In-Game Screenshot

1 Comment

Hello, everyone, Sorry I didn’t post something here in long time. I’m very busy, leveling up my CG skills. I also post some random unity things.

So, basically, taking screenshot in Unity is very easy. Copy this script below, and attach it in Main Camera

var folderName : String = "DCIM";
var captureSound : AudioClip;
var quality : float; //Set screenshot resolutions, default is 1. 1 equals your monitor size.
private var screenshotFader : GameObject;

function LateUpdate(){
 if(screenshotFader){ //Flashing effect
 screenshotFader.guiTexture.color.a -= Time.deltaTime;
 if(screenshotFader.guiTexture.color.a < 0){
 Destroy(screenshotFader);
 screenshotFader = null;
 }
 }
 
 if(Input.GetKeyDown("C") && !screenshotFader){
 if (!System.IO.Directory.Exists(folderName)) System.IO.Directory.CreateDirectory(folderName);
 
 screenshotFilename = folderName+"/DSC_"+System.DateTime.Now.Day.ToString()+"_"+System.DateTime.Now.Hour.ToString()+System.DateTime.Now.Minute.ToString()+System.DateTime.Now.Second.ToString()+".png";
 if(!System.IO.File.Exists(screenshotFilename)){
 Application.CaptureScreenshot(screenshotFilename,quality);
 AudioSource.PlayClipAtPoint(captureSound,transform.position);
 DrawWhiteItem();
 }
 }
}

function DrawWhiteItem(){
 yield new WaitForSeconds(0.5); //wait for a few frames so the application can capture before the white flash comes out.
 screenshotFader = DrawFader();
}

static function DrawFader() : GameObject{
 var fdt = new Texture2D(1,1);
 fdt.SetPixel(0,0,Color.white);
 fdt.Apply();
 
 var fadex = new GameObject("CSader");
 fadex.AddComponent(GUITexture);
 fadex.transform.position = Vector3(.5,.5,1000);
 fadex.guiTexture.texture = fdt;
 
 return fadex;
}

now it’ll save the screenshot on your game root folder / DCIM (you can change the folder name).

Advertisements

Author: IMGVERTEX

Started making games since 13 year old. 3D CGI Weeaboo | VFX Otaku | Anime Researcher | Indie Game Dev | VR Chuunibyou

One thought on “[Unity] Taking In-Game Screenshot

  1. I masurbarted and came to your [Unity] Taking In-Game Screenshot | imagination XD page and noticed your ass looks nice. This shit is lit mate !

FEED ME

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s