本文整理汇总了C#中UnityEngine.Color类的典型用法代码示例。如果您正苦于以下问题:C# Color类的具体用法?C# Color怎么用?C# Color使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Color类属于UnityEngine命名空间,在下文中一共展示了Color类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DrawDoubleCircle
public static void DrawDoubleCircle(Vector3 origin, Quaternion rotation, float radius1, float radius2, int pieceCount, Color color)
{
if (3 > pieceCount)
{
return;
}
if (0 >= radius1 || 0 >= radius2)
{
return;
}
float pieceAngle = 360.0f / pieceCount;
Vector3 p0_1 = origin + rotation * Vector3.forward * radius1;
Vector3 p0_2 = origin + rotation * Vector3.forward * radius2;
Vector3 p1_1 = p0_1;
Vector3 p1_2 = p0_2;
for (int i = 0; i < pieceCount-1; ++i)
{
var r = Quaternion.Euler(0, pieceAngle*(i+1), 0);
Vector3 p2_1 = origin + rotation * (r * Vector3.forward * radius1);
Vector3 p2_2 = origin + rotation * (r * Vector3.forward * radius2);
Debug.DrawLine(p1_1, p2_1, color);
Debug.DrawLine(p1_2, p2_2, color);
Debug.DrawLine(p2_1, p2_2, color);
p1_1 = p2_1;
p1_2 = p2_2;
}
Debug.DrawLine(p0_1, p1_1, color);
Debug.DrawLine(p0_1, p0_2, color);
}
示例2: DrawLine
/// <summary>
/// Implementation of Besenham's line algorithm:
/// http://en.wikipedia.org/wiki/Bresenham%27s_line_algorithm#Simplification
/// </summary>
public void DrawLine(Vector2 p1, Vector2 p2, Color color)
{
int dx = Mathf.Abs((int) (p1.x - p2.x));
int dy = Mathf.Abs((int) (p1.y - p2.y));
int sx = (p1.x < p2.x) ? 1 : -1;
int sy = (p1.y < p2.y) ? 1 : -1;
int err = dx - dy;
int err2;
while (true)
{
content.SetPixel((int) p1.x, (int) p1.y, color);
if (p1.x == p2.x && p1.y == p2.y) break;
err2 = err << 1;
if (err2 > -dy)
{
err -= dy;
p1.x += sx;
}
if (err2 < dx)
{
err += dx;
p1.y += sy;
}
}
}
示例3: DrawCircle
public static void DrawCircle(Vector3 origin, Quaternion rotation, float radius, int pieceCount, Color color)
{
if (3 > pieceCount)
{
return;
}
if (0 >= radius)
{
return;
}
float pieceAngle = 360.0f / pieceCount;
Vector3 p0 = origin + rotation * Vector3.forward * radius;
Vector3 p1 = p0;
for (int i = 0; i < pieceCount-1; ++i)
{
var r = Quaternion.Euler(0, pieceAngle*(i+1), 0);
Vector3 p2 = origin + rotation * (r * Vector3.forward * radius);
Debug.DrawLine(p1, p2, color);
p1 = p2;
}
Debug.DrawLine(p0, p1, color);
}
示例4: ColorLerpUnclamped
private static Color ColorLerpUnclamped(Color c1, Color c2, float value)
{
return new Color(c1.r + (c2.r - c1.r)*value,
c1.g + (c2.g - c1.g)*value,
c1.b + (c2.b - c1.b)*value,
c1.a + (c2.a - c1.a)*value);
}
示例5: Line
public static void Line(float yOrigin, Color color)
{
var rect = new Rect(0, yOrigin, Screen.width, 1);
GUI.color = color;
GUI.DrawTexture(rect, Drawing.Pixel);
Colors.ResetUIColor();
}
示例6: OnDrawGizmos
void OnDrawGizmos()
{
if (target != null) // show prey / predator indicators
{
var color = ch.Color;
var arrowLenght = 0.4f;
var direction = target.transform.position - transform.position;
var clampDir = Vector3.ClampMagnitude(direction * arrowLenght, 40f);
var start = getPointAtEdge(clampDir);
if (WhatToWatch == WatchType.PREY)
{
DrawArrow.GizmoArrow(start, clampDir, color);
}
if (WhatToWatch == WatchType.PREDATOR)
{
DrawArrow.GizmoBlock(start, clampDir, color);
}
}
if (!GizmoEnabled) return; // show sensor raycasts
var colorBright = GetComponentInParent<SpriteRenderer>().color;
var colorDark = new Color(colorBright.r, colorBright.g, colorBright.b, 0.1f);
DrawSensors.Draw(getPointAtEdge(leftRayDirection), leftRayDirection * rayRange, colorDark);
DrawSensors.Draw(getPointAtEdge(rightRayDirection), rightRayDirection * rayRange, colorDark);
DrawSensors.Draw(getPointAtEdge(sensorRayDirection), sensorRayDirection * rayRange, colorBright);
}
示例7: ResampleColors
public static void ResampleColors(ref List<Color> aColorList, int aNewWidth, int aNewHeight, Color[] aPrevColors, int aStartIndex, int aOldWidth, int aOldHeight) {
for (int y = 0; y < aNewHeight; ++y) {
for (int x = 0; x < aNewWidth; ++x) {
aColorList.Add(Sample(aPrevColors, aStartIndex, aOldWidth, aOldHeight, (float)x/(aOldWidth-1), (float)y/(aOldHeight-1)));
}
}
}
示例8: LoadColor
public static Color LoadColor(JsonTextReader reader)
{
if (reader == null) return new Color(0, 0, 0, 0);
Color color = new Color(0, 0, 0, 0);
string currVal = "";
while (reader.Read())
{
if (reader.Value != null)
{
if (reader.TokenType == JsonToken.PropertyName) currVal = (string)reader.Value;
else
{
switch (currVal)
{
case "r": color.r = (float)(double)reader.Value; break;
case "g": color.g = (float)(double)reader.Value; break;
case "b": color.b = (float)(double)reader.Value; break;
case "a": color.a = (float)(double)reader.Value; break;
default: break;
}
}
}
else if (reader.TokenType == JsonToken.EndObject) return color;
}
return color;
}
示例9: Start
void Start()
{
baseColour = Color.clear;
//m_flagAlpha = flagRenderer != null ? flagRenderer.material.color.a : 1.0f;
myFaction = gameObject.GetComponent<FactionIndentifier>();
}
示例10: DrawRect
public static void DrawRect(Vector3 left, Vector3 right, Vector3 leftEnd, Vector3 rightEnd, Color color)
{
Debug.DrawLine(left, right, color);
Debug.DrawLine(left, leftEnd, color);
Debug.DrawLine(right, rightEnd, color);
Debug.DrawLine(leftEnd, rightEnd, color);
}
示例11: Start
void Start()
{
myColor = GetComponent<Renderer>().material.color;
myCollider = GetComponent<Collider>();
//myMenu = GetComponent<Transform>().parent.gameObject.GetComponent<MenuController>(); -> voir ligne 43 / 44
transform.TransformPoint(1, 0, 0);
}
示例12: CreateColorTexture
Texture2D CreateColorTexture(Color color)
{
var texture = new Texture2D(1, 1);
texture.SetPixel(1, 1, color);
texture.Apply();
return texture;
}
示例13: LoadLevel
public static void LoadLevel(int aLevelIndex, float aFadeOutTime, float aFadeInTime, Color aColor)
{
if (Fading) return;
Instance.m_LevelName = "";
Instance.m_LevelIndex = aLevelIndex;
Instance.StartFade(aFadeOutTime, aFadeInTime, aColor);
}
示例14: DrawText
public static void DrawText(Vector3 position, string text, Color color)
{
#if UNITY_EDITOR
UnityEditor.Handles.color = color;
UnityEditor.Handles.Label(position, text);
#endif
}
示例15: DrawNodeCurve
public static void DrawNodeCurve(Rect start, Vector3 endPos)
{
var startPos = new Vector3(start.x + start.width, start.y + start.height / 2, 0);
var startTan = startPos + Vector3.right * 50;
var endTan = endPos + Vector3.left * 50;
var shadowCol = new Color(0, 0, 0, 0.06f);
for (int i = 0; i < 3; i++)
{// Draw a shadow
Handles.DrawBezier(startPos, endPos, startTan, endTan, shadowCol, null, (i + 1) * 5);
}
Handles.DrawBezier(startPos, endPos, startTan, endTan, Color.black, null, 1);
var oldColor = Handles.color;
Handles.color = new Color(.3f, 0.1f, 0.1f);
Handles.DrawSolidDisc(
(startPos + endPos) / 2,
Vector3.forward,
5);
Handles.color = Color.black;
Handles.DrawWireDisc(
(startPos + endPos) / 2,
Vector3.forward,
5);
Handles.color = oldColor;
}