当前位置: 首页>>代码示例>>C#>>正文


C# UnityEngine.Color类代码示例

本文整理汇总了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);
		}
开发者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


注:本文中的UnityEngine.Color类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。