簡單粒子製作
- 按參考資源要求,製作一個粒子系統,參考資源
- 使用 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;
}
}
效果圖