如何更改粒子系统的起始颜色 [英] How to change the Start color of the Particle System

查看:34
本文介绍了如何更改粒子系统的起始颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我只是想通过脚本简单地更改粒子系统的起始颜色,但它不起作用.

So I am just trying to simply change the start color of a particle system via script, and it's not working.

 private ParticleSystem trailPartical;   // The  particle system

 public Color StartColor
 {
      var main = trailPartical.main;
      main.startColor = value;
 }

这根本不起作用,我也尝试过折旧版本:

This is not working at all, and I have also tried the depreciated version:

 trailParticle.startColor = value;

推荐答案

您正在尝试使用 StartColor 作为方法,根据 {} 中的代码判断,即使您将其声明为一个变量.

You're trying to use StartColor as a method, judging by the code inside the {}, even though you declared it as a variable.

除此错误外,由于ParticleSystem的一些变化,需要访问组件的主模块:

Apart from this mistake, due to some changes in the ParticleSystem, you need to access the main module of the component:

ParticleSystem.MainModule main = GetComponent<ParticleSystem>().main;
main.startColor = Color.blue; // <- or whatever color you want to assign

在附加到游戏的脚本中,该脚本也具有粒子系统组件.

inside a script attached to the game which also has the particle system component.

这篇关于如何更改粒子系统的起始颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆