private static CreateColorSwatchWithBorder ( int width, int height, bool triangular ) : |
||
width | int | |
height | int | |
triangular | bool | |
Результат |
private static Texture2D CreateColorSwatchWithBorder(int width, int height, bool triangular)
{
Texture2D textured = new Texture2D(width, height, TextureFormat.RGBA32, false) {
hideFlags = HideFlags.HideAndDontSave
};
Color[] colors = new Color[width * height];
Color color = new Color(1f, 1f, 1f, 0f);
if (triangular)
{
for (int n = 0; n < height; n++)
{
for (int num2 = 0; num2 < width; num2++)
{
if (n < (width - num2))
{
colors[num2 + (n * width)] = Color.white;
}
else
{
colors[num2 + (n * width)] = color;
}
}
}
}
else
{
for (int num3 = 0; num3 < (height * width); num3++)
{
colors[num3] = Color.white;
}
}
for (int i = 0; i < width; i++)
{
colors[i] = Color.black;
}
for (int j = 0; j < width; j++)
{
colors[((height - 1) * width) + j] = Color.black;
}
for (int k = 0; k < height; k++)
{
colors[k * width] = Color.black;
}
for (int m = 0; m < height; m++)
{
colors[((m * width) + width) - 1] = Color.black;
}
textured.SetPixels(colors);
textured.Apply();
return textured;
}
private void Init() { if (this.m_ColorSwatch == null) { this.m_ColorSwatch = ColorPresetLibrary.CreateColorSwatchWithBorder(14, 14, false); } if (this.m_ColorSwatchTriangular == null) { this.m_ColorSwatchTriangular = ColorPresetLibrary.CreateColorSwatchWithBorder(14, 14, true); } if (this.m_MiniColorSwatchTriangular == null) { this.m_MiniColorSwatchTriangular = ColorPresetLibrary.CreateColorSwatchWithBorder(8, 8, true); } if (this.m_CheckerBoard == null) { this.m_CheckerBoard = GradientEditor.CreateCheckerTexture(2, 2, 3, new Color(0.8f, 0.8f, 0.8f), new Color(0.5f, 0.5f, 0.5f)); } }