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);
            }
        }
示例#2
0
        public static ScreenShotArgs GetMainCam()
        {
            var screenShotArgs = new ScreenShotArgs {
                Cam = Camera.main
            };

            return(screenShotArgs);
        }
示例#3
0
        public static ScreenShotArgs GetCurrentCam()
        {
            var screenShotArgs = new ScreenShotArgs {
                Cam = Camera.current
            };

            return(screenShotArgs);
        }
示例#4
0
 public ScreenShotArgs(ScreenShotArgs other)
 {
     Cam             = other.Cam;
     FrameHeight     = other.FrameHeight;
     FrameWidth      = other.FrameWidth;
     ClearBackground = other.ClearBackground;
     Path            = other.Path;
 }
示例#5
0
        public ScreenShotArgs GetScaledArg(int amount)
        {
            var shotArgs = new ScreenShotArgs(this);

            shotArgs.FrameWidth  *= amount;
            shotArgs.FrameHeight *= amount;
            return(shotArgs);
        }
示例#6
0
 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));
        }
示例#8
0
        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);
        }
示例#9
0
 public static void TakeScreenShot()
 {
     TakeScreenShot(ScreenShotArgs.GetMainCam());
 }
示例#10
0
 public TimelapseArgs(ScreenShotArgs args, DateTime start) : base(args)
 {
     Start = start;
 }