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).