不能再使用c#particleSystem属性了吗?

时间:2016-08-02 18:23:41

标签: c# unity3d unity5 particle-system deprecation-warning

我以前能够在Visual Studio C#代码中使用

particleSystem.SetParticles(points, points.Length);

但现在它给了我一个错误。语法有变化吗?我必须使用

GetComponent<ParticleSystem>().SetParticles(points, points.Length);

现在?我的VS项目(在这里使用Unity)不再显示我的粒子,但我没有找到任何其他可以/应该使用的语法。这是正确的,我还有其他错误吗?或者这是不正确的? 感谢。

1 个答案:

答案 0 :(得分:2)

基于relevant Unity documentation,这是最近(从版本5.4.0开始)弃用的另一个属性。

所以是的,您现在必须使用GetComponent<ParticleSystem>()来获取对粒子系统的引用 - 并且您可能希望在Awake()方法中将该引用缓存在变量中如果您需要经常使用它。

相关问题