本文整理汇总了C#中UnityEngine.Color类的典型用法代码示例。如果您正苦于以下问题:C# Color类的具体用法?C# Color怎么用?C# Color使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Color类属于UnityEngine命名空间,在下文中一共展示了Color类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
}
开发者ID:siwenRen,项目名称:Wolf,代码行数:32,代码来源:DebugUtils.cs
示例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;
}
}
}
开发者ID:BrettGregson,项目名称:ProceduralBuildings,代码行数:31,代码来源:ProceduralTexture.cs
示例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);
}
开发者ID:siwenRen,项目名称:Wolf,代码行数:25,代码来源:DebugUtils.cs
示例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);
}
开发者ID:hashashin,项目名称:ksp-img_viewer,代码行数:7,代码来源:resize.cs
示例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();
}
开发者ID:li5414,项目名称:UnityFlatEditor,代码行数:7,代码来源:Panels.cs
示例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);
}
开发者ID:Schmork,项目名称:EvoMotion2D,代码行数:31,代码来源:Sensor.cs
示例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)));
}
}
}
开发者ID:2ty,项目名称:race3d,代码行数:7,代码来源:SuperCubeUtil.cs
示例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;
}
开发者ID:amaximan,项目名称:educational,代码行数:26,代码来源:LoadManager.cs
示例9: Start
void Start()
{
baseColour = Color.clear;
//m_flagAlpha = flagRenderer != null ? flagRenderer.material.color.a : 1.0f;
myFaction = gameObject.GetComponent<FactionIndentifier>();
}
开发者ID:patferguson,项目名称:Storms-Project,代码行数:7,代码来源:PirateBaseIdentity.cs
示例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);
}
开发者ID:siwenRen,项目名称:Wolf,代码行数:7,代码来源:DebugUtils.cs
示例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);
}
开发者ID:CanPayU,项目名称:SuperSwungBall,代码行数:7,代码来源:ButtonController.cs
示例12: CreateColorTexture
Texture2D CreateColorTexture(Color color)
{
var texture = new Texture2D(1, 1);
texture.SetPixel(1, 1, color);
texture.Apply();
return texture;
}
开发者ID:Soren025,项目名称:Zenject,代码行数:7,代码来源:PlayerHealthDisplay.cs
示例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);
}
开发者ID:Zerophase,项目名称:DyMProject,代码行数:7,代码来源:AutoFade.cs
示例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
}
开发者ID:Magicolo,项目名称:PseudoFramework,代码行数:7,代码来源:DrawUtility.cs
示例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;
}
开发者ID:MRGS,项目名称:ArcadeRoyale,代码行数:32,代码来源:EditorUtils.cs
示例16: DrawBounds
public static void DrawBounds(Bounds bounds, Color color)
{
var size = bounds.size;
var points = new Vector3[8];
points[0] = bounds.center-bounds.extents;
points[1] = points[0]+new Vector3(size.x, 0, 0);
points[2] = points[0]+new Vector3(0, size.y, 0);
points[3] = points[0]+new Vector3(0, 0, size.z);
points[4] = bounds.center+bounds.extents;
points[5] = points[4]-new Vector3(size.x, 0, 0);
points[6] = points[4]-new Vector3(0, size.y, 0);
points[7] = points[4]-new Vector3(0, 0, size.z);
Debug.DrawLine(points[0], points[1], color);
Debug.DrawLine(points[0], points[2], color);
Debug.DrawLine(points[0], points[3], color);
Debug.DrawLine(points[4], points[5], color);
Debug.DrawLine(points[4], points[6], color);
Debug.DrawLine(points[4], points[7], color);
Debug.DrawLine(points[1], points[6], color);
Debug.DrawLine(points[1], points[7], color);
Debug.DrawLine(points[2], points[5], color);
Debug.DrawLine(points[2], points[7], color);
Debug.DrawLine(points[3], points[5], color);
Debug.DrawLine(points[3], points[6], color);
}
开发者ID:siwenRen,项目名称:Wolf,代码行数:27,代码来源:DebugUtils.cs
示例17: MakeOutline
public static Texture2D MakeOutline(this Texture2D texture, int width)
{
Color[] c = texture.GetPixels();
Color[] nc = new Color[c.Length];
for (int y = 0; y < texture.height; y++)
for (int x = 0; x < texture.width; x++) {
Color cc = c[x + y * texture.width];
if (cc.a < 0.1) {
float a = 0;
for (int cy = Mathf.Max(y - width, 0); cy <= Mathf.Min(y + width, texture.height - 1); cy++)
for (int cx = Mathf.Max(x - width, 0); cx <= Mathf.Min(x + width, texture.width - 1); cx++)
a = Mathf.Max(c[cx + cy * texture.width].a, a);
if (a > 0.1) {
nc[x + y * texture.width] = Color.black.Alpha(a);
goto skip;
}
}
if (cc.a > 0) {
cc = cc.Alpha(1.0f);
}
nc[x + y * texture.width] = cc;
skip:;
}
texture.SetPixels(nc, 0);
texture.Apply();
return texture;
}
开发者ID:hiyijia,项目名称:UnityEngineEx,代码行数:30,代码来源:TextureEx.cs
示例18: DrawEllipse
public void DrawEllipse(Color fillColor)
{
_type = 2;
_optimizeNotTouchable = false;
_fillColor = fillColor;
_requireUpdateMesh = true;
}
开发者ID:yinlei,项目名称:Fishing,代码行数:7,代码来源:Shape.cs
示例19: Write
public static void Write(this BinaryWriter writer, Color input)
{
writer.Write(input.r);
writer.Write(input.g);
writer.Write(input.b);
writer.Write(input.a);
}
开发者ID:Evellex,项目名称:Eldrinth,代码行数:7,代码来源:ColorExt.cs
示例20: OnUpdate
public override void OnUpdate(float realTimeDelta, float simulationTimeDelta)
{
if (!ToolModule.ActiveOptions.IsFlagSet(ToolModule.ModOptions.RoadZoneModifier))
{
return;
}
if (ToolsModifierControl.toolController == null)
{
return;
}
var isUpgradeNetToolActive = GetIsUpgradeNetToolActive();
// Keys Down --------------------------------------------------------------------------
if (Input.GetKeyDown(KeyCode.LeftShift) || Input.GetKeyDown(KeyCode.RightShift))
{
if (isUpgradeNetToolActive && !_isActive)
{
_isActive = true;
ZoneBlocksOffset.Mode = ZoneBlocksOffsetMode.HalfCell;
// 0 181 255 255
_originalColor = ToolsModifierControl.toolController.m_validColor;
// change tool overlay color so user can see that the modifier is enabled
ToolsModifierControl.toolController.m_validColor = new Color(60f / 255f, 0f, 1f, 1f);
}
}
if (Input.GetKeyDown(KeyCode.LeftControl) || Input.GetKeyDown(KeyCode.RightControl))
{
if (isUpgradeNetToolActive && _isActive)
{
ZoneBlocksOffset.Mode = ZoneBlocksOffsetMode.ForcedDefault;
}
}
// Keys Up ----------------------------------------------------------------------------
if (Input.GetKeyUp(KeyCode.LeftShift) || Input.GetKeyUp(KeyCode.RightShift))
{
if (_isActive)
{
_isActive = false;
ZoneBlocksOffset.Mode = ZoneBlocksOffsetMode.Default;
ToolsModifierControl.toolController.m_validColor = _originalColor;
}
}
if (Input.GetKeyUp(KeyCode.LeftControl) || Input.GetKeyUp(KeyCode.RightControl))
{
if (isUpgradeNetToolActive && _isActive)
{
ZoneBlocksOffset.Mode = ZoneBlocksOffsetMode.HalfCell;
}
}
}
开发者ID:Katalyst6,项目名称:CSL.TransitAddonMod,代码行数:60,代码来源:RoadZoneModifierTool.cs
注:本文中的UnityEngine.Color类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论