本文整理汇总了C#中UnityEngine.Color32类的典型用法代码示例。如果您正苦于以下问题:C# Color32类的具体用法?C# Color32怎么用?C# Color32使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Color32类属于UnityEngine命名空间,在下文中一共展示了Color32类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetColor
public static void SetColor(this Slot slot, Color32 color)
{
slot.A = color.a / 255f;
slot.R = color.r / 255f;
slot.G = color.g / 255f;
slot.B = color.b / 255f;
}
示例2: WriteRgbaColor
public void WriteRgbaColor(Color32 color)
{
Write(color.r);
Write(color.g);
Write(color.b);
Write(color.a);
}
示例3: SerializedParticle
public SerializedParticle (Vector3 position,
Vector3 velocity,
float rotation,
float size,
float lifetime,
float startLifetime,
float playgroundLife,
float playgroundStartLifetime,
float playgroundEndLifetime,
float playgroundLifetimeSubtraction,
Color32 color,
Vector3 sourcePosition,
float startingSize
)
{
this.position = position;
this.velocity = velocity;
this.rotation = rotation;
this.size = size;
this.lifetime = lifetime;
this.startLifetime = startLifetime;
this.playgroundLife = playgroundLife;
this.playgroundStartLifetime = playgroundStartLifetime;
this.playgroundEndLifetime = playgroundEndLifetime;
this.playgroundLifetimeSubtraction = playgroundLifetimeSubtraction;
this.color = color;
this.sourcePosition = sourcePosition;
this.startingSize = startingSize;
}
示例4: drawBoxAt
public void drawBoxAt(int leftSideX, int topSideY, int dimW, int dimH, Color32 useCol)
{
int left = leftSideX;
int right = left+dimW;
int top = topSideY;
int bot = topSideY+dimH;
if(left < 0) {
left = 0;
}
if(top < 0) {
top = 0;
}
if(right > screenWidth) {
right = screenWidth;
}
if(bot > screenHeight) {
bot = screenHeight;
}
for(int xp=left; xp <right; xp++) {
for(int yp=top; yp <bot; yp++) {
// paintThis.SetPixel(xp,yp,useCol);
setBufferPixel(xp,yp,useCol);
}
}
}
示例5: ColorLerpUnclamped
/// <summary>Lerps from one colour to another.</summary>
private static Color32 ColorLerpUnclamped(Color32 c1,Color32 c2,float value){
return new Color32 ((byte)(c1.r + (c2.r - c1.r)*value),
(byte)(c1.g + (c2.g - c1.g)*value),
(byte)(c1.b + (c2.b - c1.b)*value),
(byte)(c1.a + (c2.a - c1.a)*value)
);
}
示例6: mBlock
public mBlock(Color32 color)
{
this.r = color.r;
this.g = color.g;
this.b = color.b;
solid = true;
}
示例7: rgbToHsv
public static HSVColor rgbToHsv(Color32 color)
{
HSVColor result=new HSVColor();
float min,max,delta;
float r = (float)color.r/255.0f;
float g = (float)color.g/255.0f;
float b = (float)color.b/255.0f;
min = Mathf.Min(r,g,b);
max = Mathf.Max(r,g,b);
result.v = max;
delta = max - min;
if( max != 0 )
result.s = delta / max; // s
else {
// r = g = b = 0 // s = 0, v is undefined
result.s = 0;
result.h = -1;
return result;
}
if( r == max )
result.h = ( g - b ) / delta; // between yellow & magenta
else if( g == max )
result.h = 2 + ( b - r ) / delta; // between cyan & yellow
else
result.h = 4 + ( r - g ) / delta; // between magenta & cyan
result.h *= 60; // degrees
if( result.h < 0 )
result.h += 360;
result.h /=360;
return result;
}
示例8: Set
public void Set(int index, Color32 color)
{
components[index + 0] = color.r;
components[index + 1] = color.g;
components[index + 2] = color.b;
components[index + 3] = color.a;
}
示例9: Slot
//TODO probably can delete it
public Slot (string bone, string slot, string attachment = null, Color32? color = null)
{
this.bone = bone;
this.name = slot;
this.defaultAttachmentName = attachment;
this.color = color;
}
示例10: Update
// Update is called once per frame
void Update()
{
float TimePassed = (Time.time - TimeStarted) / FadeTime;
int FadeValue;
int StartValue = 255;
int EndValue = 0;
if (!IsForward) {
StartValue = 0;
EndValue = 255;
}
FadeValue = Mathf.RoundToInt (Mathf.Lerp (StartValue, EndValue, TimePassed));
Color32 NewBackgroundColor = new Color32(MyBackgroundColor.r,MyBackgroundColor.g,MyBackgroundColor.b,
(byte)(FadeValue));
gameObject.GetComponent<Renderer> ().material.color = NewBackgroundColor;
//Time.timeScale = 0;
if (FadeValue == EndValue) {
if (IsForward) {
//Time.timeScale = 1;
gameObject.SetActive (false);
} else {
TimeStarted = Time.time+TimeDelay;
IsForward = true;
}
}
}
示例11: NoiseTexture
void NoiseTexture(int size, bool mono)
{
var path = EditorUtility.SaveFilePanel("Save Noise Texture", "Assets", "noise" + size, "png");
if (path != "") {
var tex = new Texture2D(size, size, TextureFormat.ARGB32, false);
var s2 = size * size;
var cols = new Color32[s2];
for (int i = 0; i < s2; ++i) {
if (mono) {
var r = (byte)Random.Range(0, 256);
cols[i] = new Color32(r, r, r, 255);
}
else {
cols[i] = new Color32((byte)Random.Range(0, 256), (byte)Random.Range(0, 256), (byte)Random.Range(0, 256), 255);
}
}
tex.SetPixels32(cols);
tex.Apply();
System.IO.File.WriteAllBytes(path, tex.EncodeToPNG());
AssetDatabase.Refresh();
Object.DestroyImmediate(tex);
path = "Assets" + path.Remove(0, Application.dataPath.Length);
// tex = (Texture2D)AssetDatabase.LoadAssetAtPath(path, typeof(Texture2D));
TextureImporter textureImporter = AssetImporter.GetAtPath(path) as TextureImporter;
textureImporter.textureFormat = TextureImporterFormat.ARGB32;
textureImporter.anisoLevel = 0;
AssetDatabase.ImportAsset(path);
// EditorUtility.CompressTexture(tex, TextureFormat.ARGB32, 0);
//tex.format = TextureFormat.ARGB32;
}
}
示例12: ColorXml
public ColorXml(Color32 c)
{
this.r = c.r;
this.g = c.g;
this.b = c.b;
this.a = c.a;
}
示例13: CreateColorPixel
/// <summary>
/// Creates a 1x1 texture
/// </summary>
/// <param name="Background">Color of the texture</param>
/// <returns></returns>
internal static Texture2D CreateColorPixel(Color32 Background)
{
Texture2D retTex = new Texture2D(1, 1);
retTex.SetPixel(0, 0, Background);
retTex.Apply();
return retTex;
}
示例14: Start
void Start() {
winter = new Color32(246, 243, 237, 255);
spring = new Color32(170, 155, 42, 255);
summer = new Color32(137, 182, 65, 255);
autumn = new Color32(234, 157, 46, 255);
int currentSecond = DateTime.Now.Second;
Camera _camera = GameObject.Find ("Main Camera").GetComponent<Camera>();
childRenderers = this.transform.FindChild ("RoadsideGrass").GetComponentsInChildren<Renderer>();
foreach (Renderer childRenderer in childRenderers) {
if (currentSecond < 15) {
_camera.backgroundColor = winter;
childRenderer.material.color = winter;
}
else if (currentSecond < 30) {
_camera.backgroundColor = spring;
childRenderer.material.color = spring;
}
else if (currentSecond < 45) {
_camera.backgroundColor = summer;
childRenderer.material.color = summer;
}
else {
_camera.backgroundColor = autumn ;
childRenderer.material.color = autumn;
}
}
}
示例15: fill4
public void fill4(int x, int y, Color32 oldColor, Color32 newColor)
{
ArrayList stack = new ArrayList();
stack.Add(new Vec2i(x,y));
int emergency = 10000;
while(stack.Count > 0 && emergency >= 0) {
Vec2i pixel = (Vec2i)stack[stack.Count - 1];
stack.RemoveAt(stack.Count - 1);
if(canvas.GetPixel(pixel.x, pixel.y) == oldColor) {
canvas.SetPixel(pixel.x, pixel.y, newColor);
if(pixel.x + 1 < 96 && canvas.GetPixel(pixel.x + 1, pixel.y) == oldColor)
stack.Add(new Vec2i(pixel.x + 1, pixel.y));
if(pixel.x - 1 >= 0 && canvas.GetPixel(pixel.x - 1, pixel.y) == oldColor)
stack.Add(new Vec2i(pixel.x - 1, pixel.y));
if(pixel.y + 1 < 64 && canvas.GetPixel(pixel.x, pixel.y + 1) == oldColor)
stack.Add(new Vec2i(pixel.x, pixel.y + 1));
if(pixel.y - 1 >= 0 && canvas.GetPixel(pixel.x, pixel.y - 1) == oldColor)
stack.Add(new Vec2i(pixel.x, pixel.y - 1));
}
emergency--;
}
}