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


C# Gradient.SetKeys方法代码示例

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


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

示例1: Update

	// Update is called once per frame
	void Update () {
    if (timer == 0) {
      LastColor = SoupMaterial.color;
    }

    if (!NextColor.Equals(SoupMaterial.color)) {
      timer += Time.deltaTime;
      Color c = Color.Lerp(LastColor, NextColor, timer / duration);
      SoupMaterial.color = c;
      SoupLight.color = c;
      SoupLight.intensity = Mathf.Max(1.5f * (duration - timer), 1);

      var col = Smoke.colorOverLifetime;
      col.enabled = true;

      Gradient grad = new Gradient();
      grad.SetKeys( new GradientColorKey[] { new GradientColorKey(c, 0.0f), new GradientColorKey(Color.gray, 1.0f) }, new GradientAlphaKey[] { new GradientAlphaKey(1.0f, 0.0f), new GradientAlphaKey(0.0f, 1.0f) } );

      col.color = new ParticleSystem.MinMaxGradient(grad);

      if (timer >= duration) {
        SoupMaterial.color = NextColor;
        SoupLight.intensity = 1;
        timer = 0;
      }
    }
	}
开发者ID:HarrisonHough,项目名称:TheCauldrenRepo,代码行数:28,代码来源:SoupColor.cs

示例2: 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

示例3: GradientPresets

        /// <summary>
        /// Initializes a new instance of Gradient.
        /// </summary>
        static GradientPresets()
        {
            // Grayscale gradient color keys
            var grayscaleColorKeys = new List<GradientColorKey>
            {
                new GradientColorKey(Color.black, 0),
                new GradientColorKey(Color.white, 1)
            };

            // RGB gradient color keys
            var rgbColorKeys = new List<GradientColorKey>
            {
                new GradientColorKey(Color.red, 0),
                new GradientColorKey(Color.green, 0.5f),
                new GradientColorKey(Color.blue, 1)
            };

            // RGBA gradient color keys
            var rgbaColorKeys = new List<GradientColorKey>
            {
                new GradientColorKey(Color.red, 0),
                new GradientColorKey(Color.green, 1 / 3f),
                new GradientColorKey(Color.blue, 2 / 3f),
                new GradientColorKey(Color.black, 1)
            };

            // RGBA gradient alpha keys
            var rgbaAlphaKeys = new List<GradientAlphaKey> {new GradientAlphaKey(0, 2 / 3f), new GradientAlphaKey(1, 1)};

            // Terrain gradient color keys
            var terrainColorKeys = new List<GradientColorKey>
            {
                new GradientColorKey(new Color(0, 0, 0.5f), 0),
                new GradientColorKey(new Color(0.125f, 0.25f, 0.5f), 0.4f),
                new GradientColorKey(new Color(0.25f, 0.375f, 0.75f), 0.48f),
                new GradientColorKey(new Color(0, 0.75f, 0), 0.5f),
                new GradientColorKey(new Color(0.75f, 0.75f, 0), 0.625f),
                new GradientColorKey(new Color(0.625f, 0.375f, 0.25f), 0.75f),
                new GradientColorKey(new Color(0.5f, 1, 1), 0.875f),
                new GradientColorKey(Color.white, 1)
            };

            // Generic gradient alpha keys
            var alphaKeys = new List<GradientAlphaKey> {new GradientAlphaKey(1, 0), new GradientAlphaKey(1, 1)};

            _empty = new Gradient();

            _rgb = new Gradient();
            _rgb.SetKeys(rgbColorKeys.ToArray(), alphaKeys.ToArray());

            _rgba = new Gradient();
            _rgba.SetKeys(rgbaColorKeys.ToArray(), rgbaAlphaKeys.ToArray());

            _grayscale = new Gradient();
            _grayscale.SetKeys(grayscaleColorKeys.ToArray(), alphaKeys.ToArray());

            _terrain = new Gradient();
            _terrain.SetKeys(terrainColorKeys.ToArray(), alphaKeys.ToArray());
        }
开发者ID:Andros-Spica,项目名称:LibNoise.Unity,代码行数:62,代码来源:GradientPresets.cs

示例4: InitImpulseGradient

	private void InitImpulseGradient ()
	{
		impulseGradient = new Gradient ();
		GradientColorKey[] gck = new GradientColorKey[impulseGradientColors.Length];
		GradientAlphaKey[] gak = new GradientAlphaKey[impulseGradientColors.Length];
		for (int i = 0; i < impulseGradientColors.Length; i++) {
			gck [i].color = impulseGradientColors [i];
			gak [i].alpha = 1.0f;
			gck [i].time = gak [i].time = impulseGradientTimes [i];
		}
		impulseGradient.SetKeys (gck, gak);
	}
开发者ID:eriol1977,项目名称:Bullseye,代码行数:12,代码来源:UIControl.cs

示例5: GetLerp

        /// <summary>
        /// Returns a gradient that represents a linear interpolation between two colors.
        /// </summary>
        /// <param name="color1"></param>
        /// <param name="color2"></param>
        /// <returns></returns>
        public static Gradient GetLerp(Color color1, Color color2)
        {
            var gradient = new Gradient();

            var leftColorKey = new GradientColorKey(color1, 0);
            var rightColorKey = new GradientColorKey(color2, 1);

            var leftAlphaKey = new GradientAlphaKey(color1.a, 0);
            var rightAlphaKey = new GradientAlphaKey(color1.a, 1);

            gradient.SetKeys(
                new[]{leftColorKey, rightColorKey},
                new[]{leftAlphaKey, rightAlphaKey});

            return gradient;
        }
开发者ID:MRGS,项目名称:ArcadeRoyale,代码行数:22,代码来源:GradientExtensions.cs

示例6: CreateGradTexture

	public void CreateGradTexture(){
		// Create gradient object and assign generic starting colours
		Grad = new Gradient();
		LastGrad = new Gradient();
		GradientColorKey[] gck = new GradientColorKey[2];
		gck[0] = new GradientColorKey(Color.black, 0f);
		gck[1] = new GradientColorKey(Color.white, 1f);
		GradientAlphaKey[] gak = new GradientAlphaKey[2];
		gak[0] = new GradientAlphaKey(1f, 0f);
		gak[1] = new GradientAlphaKey(1f, 1f);
		Grad.SetKeys(gck, gak);
		LastGrad.SetKeys(gck, gak);
		
		outTexture = new Texture2D(_gradientSizeX,_gradientSizeY);
		outTexture.hideFlags = HideFlags.HideAndDontSave;
//		Debug.Log (outTexture);
	}
开发者ID:haramako,项目名称:test02,代码行数:17,代码来源:GradientMaker.cs

示例7: Start

    void Start () {
        GradientColorKey[] gradColorKey;
        GradientAlphaKey[] gradAlphaKey;

        grad = new Gradient();
        gradColorKey = new GradientColorKey[3];
        gradAlphaKey = new GradientAlphaKey[1];

        gradColorKey[0].color = Color.magenta;
        gradColorKey[0].time = 0.0f;
        gradColorKey[1].color = Color.green;
        gradColorKey[1].time = 0.5f;
        gradColorKey[2].color = Color.magenta;
        gradColorKey[2].time = 1.0f;

        gradAlphaKey[0].alpha = 1.0f;

        grad.SetKeys(gradColorKey,gradAlphaKey);
    }
开发者ID:AlbinoShadow,项目名称:NecknNeck,代码行数:19,代码来源:WallColors.cs

示例8: Grad

    public static Color Grad(float x)
    {
        /*
        // Terrain gradient color keys
        List<GradientColorKey> terrainColorKeys = new List<GradientColorKey>
        {
            new GradientColorKey(new Color(0, 0, 0.5f), 0),
            new GradientColorKey(new Color(0.125f, 0.25f, 0.5f), 0.4f),
            new GradientColorKey(new Color(0.25f, 0.375f, 0.75f), 0.48f),
            new GradientColorKey(new Color(0, 0.75f, 0), 0.5f),
            new GradientColorKey(new Color(0.75f, 0.75f, 0), 0.625f),
            new GradientColorKey(new Color(0.625f, 0.375f, 0.25f), 0.75f),
            new GradientColorKey(new Color(0.5f, 1, 1), 0.875f),
            new GradientColorKey(Color.white, 1)
        };

        // Generic gradient alpha keys
        var alphaKeys = new List<GradientAlphaKey> {new GradientAlphaKey(1, 0), new GradientAlphaKey(1, 1)};
        */

        Gradient g = new Gradient();
        GradientColorKey[] gck;
        GradientAlphaKey[] gak;

        // Populate the color keys at the relative time 0 and 1 (0 and 100%)
        gck = new GradientColorKey[2];
        gck[0].color = Color.red;
        gck[0].time = 0.0f;
        gck[1].color = Color.blue;
        gck[1].time = 1.0f;

        // Populate the alpha  keys at relative time 0 and 1  (0 and 100%)
        gak = new GradientAlphaKey[2];
        gak[0].alpha = 1.0f;
        gak[0].time = 0.0f;
        gak[1].alpha = 0.0f;
        gak[1].time = 1.0f;

        //g.SetKeys(terrainColorKeys.ToArray(), alphaKeys.ToArray());
        g.SetKeys(gck,gak);

        return g.Evaluate(x);;
    }
开发者ID:parthshah31,项目名称:HackMITAudio,代码行数:43,代码来源:Tools.cs

示例9: CreateModel

        public override void CreateModel(Transform parent)
        {
            GameObject model = Object.Instantiate(Resources.Load("ParticleSystem")) as GameObject;

            if (model != null)
            {
                var colorOverLifetimeModule = model.GetComponent<ParticleSystem>().colorOverLifetime;
                var gradient = new Gradient();
                var gradientColorKeys = new GradientColorKey[]
                {new GradientColorKey(_startColor, 0f), new GradientColorKey(_endColor, 1f)};
                var gradientAlphaKeys = new GradientAlphaKey[]
                {new GradientAlphaKey(1f, 0f), new GradientAlphaKey(1f, 0.8f), new GradientAlphaKey(0f, 1f)};
                    // only fade out in the last 20% of lifetime
                gradient.SetKeys(gradientColorKeys, gradientAlphaKeys);
                colorOverLifetimeModule.color = new ParticleSystem.MinMaxGradient(gradient);

                model.transform.SetParent(parent);
                model.transform.localPosition = LocalCoinPosition();
                SetModel(model);
            }
        }
开发者ID:mervyn-mccreight,项目名称:unity-cardboard-qr,代码行数:21,代码来源:QrCodeDataParticle.cs

示例10: EvaluateColor

        public Color EvaluateColor(double value)
        {
            if (_unityGradient == null)
            {
                var colorKeys = Stops
                    .Select(i => i.TryConvertToColorKey(Min, Max))
                    .Where(i => i != null)
                    .Select(i => i.Value)
                    .ToArray();

                var alphaKeys = Stops
                    .Select(i => i.TryConvertToAlphaKey(Min, Max))
                    .Where(i => i != null)
                    .Select(i => i.Value)
                    .ToArray();

                _unityGradient = new Gradient();
                _unityGradient.SetKeys(colorKeys, alphaKeys);
            }

            return _unityGradient.Evaluate((float)((value - Min) / (Max - Min)));
        }
开发者ID:nanathan,项目名称:HotSpot,代码行数:22,代码来源:EvaluatedGradientNode.cs

示例11: Start

    // Use this for initialization
    void Start()
    {
        ren = GetComponent<MeshRenderer>();
        mat = ren.material;
        initialPos = transform.position;

        pillarGradient = new Gradient();

        gck = pillarGradient.colorKeys;
        gck[0].color = mat.color;
        gck[0].time = 0.0f;
        gck[1].color = hotColor;
        gck[1].time = 1.0f;

        gak = pillarGradient.alphaKeys;
        gak[0].alpha = 1.0f;
        gak[0].time = 0.0f;
        gak[1].alpha = 1.0f;
        gak[1].time = 1.0f;

        pillarGradient.SetKeys(gck, gak);
    }
开发者ID:matiasfr,项目名称:Hattrick,代码行数:23,代码来源:PillarController.cs

示例12: GetGradient

		public static Gradient GetGradient(string key)
		{
			Gradient gradient = null;

			if( z_GradientSerializer.Deserialize(EditorPrefs.GetString(key), out gradient) )
				return gradient;

			Gradient g = new Gradient();
			
			g.SetKeys(
				new GradientColorKey[] { 
					new GradientColorKey(new Color(.1f, 0f, 1f, 1f), 0f),
					new GradientColorKey(Color.black, 1f)
					},
				new GradientAlphaKey[] {
					new GradientAlphaKey(1f, 0f),
					new GradientAlphaKey(1f, 1f),
					});

			return g;

		}
开发者ID:alex-carlson,项目名称:PixelitisGGJ,代码行数:22,代码来源:z_Pref.cs

示例13: setGradient

    void setGradient()
    {
        gradientKeys = new GradientColorKey[4];
        gradientKeys [0].color = headColor_hsv;
        gradientKeys [0].time = 0.0f;
        gradientKeys [1].color = headASColor_hsv;
        gradientKeys [1].time = 0.2f;
        gradientKeys [2].color = bottomAScolor_hsv;
        gradientKeys [2].time = 0.7f;
        gradientKeys [3].color = bottomColor_hsv;
        gradientKeys [3].time = 1.0f;

        gradientAlpha = new GradientAlphaKey[4];
        gradientAlpha [0].alpha = 1.0f;
        gradientAlpha [1].alpha = 1.0f;
        gradientAlpha [2].alpha = 1.0f;
        gradientAlpha [3].alpha = 1.0f;
        gradientAlpha[0].time = 0.0f;
        gradientAlpha[1].time = 0.2f;
        gradientAlpha[2].time = 0.7f;
        gradientAlpha[3].time = 1.0f;

        randomGradient = new Gradient();
        randomGradient.SetKeys(gradientKeys,gradientAlpha);

        gradientKeys = new GradientColorKey[4];
        gradientKeys [0].color = bottomColor_hsv;
        gradientKeys [0].time = 0.0f;
        gradientKeys [1].color = bottomAScolor_hsv;
        gradientKeys [1].time = 0.2f;
        gradientKeys [2].color = headASColor_hsv;
        gradientKeys [2].time = 0.7f;
        gradientKeys [3].color = headColor_hsv;
        gradientKeys [3].time = 1.0f;

        randomGradient2 = new Gradient();
        randomGradient2.SetKeys(gradientKeys,gradientAlpha);
    }
开发者ID:Titoulion,项目名称:Shoal,代码行数:38,代码来源:NewGradient.cs

示例14: OnInitialize


//.........这里部分代码省略.........

                particleSystem.simulationSpace = childKSPParticleEmitter.pe.useWorldSpace
                    ? ParticleSystemSimulationSpace.World
                    : ParticleSystemSimulationSpace.Local;

                particleSystem.maxParticles = particleCountLimit;

                particleSystemRenderer.material = childKSPParticleEmitter.pr.material;

                // TODO Actually copy the mode from childKSPParticleEmitter.particleRenderMode?
                particleSystemRenderer.renderMode = ParticleSystemRenderMode.Billboard;

                try
                {
                    childKSPParticleEmitter.particleRenderMode =
                        (ParticleRenderMode)Enum.Parse(typeof(ParticleRenderMode), renderMode);
                }
                catch (ArgumentException)
                {
                    Print("ModelMultiParticleFXExt: " + renderMode + " is not a valid ParticleRenderMode");
                }

                switch (childKSPParticleEmitter.particleRenderMode)
                {
                    case ParticleRenderMode.Billboard:
                        particleSystemRenderer.renderMode = ParticleSystemRenderMode.Billboard;
                        break;
                    case ParticleRenderMode.Stretch:
                        particleSystemRenderer.renderMode = ParticleSystemRenderMode.Stretch;
                        break;
                    case ParticleRenderMode.SortedBillboard:
                        particleSystemRenderer.renderMode = ParticleSystemRenderMode.Billboard;
                        particleSystemRenderer.sortMode = ParticleSystemSortMode.Distance;
                        break;
                    case ParticleRenderMode.HorizontalBillboard:
                        particleSystemRenderer.renderMode = ParticleSystemRenderMode.HorizontalBillboard;
                        break;
                    case ParticleRenderMode.VerticalBillboard:
                        particleSystemRenderer.renderMode = ParticleSystemRenderMode.VerticalBillboard;
                        break;
                    default:
                        particleSystemRenderer.renderMode = ParticleSystemRenderMode.Billboard;
                        break;
                }

                //particleSystemRenderer.alignment = ParticleSystemRenderSpace.View;

                if (childKSPParticleEmitter.doesAnimateColor)
                {
                    ParticleSystem.ColorOverLifetimeModule col = particleSystem.colorOverLifetime;
                    col.enabled = true;

                    GradientColorKey[] colorKeys = new GradientColorKey[5];
                    GradientAlphaKey[] alphaKeys = new GradientAlphaKey[5];

                    Color[] colors = childKSPParticleEmitter.colorAnimation;

                    float step = 1f / (colors.Length - 1);

                    for (int t = 0; t < colors.Length; t++)
                    {
                        colorKeys[t] = new GradientColorKey(colors[t], t * step);
                        alphaKeys[t] = new GradientAlphaKey(colors[t].a, t * step);
                    }

                    Gradient gradient = new Gradient();
                    gradient.SetKeys(colorKeys, alphaKeys);

                    col.color = new ParticleSystem.MinMaxGradient(gradient);
                }

                //try
                //{
                //    particleSystemRenderer.renderMode =
                //        (ParticleSystemRenderMode)Enum.Parse(typeof (ParticleSystemRenderMode), renderMode);
                //}
                //catch (ArgumentException)
                //{
                //    Print("ModelMultiParticleFXExt: " + renderMode + " is not a valid ParticleSystemRenderMode");
                //}

                persistentEmitters.Add(pkpe);

                DisableCollider(pkpe.go);

                emitterGameObject.transform.SetParent(transforms[i]);

                emitterGameObject.transform.localPosition = localPosition;
                emitterGameObject.transform.localRotation = Quaternion.Euler(localRotation);
                emitterGameObject.SetLayerRecursive(layerId);
            }
        }

        Destroy(model);

        list.Add(this);

        // 1.0 don't seems to properly do this for engines.
        OnEvent(0);
    }
开发者ID:sarbian,项目名称:SmokeScreen,代码行数:101,代码来源:ModelMultiShurikenPersistFX.cs

示例15: GradientPresets

        /// <summary>
        /// Initializes a new instance of Gradient.
        /// </summary>
        static GradientPresets()
        {
            // Generic gradient alpha keys
            var alphaKeys = new List<GradientAlphaKey> { new GradientAlphaKey(1, 0), new GradientAlphaKey(1, 1) };

            // RGBA gradient alpha keys
            var rgbaAlphaKeys = new List<GradientAlphaKey> { new GradientAlphaKey(0, 2 / 3f), new GradientAlphaKey(1, 1) };

            // cloud alpha keys
            var cloudAlphaKeys = new List<GradientAlphaKey> { new GradientAlphaKey(0, 0), new GradientAlphaKey(1, 1) };

            // Grayscale gradient color keys
            var grayscaleColorKeys = new List<GradientColorKey>
            {
                new GradientColorKey(Color.black, 0),
                new GradientColorKey(Color.white, 1)
            };

            var cloudColorKeys = new List<GradientColorKey>
            {
                new GradientColorKey(new Color(1,1,1,0), 0f),
                new GradientColorKey(new Color(1,1,1,0), 0.5f),
                new GradientColorKey(new Color(1,1,1,0), 1f)
            };

            // RGB gradient color keys
            var rgbColorKeys = new List<GradientColorKey>
            {
                new GradientColorKey(Color.red, 0),
                new GradientColorKey(Color.green, 0.5f),
                new GradientColorKey(Color.blue, 1)
            };

            // RGBA gradient color keys
            var rgbaColorKeys = new List<GradientColorKey>
            {
                new GradientColorKey(Color.red, 0),
                new GradientColorKey(Color.green, 1 / 3f),
                new GradientColorKey(Color.blue, 2 / 3f),
                new GradientColorKey(Color.black, 1)
            };

            var one = 1f / 255f;

            // Terrain gradient color keys
            var terrainColorKeys = new List<GradientColorKey>
            {
                new GradientColorKey(new Color(one * 13,  one * 48,  one * 76), 0),      // deep ocean
                new GradientColorKey(new Color(one * 28,  one * 74,  one * 107), 0.42f), // shallow water
                new GradientColorKey(new Color(one * 169, one * 160, one * 124), 0.45f), // beach
                new GradientColorKey(new Color(one * 92,  one * 131, one * 57), 0.46f),  // green land
                new GradientColorKey(new Color(one * 125, one * 112, one * 88), 0.55f),  // arid / desert
                new GradientColorKey(new Color(one * 92,  one * 131, one * 57), 0.60f),  // green land
                new GradientColorKey(new Color(one * 11,  one * 40,  one * 4), 0.94f),   // forest
                new GradientColorKey(new Color(one * 236, one * 240, one * 249), 1)      // mountain peaks
            };

            _empty = new Gradient();

            _rgb = new Gradient();
            _rgb.SetKeys(rgbColorKeys.ToArray(), alphaKeys.ToArray());

            _rgba = new Gradient();
            _rgba.SetKeys(rgbaColorKeys.ToArray(), rgbaAlphaKeys.ToArray());

            _grayscale = new Gradient();
            _grayscale.SetKeys(grayscaleColorKeys.ToArray(), alphaKeys.ToArray());

            _cloud = new Gradient();
            _cloud.SetKeys(cloudColorKeys.ToArray(), cloudAlphaKeys.ToArray());

            _terrain = new Gradient();
            _terrain.SetKeys(terrainColorKeys.ToArray(), alphaKeys.ToArray());
        }
开发者ID:TehWardy,项目名称:Framework,代码行数:77,代码来源:GradientPresets.cs


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