ParticleSystem不推荐使用颜色和大小替换

时间:2017-09-06 09:09:36

标签: c# unity3d

当我在Update Unity2017MonoDevelop Mac上使用以下方法时,一切都很好,我可以看到图表动画和更改颜色。

但是,当我在使用Windows的{​​{1}}计算机上使用它时(因为它是HoloLens项目的一部分),visual studio会抱怨VisualStudio2017.color已被弃用,所以我应该使用他们的替代品,但是当我这样做时,一切都以粉红色显示。

有谁知道如何纠正这个问题?

.size

我附上了两个屏幕截图,其中显示了之前的using UnityEngine; public class GraphAnimator : MonoBehaviour { [Range(30, 100)] public int _resolution = 30; private int _currentResolution; private ParticleSystem.Particle[] _points; private ParticleSystem _particleSystem; public enum FunctionOption { Sine, Linear, Exponential, Parabola } public FunctionOption _function; private delegate float FunctionDelegate(float x); private static FunctionDelegate[] _functionDelegates = { Sine, Linear, Exponential, Parabola }; private void Start() { _particleSystem = GetComponent<ParticleSystem>(); CreatePoints(); } private void CreatePoints() { if (_resolution < 30 || _resolution > 100) { Debug.LogWarning("Grapher resolution out of bounds, resetting to 30", this); _resolution = 30; } _currentResolution = _resolution; _points = new ParticleSystem.Particle[_resolution]; float increment = 1f / (_resolution - 1); for (int i = 0; i < _resolution; i++) { float x = i * increment; _points[i].position = new Vector3(x, 0f, 0f); _points[i].color = new Color(x, 0f, 0f); _points[i].size = 0.1f; } } private void Update() { if (_currentResolution != _resolution || _points == null) { CreatePoints(); } FunctionDelegate f = _functionDelegates[(int)_function]; for (int i = 0; i < _resolution; i++) { Vector3 p = _points[i].position; p.y = f(p.x); _points[i].position = p; Color c = _points[i].color; c.g = p.y; _points[i].color = c; } _particleSystem.SetParticles(_points, _points.Length); } private static float Sine(float x) { return 0.5f + 0.5f * Mathf.Sin(2 * Mathf.PI * x + Time.timeSinceLevelLoad); } private static float Linear(float x) { return x; } private static float Exponential(float x) { return x * x; } private static float Parabola(float x) { x = 2f * x - 1f; return x * x; } } Unity2017 MonoDevelop)和Mac机器之后使用Windows)颜色动画图。

我尝试的替换包括VisualStudio2017_points[i].startColor = new Color(x, 0f, 0f);以及声明_points[i].startSize = 0.1f;

ParticleSystem.MainModule main = _particleSystem.main;

ParticleSystem.MainModule settings = GetComponent<ParticleSystem>().main;
settings.startColor = new ParticleSystem.MinMaxGradient( new Color(x, 0f, 0f) );

我没有收到任何警告或错误,但它都以粉红色显示,如截图中所示。此脚本附加到空游戏对象,该对象还附加了粒子系统组件。

enter image description here enter image description here

编辑:

事实证明,缺少对材料的引用。 因此,它是基于用户'程序员'的帮助/评论来解决的。

0 个答案:

没有答案