Beispiel #1
0
        public void TakeScreenshot(ScreenshotSettings settings, Action <Texture2D> callback)
        {
            this.settings = settings;
            this.callback = callback;

            takeScreenshot = true;
        }
Beispiel #2
0
        public static void TakeAndSave(ScreenshotSettings settings = null, bool destroyOnComplete = true)
        {
            settings = settings ?? new ScreenshotSettings();

            Take(bytes => File.WriteAllBytes(
                     Path.Combine(ScreenshotPath, settings.Name + ".png"),
                     bytes.EncodeToPNG()),
                 settings,
                 destroyOnComplete);
        }
Beispiel #3
0
        public static void Take(Action <Texture2D> callback, ScreenshotSettings settings = null, bool destroyOnComplete = true)
        {
            settings = settings ?? new ScreenshotSettings();

            if (destroyOnComplete)
            {
                callback += bytes => UnityEngine.Object.Destroy(screenshoter);
            }

            Camera camera = settings.Camera ? settings.Camera : Camera.main;

            if (!screenshoter)
            {
                screenshoter = camera.gameObject.AddComponent <Screenshoter>();
            }

            screenshoter.TakeScreenshot(settings, callback);
        }