Beispiel #1
0
        public static void ScreenGameViewContent()
        {
            string uniquePathForName = ScreenShots.GetUniquePathForName("ContentExample");

            Application.CaptureScreenshot(uniquePathForName);
            Debug.Log(string.Format("Saved screenshot at {0}", uniquePathForName));
        }
Beispiel #2
0
        public static string SaveScreenShotWithBorder(Rect r, Color borderColor, string name)
        {
            int num  = (int)r.width;
            int num2 = (int)r.height;

            Color[] array  = InternalEditorUtility.ReadScreenPixel(new Vector2(r.x, r.y), num, num2);
            Color[] array2 = new Color[(num + 2) * (num2 + 2)];
            for (int i = 0; i < num; i++)
            {
                for (int j = 0; j < num2; j++)
                {
                    array2[i + 1 + (num + 2) * (j + 1)] = array[i + num * j];
                }
            }
            for (int k = 0; k < num + 2; k++)
            {
                array2[k] = borderColor;
                array2[k + (num + 2) * (num2 + 1)] = borderColor;
            }
            for (int l = 0; l < num2 + 2; l++)
            {
                array2[l * (num + 2)]             = borderColor;
                array2[l * (num + 2) + (num + 1)] = borderColor;
            }
            return(ScreenShots.SaveScreenShot((int)(r.width + 2f), (int)(r.height + 2f), array2, name));
        }
Beispiel #3
0
 public static void ScreenShotComponent(Rect contentRect, UnityEngine.Object target)
 {
     ScreenShots.s_TakeComponentScreenshot = false;
     contentRect.yMax += 2f;
     contentRect.xMin += 1f;
     ScreenShots.SaveScreenShotWithBorder(contentRect, ScreenShots.kWindowBorderColor, target.GetType().Name + "Inspector");
 }
        public static string SaveScreenShotWithBorder(Rect r, Color borderColor, string name)
        {
            int width  = (int)r.width;
            int height = (int)r.height;

            Color[] colorArray = InternalEditorUtility.ReadScreenPixel(new Vector2(r.x, r.y), width, height);
            Color[] pixels     = new Color[(width + 2) * (height + 2)];
            for (int index1 = 0; index1 < width; ++index1)
            {
                for (int index2 = 0; index2 < height; ++index2)
                {
                    pixels[index1 + 1 + (width + 2) * (index2 + 1)] = colorArray[index1 + width * index2];
                }
            }
            for (int index = 0; index < width + 2; ++index)
            {
                pixels[index] = borderColor;
                pixels[index + (width + 2) * (height + 1)] = borderColor;
            }
            for (int index = 0; index < height + 2; ++index)
            {
                pixels[index * (width + 2)] = borderColor;
                pixels[index * (width + 2) + (width + 1)] = borderColor;
            }
            return(ScreenShots.SaveScreenShot((int)((double)r.width + 2.0), (int)((double)r.height + 2.0), pixels, name));
        }
Beispiel #5
0
        public static void Screenshot()
        {
            GUIView mouseOverView = ScreenShots.GetMouseOverView();

            if (mouseOverView != null)
            {
                string gUIViewName    = ScreenShots.GetGUIViewName(mouseOverView);
                Rect   screenPosition = mouseOverView.screenPosition;
                screenPosition.y      -= 1f;
                screenPosition.height += 2f;
                ScreenShots.SaveScreenShot(screenPosition, gUIViewName);
            }
        }
Beispiel #6
0
        public static void ScreenshotToolbar()
        {
            GUIView mouseOverView = ScreenShots.GetMouseOverView();

            if (mouseOverView != null)
            {
                string name           = ScreenShots.GetGUIViewName(mouseOverView) + "Toolbar";
                Rect   screenPosition = mouseOverView.screenPosition;
                screenPosition.y     += 19f;
                screenPosition.height = 16f;
                screenPosition.width -= 2f;
                ScreenShots.SaveScreenShotWithBorder(screenPosition, ScreenShots.kToolbarBorderColor, name);
            }
        }
Beispiel #7
0
        private static string SaveScreenShot(int width, int height, Color[] pixels, string name)
        {
            Texture2D texture2D = new Texture2D(width, height);

            texture2D.SetPixels(pixels, 0);
            texture2D.Apply(true);
            byte[] bytes = texture2D.EncodeToPNG();
            UnityEngine.Object.DestroyImmediate(texture2D, true);
            string uniquePathForName = ScreenShots.GetUniquePathForName(name);

            File.WriteAllBytes(uniquePathForName, bytes);
            Debug.Log(string.Format("Saved screenshot at {0}", uniquePathForName));
            return(uniquePathForName);
        }
Beispiel #8
0
        public static void ScreenshotExtendedRight()
        {
            GUIView mouseOverView = ScreenShots.GetMouseOverView();

            if (mouseOverView != null)
            {
                string     name           = ScreenShots.GetGUIViewName(mouseOverView) + "Extended";
                MainWindow mainWindow     = Resources.FindObjectsOfTypeAll(typeof(MainWindow))[0] as MainWindow;
                Rect       screenPosition = mouseOverView.screenPosition;
                screenPosition.xMax    = mainWindow.window.position.xMax;
                screenPosition.y      -= 1f;
                screenPosition.height += 2f;
                ScreenShots.SaveScreenShot(screenPosition, name);
            }
        }
        public static void Screenshot()
        {
            GUIView mouseOverView = ScreenShots.GetMouseOverView();

            if (!((Object)mouseOverView != (Object)null))
            {
                return;
            }
            string guiViewName    = ScreenShots.GetGUIViewName(mouseOverView);
            Rect   screenPosition = mouseOverView.screenPosition;

            --screenPosition.y;
            screenPosition.height += 2f;
            ScreenShots.SaveScreenShot(screenPosition, guiViewName);
        }
Beispiel #10
0
 public static void SaveScreenShot(Rect r, string name)
 {
     ScreenShots.SaveScreenShot((int)r.width, (int)r.height, InternalEditorUtility.ReadScreenPixel(new Vector2(r.x, r.y), (int)r.width, (int)r.height), name);
 }