本文整理汇总了C#中UnityEngine.Color.SetValues方法的典型用法代码示例。如果您正苦于以下问题:C# Color.SetValues方法的具体用法?C# Color.SetValues怎么用?C# Color.SetValues使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UnityEngine.Color
的用法示例。
在下文中一共展示了Color.SetValues方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ColoredBox
public static GUIStyle ColoredBox(Color boxColor, int border, float alphaFalloff)
{
GUIStyle style = new GUIStyle("box");
Texture2D texture = new Texture2D(64, 64);
Color[] pixels = new Color[texture.height * texture.width];
float alpha = boxColor.a;
for (int y = 0; y < texture.height; y++) {
for (int x = 0; x < texture.width; x++) {
bool isBorder = (x < border || x > texture.width - border - 1 || y < border || y > texture.height - border - 1);
Color pixel = isBorder ? boxColor : boxColor.SetValues(boxColor / 2, Channels.RGB);
pixel.a = isBorder ? alpha : alpha * alphaFalloff;
pixels[y * texture.width + x] = pixel;
}
}
texture.SetPixels(pixels);
texture.Apply();
style.normal.background = texture;
return style;
}
示例2: Box
public static Texture2D Box(Color boxColor, int border = 1, float alphaFalloff = 1f)
{
var texture = new Texture2D(64, 64, TextureFormat.RGBA32, false);
var pixels = new Color[texture.height * texture.width];
var alpha = boxColor.a;
for (int y = 0; y < texture.height; y++)
{
for (int x = 0; x < texture.width; x++)
{
bool isBorder = (x < border || x > texture.width - border - 1 || y < border || y > texture.height - border - 1);
var pixel = isBorder ? boxColor : boxColor.SetValues(boxColor / 2, Channels.RGB);
pixel.a = isBorder ? alpha : alpha * alphaFalloff;
pixels[y * texture.width + x] = pixel;
}
}
texture.filterMode = FilterMode.Point;
texture.hideFlags = HideFlags.DontSave;
texture.SetPixels(pixels);
texture.Apply();
return texture;
}