Fix for Smoke start color update to Unity 5.5

Hi,

After updating this got deprecated:

smokePuff.GetComponent<ParticleSystem>().startColor = gameObject.GetComponent<SpriteRenderer>().color;

The warning message says: ‘ParticleSystem.startColor’ is obsolete: startColor property is depcreated. Use main.StartColor instead.’

The solution I found was to create a ParticleSystem child of the smokePuff object and then create a variable that would use the main [module]:

GameObject smokePuff = Instantiate(smoke, gameObject.transform.position, Quaternion.identity) as GameObject;
ParticleSystem smokePuffPS = smokePuff.GetComponent<ParticleSystem>();

var smokeMain = smokePuffPS.main;
smokeMain.startColor = gameObject.GetComponent<SpriteRenderer>().color;

Destroy(smokePuff, 3f);

The Destroy part is because it was now creating instances that did not disappear

2 Likes

Thanks, I was looking for this. I think they sould update the class with this information.

1 Like

Hi Jose,

Lecture 97 : BB Upgrade to Unity 5 & WebGL Build covers most of the changes in the API between the course recommended version of Unity and Unity 5.

This lecture was added after the release of Unity 5 to cover the differences that students were experiencing, at the time of recording Unity 5.2 was being used. As of Unity 5.3 a significant change to the Particle System was introduced, and currently, this isn’t covered by this lecture (or the source code on GitHub).

In case you come across any other version based differences I would definitely recommend searching here on the forum, as often the question(s) have already been asked and you’ll find an answer really quickly.

I have raised your suggestion of updating the course material with regards to this specific issue, it is obviously rather version specific, users of Unity 5.2 or lower will not experience this, but 5.3 or above will. :slight_smile:


Updated Tue Nov 28 2017 16:29

Hi Jose (@Mstr_JL),

Just to let you know, this information is in a document within Lecture 8 : How You Can Follow With Unity 5.X and Unity 2017. It provides some explanations and code examples highlighting the differences.

1 Like