Created
December 7, 2014 06:50
-
-
Save jimfleming/dcdd481ffec122f40def to your computer and use it in GitHub Desktop.
Uses an internal Unity3D utility function to grab chunks of the screen for blurring.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class GrabScreenSwatch { | |
public static Texture GrabScreenSwatch(Rect rect) { | |
int width = (int)rect.width; | |
int height = (int)rect.height; | |
int x = (int)rect.x; | |
int y = (int)rect.y; | |
Vector2 position = new Vector2(x, y); | |
Color[] pixels = UnityEditorInternal.InternalEditorUtility.ReadScreenPixel(position, width, height); | |
Texture2D texture = new Texture2D(width, height); | |
texture.SetPixels(pixels); | |
texture.Apply(); | |
return texture; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment