private void TakeScreenShot() { var args = new ScreenShotArgs { FrameWidth = HighResWidth, FrameHeight = HighResHeight, Path = path, ClearBackground = isTransparent }; if (myCamera == null) { myCamera = Camera.main; } if (myCamera == null) { myCamera = UnityEngine.Object.FindObjectOfType <Camera>(); } args.Cam = myCamera; if (scale > 1) { Screenshot.TakeScreenShot(args, args.GetScaledArg(scale)); } else { Screenshot.TakeScreenShot(args); } }
public static ScreenShotArgs GetMainCam() { var screenShotArgs = new ScreenShotArgs { Cam = Camera.main }; return(screenShotArgs); }
public static ScreenShotArgs GetCurrentCam() { var screenShotArgs = new ScreenShotArgs { Cam = Camera.current }; return(screenShotArgs); }
public ScreenShotArgs(ScreenShotArgs other) { Cam = other.Cam; FrameHeight = other.FrameHeight; FrameWidth = other.FrameWidth; ClearBackground = other.ClearBackground; Path = other.Path; }
public ScreenShotArgs GetScaledArg(int amount) { var shotArgs = new ScreenShotArgs(this); shotArgs.FrameWidth *= amount; shotArgs.FrameHeight *= amount; return(shotArgs); }
public Timelapse(float waitTime, int times, ScreenShotArgs myArgs) { Start = DateTime.Now; Args = new TimelapseArgs(myArgs, Start); obj = GameObject.Find("Timelapse_OBJ"); if (obj == null) { obj = new GameObject("Timelapse_OBJ"); } WaitTime = waitTime; Times = times; obj.AddComponent <ComponentTag>().StartCoroutine(TakeImage()); }
private void TakeScreenShot() { var args = new ScreenShotArgs { FrameWidth = HighResWidth, FrameHeight = HighResHeight, Path = path, ClearBackground = isTransparent }; if (myCamera == null) { myCamera = Camera.main; } if (myCamera == null) { myCamera = Object.FindObjectOfType <Camera>(); } args.Cam = myCamera; Timelapse = new Timelapse(waitTime, times, args.GetScaledArg(scale)); }
public static void TakeScreenShot(ScreenShotArgs screenShotArgs) { CreateFolder(screenShotArgs.Path); var rt = new RenderTexture(screenShotArgs.FrameWidth, screenShotArgs.FrameHeight, 24); screenShotArgs.Cam.targetTexture = rt; var tFormat = screenShotArgs.ClearBackground? TextureFormat.ARGB32 : TextureFormat.RGB24; var screenShot = new Texture2D(screenShotArgs.FrameWidth, screenShotArgs.FrameHeight, tFormat, false); screenShotArgs.Cam.Render(); RenderTexture.active = rt; screenShot.ReadPixels(new Rect(0, 0, screenShotArgs.FrameWidth, screenShotArgs.FrameHeight), 0, 0); screenShotArgs.Cam.targetTexture = null; RenderTexture.active = null; var bytes = screenShot.EncodeToPNG(); var filename = screenShotArgs.GetFullFileName(); File.WriteAllBytes(filename, bytes); }
public static void TakeScreenShot() { TakeScreenShot(ScreenShotArgs.GetMainCam()); }
public TimelapseArgs(ScreenShotArgs args, DateTime start) : base(args) { Start = start; }