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


C# UnityEngine.Gradient类代码示例

本文整理汇总了C#中UnityEngine.Gradient的典型用法代码示例。如果您正苦于以下问题:C# Gradient类的具体用法?C# Gradient怎么用?C# Gradient使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Gradient类属于UnityEngine命名空间,在下文中一共展示了Gradient类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: DrawGradientRect

        /// <summary>
        /// Draws gradient rectangle on texture
        /// </summary>t
        public static void DrawGradientRect(this Texture2D texture, int x, int y, int blockWidth, int blockHeight,
            Gradient gradient, Directions progressionDirection)
        {
            Func<int, int, Color> getColor;
            switch (progressionDirection)
            {
                case Directions.Left:
                    getColor = (_x, _y) => gradient.Evaluate(1 - (float) _x/(float) blockWidth);
                    break;
                case Directions.Right:
                    getColor = (_x, _y) => gradient.Evaluate((float) _x/(float) blockWidth);
                    break;
                case Directions.Down:
                    getColor = (_x, _y) => gradient.Evaluate(1 - (float) _y/(float) blockHeight);
                    break;
                case Directions.Up:
                    getColor = (_x, _y) => gradient.Evaluate((float) _y/(float) blockHeight);
                    break;
                default:
                    Debug.LogError("Not supported direction: " + progressionDirection);
                    return;
            }

            var colors = new Color[blockWidth*blockHeight];
            for (int _y = 0; _y < blockHeight; _y++)
            {
                for (int _x = 0; _x < blockWidth; _x++)
                {
                    colors[_x + _y*blockWidth] = getColor(_x, _y);
                }
            }
            texture.SetPixels(x, y, blockWidth, blockHeight, colors);
        }
开发者ID:rickoskam,项目名称:ShepherdGame,代码行数:36,代码来源:TextureE.cs

示例2: DebugCreateTonsOfPresets

 public void DebugCreateTonsOfPresets()
 {
     int num = 150;
     string str = "Preset_";
     for (int i = 0; i < num; i++)
     {
         List<GradientColorKey> list = new List<GradientColorKey>();
         int num3 = Random.Range(3, 8);
         for (int j = 0; j < num3; j++)
         {
             list.Add(new GradientColorKey(new Color(Random.value, Random.value, Random.value), Random.value));
         }
         List<GradientAlphaKey> list2 = new List<GradientAlphaKey>();
         int num5 = Random.Range(3, 8);
         for (int k = 0; k < num5; k++)
         {
             list2.Add(new GradientAlphaKey(Random.value, Random.value));
         }
         Gradient presetObject = new Gradient {
             colorKeys = list.ToArray(),
             alphaKeys = list2.ToArray()
         };
         this.Add(presetObject, str + (i + 1));
     }
 }
开发者ID:CarlosHBC,项目名称:UnityDecompiled,代码行数:25,代码来源:GradientPresetLibrary.cs

示例3: OnGUI

		internal static void OnGUI()
		{
			if(!initialized)
				GetPreferences();

			GUILayout.Label("Settings", z_GUI.headerTextStyle);

			rebuildNormals = EditorGUILayout.Toggle(gc_rebuildNormals, rebuildNormals);
			hideWireframe = EditorGUILayout.Toggle(gc_hideWireframe, hideWireframe);
			lockBrushSettings = EditorGUILayout.Toggle(gc_lockBrushSettings, lockBrushSettings);
			fullStrengthColor = EditorGUILayout.ColorField(gc_fullStrengthColor, fullStrengthColor);

			try
			{
				EditorGUI.BeginChangeCheck();
				
				object out_gradient = z_ReflectionUtil.Invoke(	null,
																typeof(EditorGUILayout),
																"GradientField",
																new System.Type[] { typeof(GUIContent), typeof(Gradient), typeof(GUILayoutOption[]) },
																BindingFlags.NonPublic | BindingFlags.Static,
																new object[] { gc_BrushGradient, gradient, null });
				gradient = (Gradient) out_gradient;

				if(EditorGUI.EndChangeCheck())
					SetPreferences();
			}
			catch
			{
				// internal editor gripe about something unimportant
			}
		}
开发者ID:alex-carlson,项目名称:PixelitisGGJ,代码行数:32,代码来源:z_GlobalSettingsEditor.cs

示例4: DrawInternal

 private void DrawInternal(Rect rect, Gradient gradient)
 {
     if (gradient != null)
     {
         GradientEditor.DrawGradientWithBackground(rect, GradientPreviewCache.GetGradientPreview(gradient));
     }
 }
开发者ID:CarlosHBC,项目名称:UnityDecompiled,代码行数:7,代码来源:GradientPresetLibrary.cs

示例5: Gradient

 /// <summary>
 /// Creates a gradient between two colors
 /// </summary>
 public static Gradient Gradient(Color from, Color to)
 {
     var g = new Gradient();
     g.SetKeys(new[] {new GradientColorKey(from, 0), new GradientColorKey(to, 1)},
         new[] {new GradientAlphaKey(from.a, 0), new GradientAlphaKey(to.a, 1)});
     return g;
 }
开发者ID:liamzebedee,项目名称:hackagong2015,代码行数:10,代码来源:ColorE.cs

示例6: GenerateColorsEvenGradient

        /// <summary>
        /// Generate colors evely spaced out on a given gradient.
        /// </summary>
        /// <param name="colorCount"></param>
        /// <param name="gradient"></param>
        /// <param name="jitter"></param>
        /// <returns></returns>
        public static List<Color> GenerateColorsEvenGradient(
			int colorCount, 
			Gradient gradient, 
			float jitter)
        {
            return gradient.SampleEvenly(colorCount, jitter).ToList();
        }
开发者ID:MRGS,项目名称:ArcadeRoyale,代码行数:14,代码来源:ProceduralPalette.cs

示例7: Deserialize

		public static bool Deserialize(string str, out Gradient gradient)
		{
			gradient = null;

			string[] arrays = str.Split('\n');

			if(arrays.Length < 2)
				return false;

			string[] colors_str = arrays[0].Split('|');
			string[] alphas_str = arrays[1].Split('|');

			if(colors_str.Length < 2 || alphas_str.Length < 2)
				return false;

			List<GradientColorKey> colors = new List<GradientColorKey>();
			List<GradientAlphaKey> alphas = new List<GradientAlphaKey>();

			foreach(string s in colors_str)
			{
				string[] key = s.Split('&');

				if(key.Length < 2)
					continue;

				Color value;
				float time;

				if(!TryParseColor(key[0], out value))
					continue;

				if(!float.TryParse(key[1], out time))
					continue;

				colors.Add( new GradientColorKey(value, time) );
			}

			foreach(string s in alphas_str)
			{
				string[] key = s.Split('&');

				if(key.Length < 2)
					continue;

				float alpha, time;

				if(!float.TryParse(key[0], out alpha))
					continue;
				if(!float.TryParse(key[1], out time))
					continue;

				alphas.Add( new GradientAlphaKey(alpha, time) );
			}

			gradient = new Gradient();
			gradient.SetKeys(colors.ToArray(), alphas.ToArray());

			return true;
		}
开发者ID:alex-carlson,项目名称:PixelitisGGJ,代码行数:59,代码来源:z_GradientSerializer.cs

示例8: CreateGradientTexture

 public static Texture2D CreateGradientTexture(Gradient gradient)
 {
   Texture2D preview = new Texture2D(256, 2, TextureFormat.ARGB32, false);
   preview.wrapMode = TextureWrapMode.Clamp;
   preview.hideFlags = HideFlags.HideAndDontSave;
   GradientEditor.RefreshPreview(gradient, preview);
   return preview;
 }
开发者ID:BlakeTriana,项目名称:unity-decompiled,代码行数:8,代码来源:GradientEditor.cs

示例9: RefreshPreview

 public static void RefreshPreview(Gradient gradient, Texture2D preview)
 {
   Color[] colors = new Color[512];
   for (int index = 0; index < 256; ++index)
     colors[index] = colors[index + 256] = gradient.Evaluate((float) index / 256f);
   preview.SetPixels(colors);
   preview.Apply();
 }
开发者ID:BlakeTriana,项目名称:unity-decompiled,代码行数:8,代码来源:GradientEditor.cs

示例10: Init

 private void Init(Gradient newGradient)
 {
     this.m_Gradient = newGradient;
     if (this.m_GradientEditor != null)
     {
         this.m_GradientEditor.Init(newGradient, 0);
     }
     base.Repaint();
 }
开发者ID:randomize,项目名称:VimConfig,代码行数:9,代码来源:GradientPicker.cs

示例11: Init

 public void Init(Gradient gradient, int numSteps)
 {
   this.m_Gradient = gradient;
   this.m_TextureDirty = true;
   this.m_NumSteps = numSteps;
   this.BuildArrays();
   if (this.m_RGBSwatches.Count <= 0)
     return;
   this.m_SelectedSwatch = this.m_RGBSwatches[0];
 }
开发者ID:BlakeTriana,项目名称:unity-decompiled,代码行数:10,代码来源:GradientEditor.cs

示例12: constructor

	static public int constructor(IntPtr l) {
		try {
			UnityEngine.Gradient o;
			o=new UnityEngine.Gradient();
			pushValue(l,true);
			pushValue(l,o);
			return 2;
		}
		catch(Exception e) {
			return error(l,e);
		}
	}
开发者ID:xclouder,项目名称:godbattle,代码行数:12,代码来源:Lua_UnityEngine_Gradient.cs

示例13: constructor

 public static int constructor(IntPtr l)
 {
     try {
         UnityEngine.Gradient o;
         o=new UnityEngine.Gradient();
         pushValue(l,o);
         return 1;
     }
     catch(Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return 0;
     }
 }
开发者ID:BobLChen,项目名称:hugula,代码行数:13,代码来源:Lua_UnityEngine_Gradient.cs

示例14: Add

		public override void Add(object presetObject, string presetName)
		{
			Gradient gradient = presetObject as Gradient;
			if (gradient == null)
			{
				Debug.LogError("Wrong type used in GradientPresetLibrary");
				return;
			}
			Gradient gradient2 = new Gradient();
			gradient2.alphaKeys = gradient.alphaKeys;
			gradient2.colorKeys = gradient.colorKeys;
			this.m_Presets.Add(new GradientPresetLibrary.GradientPreset(gradient2, presetName));
		}
开发者ID:guozanhua,项目名称:UnityDecompiled,代码行数:13,代码来源:GradientPresetLibrary.cs

示例15: Replace

		public override void Replace(int index, object newPresetObject)
		{
			Gradient gradient = newPresetObject as Gradient;
			if (gradient == null)
			{
				Debug.LogError("Wrong type used in GradientPresetLibrary");
				return;
			}
			Gradient gradient2 = new Gradient();
			gradient2.alphaKeys = gradient.alphaKeys;
			gradient2.colorKeys = gradient.colorKeys;
			this.m_Presets[index].gradient = gradient2;
		}
开发者ID:guozanhua,项目名称:UnityDecompiled,代码行数:13,代码来源:GradientPresetLibrary.cs


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