Skip to content

Instantly share code, notes, and snippets.

@rafayali
Last active August 29, 2015 14:12
Show Gist options
  • Save rafayali/54dc3680ed859be74aa2 to your computer and use it in GitHub Desktop.
Save rafayali/54dc3680ed859be74aa2 to your computer and use it in GitHub Desktop.
Converts a color into a Texture2D format which can be written to a file or can be used as a regular texture
private Texture2D MakeTex(int width, int height, Color col)
{
Color[] pix = new Color[width * height];
for( int i = 0; i < pix.Length; ++i )
{
pix[ i ] = col;
}
Texture2D result = new Texture2D( width, height );
result.SetPixels( pix );
result.Apply();
return result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment