【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<ParticleSystem>();
    }

    // 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<ParticleSystem>();
    }

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

}

效果圖

在這裏插入圖片描述
在這裏插入圖片描述

發佈了36 篇原創文章 · 獲贊 1 · 訪問量 9953
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章