【Unity3D】粒子系统

简单粒子制作

  • 按参考资源要求,制作一个粒子系统,参考资源
  • 使用 3.3 节介绍,用代码控制使之在不同场景下效果不一样

效果实现

添加粒子系统

添加粒子系统,进行三种光的模拟:

  • shining:原粒子
  • purple:紫色光
  • pink:粉色光
    其中紫色光和粉色光使用代码进行控制。

代码控制

purpleChange.cs
public class purpleChange : MonoBehaviour {
    ParticleSystem exhaust;
    float size = 5f;

    // Use this for initialization
    void Start()
    {
        exhaust = GetComponent();
    }

    // Update is called once per frame
    void Update()
    {
        size = size * 0.999f;
        var main = exhaust.main;
        main.startSize = size;
    }
}

pinkChange.cs
public class pinkChange : MonoBehaviour {

    ParticleSystem exhaust;
    float size = 2f;

    // Use this for initialization
    void Start()
    {
        exhaust = GetComponent();
    }

    // Update is called once per frame
    void Update()
    {
        size = size * 0.999f;
        var main = exhaust.main;
        main.startSize = size;
    }

}

效果图

【Unity3D】粒子系统_第1张图片
【Unity3D】粒子系统_第2张图片

你可能感兴趣的:(Unity3D)