UnityEditor.ScreenShots.SaveScreenShotWithBorder C# (CSharp) Method

SaveScreenShotWithBorder() public static method

public static SaveScreenShotWithBorder ( Rect r, Color borderColor, string name ) : string
r UnityEngine.Rect
borderColor Color
name string
return string
        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 i = 0; i < width; i++)
            {
                for (int m = 0; m < height; m++)
                {
                    pixels[(i + 1) + ((width + 2) * (m + 1))] = colorArray[i + (width * m)];
                }
            }
            for (int j = 0; j < (width + 2); j++)
            {
                pixels[j] = borderColor;
                pixels[j + ((width + 2) * (height + 1))] = borderColor;
            }
            for (int k = 0; k < (height + 2); k++)
            {
                pixels[k * (width + 2)] = borderColor;
                pixels[(k * (width + 2)) + (width + 1)] = borderColor;
            }
            return SaveScreenShot((int) (r.width + 2f), (int) (r.height + 2f), pixels, name);
        }

Usage Example

示例#1
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");
 }
All Usage Examples Of UnityEditor.ScreenShots::SaveScreenShotWithBorder