Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* To change the lifetime color’s gradient through script you can assign a new gradient onto the lifetimeColor variable as such: */
- using UnityEngine;
- using System.Collections;
- using ParticlePlayground;
- public class ChangeLifetimeGradient : MonoBehaviour {
- public PlaygroundParticlesC particles;
- public Gradient newGradient;
- void Start () {
- particles.lifetimeColor = newGradient;
- }
- }
- /* Would you like to only change a particular part of the gradient you can reach into the gradient’s keys and set a new color, here’s how you can change the end color of a gradient: */
- using UnityEngine;
- using System.Collections;
- using ParticlePlayground;
- public class ChangeLifetimeGradient : MonoBehaviour {
- public PlaygroundParticlesC particles;
- public Color newEndColor;
- void Start () {
- // Get the color- and alpha keys of the current lifetime gradient
- GradientColorKey[] newLifetimeColorKeys = (GradientColorKey[])particles.lifetimeColor.colorKeys.Clone();
- GradientAlphaKey[] newLifetimeAlphaKeys = (GradientAlphaKey[])particles.lifetimeColor.alphaKeys.Clone();
- // Apply the new end color
- newLifetimeColorKeys[newLifetimeColorKeys.Length-1].color = newEndColor;
- // Set the color- and alpha keys back into the lifetime gradient
- particles.lifetimeColor.SetKeys(newLifetimeColorKeys, newLifetimeAlphaKeys);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement