Search Unity

  1. Unity 2019.1 beta is now available.
    Dismiss Notice
  2. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  3. We're looking for insight from anyone who has experience with game testing to help us better Unity. Take our survey here. If chosen to participate you'll be entered into a sweepstake to win an Amazon gift card.
    Dismiss Notice
  4. On February 28th the Feedback website will shut down and be redirected to the Unity forums. See the full post for more information.
    Dismiss Notice
  5. Want to provide direct feedback to the Unity team? Join the Unity Advisory Panel.
    Dismiss Notice
  6. Unity 2018.3 is now released.
    Dismiss Notice
  7. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice

[Feedback] Legacy Particle System Updater

Discussion in 'Particle System Previews' started by richardkettlewell, Jan 2, 2018.

  1. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    3,189
    This bit of code needs to have the params populated.
    e.g
    Code (CSharp):
    1. var emitParams = new ParticleSystem.EmitParams();
    2. emitParams.startSize = size;
    3. emitParams.startLifetime = energy;
    4. .... etc
    5. _skidSmoke.Emit(emitParams, emission);
    However any values you dont set will be used from the particle system. So it looks like there is an oppurtunity to simplify this script as all you seem to be doing it calculating the values for a manual emission.
    Its worth just calling Emit(emission) and using the defaults from the particle system. See how it looks.
     
    ViperTechnologies likes this.
  2. ViperTechnologies

    ViperTechnologies

    Joined:
    Apr 28, 2017
    Posts:
    29
    Thanks for the hints :)

    in this code i changed the
        private ParticleEmitter[] SplashEmitters;


    to

        private ParticleSystem[] SplashEmitters;


    i have errors on :

    SplashEmitters[ i ].emit=false;

    and

    SplashEmitters[ p ].Emit() ;

    :(
     
    Last edited: Sep 11, 2018
  3. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    3,189
    Code (csharp):
    1. SplashEmitters[ i ].emit=false;
    You need to get the emissions module and set enabled to false.
    Code (csharp):
    1. var emit = SplashEmitters[i].emission;
    2. emit.enabled = false;
    Code (csharp):
    1. SplashEmitters[ p ].Emit() ;
    Just set the enabled state to true. Like above
     
  4. ViperTechnologies

    ViperTechnologies

    Joined:
    Apr 28, 2017
    Posts:
    29
    @karl_jones you are the best sir,
    Thank you it is ready to upgrade !
    really appreciated.
     
    karl_jones likes this.
  5. MasterChameleonGames

    MasterChameleonGames

    Joined:
    Apr 7, 2018
    Posts:
    8
    Do we need to install this, or would the new particle system be installed in 2018.3?
     
  6. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    3,189
    Legacy particles wont work at all in 2018.3. They dont exist.
    If you have legacy particles then go to 2018.2, use the upgrader to replace them and then move to 2018.3.
     
  7. MasterChameleonGames

    MasterChameleonGames

    Joined:
    Apr 7, 2018
    Posts:
    8
    Ok, so the new particle system doesn't get installed in the 2018.3 update?
     
  8. richardkettlewell

    richardkettlewell

    Unity Technologies

    Joined:
    Sep 9, 2015
    Posts:
    899
    I suspect you are confused about what the many various Unity Particle Systems are called.

    - Legacy Particle System is a really *really* old thing that got removed in 2018.3
    - Particle System is the current Production-ready solution for particles in 2018.3
    - The Visual Effect Graph (which I suspect is what you mean by "new") is coming as an experimental preview in the 2018.3 beta cycle, and is nothing to do with this thread/tool.

    This thread is to help people migrate from the Legacy Particle System to the Particle System.
     
    karl_jones likes this.
  9. MasterChameleonGames

    MasterChameleonGames

    Joined:
    Apr 7, 2018
    Posts:
    8
    No, I am not talking about the Visual Effect Graph.
    I wanted to know if this tool is necessary.
    Would installing the 2018.3 version of Unity also install the new Particle System and remove the Legacy one, or does the new system need to be manually installed before the update to use particles?
     
  10. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    3,189
    There is no automatic upgrade to Shruiken(Particle System) from Legacy. The purpose of this tool/thread was to help people migrate by providing a tool to do some of the work. If you have a legacy system in 2018.3 and onwards then it will simply not exists. The code has been completely removed.

    You dont need to install anything. The Particle System has been in Unity since 4.x era. We have just finally removed the very old legacy system.
     
  11. MasterChameleonGames

    MasterChameleonGames

    Joined:
    Apr 7, 2018
    Posts:
    8
    Ok, so this is necessary if I want to use particles.

    Thank you for the clarification. I really appreciate it.
     
  12. MasterChameleonGames

    MasterChameleonGames

    Joined:
    Apr 7, 2018
    Posts:
    8
    Sorry, I read the description completely wrong.

    So this is a tool that converts the script already using the legacy particle system into the new particle system, so if I have never used particle systems but is planning to use it in 2018.3, there is no need for me to use this?
     
  13. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    3,189
    Thats correct. If you have never used legacy particles then you dont need to worry about any of this.
     
  14. MasterChameleonGames

    MasterChameleonGames

    Joined:
    Apr 7, 2018
    Posts:
    8
    Ok, thank you.
     
    karl_jones likes this.
  15. carlos_m_orozco

    carlos_m_orozco

    Joined:
    Sep 17, 2018
    Posts:
    3
    I can't get the update tool to show in the asset menu. What do I need to do ?
     
  16. ViperTechnologies

    ViperTechnologies

    Joined:
    Apr 28, 2017
    Posts:
    29
    first of all the updater is NOT WORKING on 2018.x series, so here is the workaround :
    1- install 2017.4.x
    2- Load your project (clean NOT the one from 2018 since its gonna break it downgrades are NOT ethic )
    3- Import the MAGICAL SCRIPT, select your legacy particle GO, and select the script from the Asset Menu. and you no what to do ^_^.
    4- test your particle if its upgraded correctly tune it if needed. Save your Project.
    5- Clone your project (Just in case you need a backup)
    6- open it in 2018.x if needed upgrade the scripts if needed ...HAVE FUN ;)
     
  17. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    3,189
    What do you mean its not working? It should work on 2018.1 and 2018.2
     
  18. ViperTechnologies

    ViperTechnologies

    Joined:
    Apr 28, 2017
    Posts:
    29
    Sorry i should be more specific, i tested on 2018.1.5 and it was not working i mean errors and not showing in the menu.
    but then i go for 2017.4.6 and then the other updated versions (latest 2017.4.x) works like a charm !
     
  19. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    3,189
    Thanks. I'll take a look and see what's the problem. Ideally the best version to use it on should be 2018.2 as that has the most features to map to legacy.


    Do you mean errors from your scripts using legacy? That will happen as the api is gone but the upgrader should work.
     
    Last edited: Sep 20, 2018
    ViperTechnologies likes this.
  20. game_apps

    game_apps

    Joined:
    Mar 3, 2016
    Posts:
    23
    Hi @karl_jones

    this.Water_heavy.GetComponent<ParticleEmitter>().maxSize = this.ParticleSize;


    How to replace this line with new Particle system ?
     
  21. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    3,189
    Last edited: Dec 17, 2018
  22. kevinbeijer1996

    kevinbeijer1996

    Joined:
    Nov 28, 2017
    Posts:
    2
    Hi everyone,

    I have now updated to Unity 2018.3 but I get the following errors in the updater script.

    Assets/editor/Legacy_Particle_System_Updater.cs(63,13): error CS0246: The type or namespace name `ParticleEmitter' could not be found. Are you missing an assembly reference?

    And the same for line 64 of that script.

    The lines are as following:
    Code (CSharp):
    1. private ParticleEmitter[] components;
    2.     private ParticleEmitter[] prefabs;
    I already looked at it a bit, and don't think they are necessary anymore. Can I just delete them, or is there some way to fix it? And what could be the reason that it gives this error?

    *edit I can't just comment them out as it gives new errors, so that's not really a solution.
    *2nd edit I fixed it by deleting the script, and deleting the scripts with the followup errors as they weren't in use anyway.
     
    Last edited: Jan 9, 2019
  23. Flegy

    Flegy

    Joined:
    Jan 5, 2017
    Posts:
    19
    I bought before several years asset but it is now deprecated. Can you please help me upgrade script to new particle system?

    Thanks in advance
     

    Attached Files:

  24. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    3,189
    I upgraded the script. Its in C# now:

    Code (CSharp):
    1. using UnityEngine;
    2.  
    3. [RequireComponent(typeof(ParticleSystem))]
    4. public class RampDownParticle : MonoBehaviour
    5. {
    6.     public float delayTime;
    7.     float delayPlusTime;
    8.     public float rampDownTime = 1;
    9.     float origMinEmission;
    10.     float origMaxEmission;
    11.     ParticleSystem.EmissionModule emissionModule;
    12.    
    13.     void Start()
    14.     {
    15.         var particleSystem = GetComponent<ParticleSystem>();
    16.         emissionModule = particleSystem.emission;
    17.         origMinEmission = emissionModule.rateOverTime.constantMin;
    18.         origMaxEmission = emissionModule.rateOverTime.constantMax;
    19.         emissionModule.enabled = false;
    20.     }
    21.  
    22.     void Update()
    23.     {
    24.         if ((delayTime + delayPlusTime) > 0)
    25.             delayTime -= Time.deltaTime;
    26.  
    27.         if (delayTime <= 0 && emissionModule.enabled == false)
    28.             emissionModule.enabled = true;
    29.  
    30.         if ((delayTime + delayPlusTime) <= 0)
    31.         {
    32.             emissionModule.rateOverTime = new ParticleSystem.MinMaxCurve(origMinEmission * rampDownTime, origMaxEmission * rampDownTime);
    33.             rampDownTime -= Time.deltaTime;
    34.  
    35.             if (rampDownTime < 0)
    36.                 rampDownTime = 0;
    37.         }
    38.     }
    39. }
    40.  
     
    Flegy and richardkettlewell like this.
  25. Flegy

    Flegy

    Joined:
    Jan 5, 2017
    Posts:
    19
    Thanks, karl_jones for support. It was only js script in my project so thanks for convert to c#. Script now works fine but something is still wrong after upgrade from old to new. Please check video first clip is original second after the upgrade.
     

    Attached Files:

  26. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    3,189
    Looks like something to do with the shape module. Did you try our upgrader on the prefab?
     
  27. Flegy

    Flegy

    Joined:
    Jan 5, 2017
    Posts:
    19
    Yes, nothing change. I did more tests and look like it a fallow scale of the object when with old particles it didn't be a case. Any solution to be all time the same size?
     
  28. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    3,189
  29. ViperTechnologies

    ViperTechnologies

    Joined:
    Apr 28, 2017
    Posts:
    29
    hello again,
    Well, been searching in upgrade guides not sure about that but i need help in converting this script :


    Code (CSharp):
    1.  
    2. public class LightningBolt : MonoBehaviour
    3. {
    4.     public Transform target;
    5.     public int zigs = 100;
    6.     public float speed = 1f;
    7.     public float scale = 1f;
    8.     public Light startLight;
    9.     public Light endLight;
    10.    
    11.     Perlin noise;
    12.     float oneOverZigs;
    13.    
    14.     private Particles[] particles;
    15.    
    16.     void Start()
    17.     {
    18.         oneOverZigs = 1f / (float)zigs;
    19.         GetComponent<ParticleEmitter>().emit = false;
    20.  
    21.         GetComponent<ParticleEmitter>().Emit(zigs);
    22.         particles = GetComponent<ParticleEmitter>().particles;
    23.     }
    24.    
    25.     void Update ()
    26.     {
    27.         if (noise == null)
    28.             noise = new Perlin();
    29.            
    30.         float timex = Time.time * speed * 0.1365143f;
    31.         float timey = Time.time * speed * 1.21688f;
    32.         float timez = Time.time * speed * 2.5564f;
    33.        
    34.         for (int i=0; i < particles.Length; i++)
    35.         {
    36.             Vector3 position = Vector3.Lerp(transform.position, target.position, oneOverZigs * (float)i);
    37.             Vector3 offset = new Vector3(noise.Noise(timex + position.x, timex + position.y, timex + position.z),
    38.                                         noise.Noise(timey + position.x, timey + position.y, timey + position.z),
    39.                                         noise.Noise(timez + position.x, timez + position.y, timez + position.z));
    40.             position += (offset * scale * ((float)i * oneOverZigs));
    41.            
    42.             particles[i].position = position;
    43.             particles[i].color = Color.white;
    44.             particles[i].energy = 1f;
    45.         }
    46.        
    47.         GetComponent<ParticleEmitter>().particles = particles;
    48.        
    49.         if (GetComponent<ParticleEmitter>().particleCount >= 2)
    50.         {
    51.             if (startLight)
    52.                 startLight.transform.position = particles[0].position;
    53.             if (endLight)
    54.                 endLight.transform.position = particles[particles.Length - 1].position;
    55.         }
    56.     }  
    57. }
     
  30. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    3,189
    try this

    Code (csharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4.  
    5. public class LightningBolt : MonoBehaviour
    6. {
    7.     public Transform target;
    8.     public int zigs = 100;
    9.     public float speed = 1f;
    10.     public float scale = 1f;
    11.     public Light startLight;
    12.     public Light endLight;
    13.  
    14.     Perlin noise;
    15.     float oneOverZigs;
    16.  
    17.     ParticleSystem system;
    18.  
    19.     void Start()
    20.     {
    21.         oneOverZigs = 1f / (float)zigs;
    22.         system = GetComponent<ParticleSystem>();
    23.         system.Emit(zigs);
    24.     }
    25.  
    26.     void Update()
    27.     {
    28.         if (noise == null)
    29.             noise = new Perlin();
    30.  
    31.         float timex = Time.time * speed * 0.1365143f;
    32.         float timey = Time.time * speed * 1.21688f;
    33.         float timez = Time.time * speed * 2.5564f;
    34.  
    35.         var particles = new ParticleSystem.Particle[system.particleCount];
    36.         system.GetParticles(particles);
    37.  
    38.         for (int i = 0; i < particles.Length; i++)
    39.         {
    40.             Vector3 position = Vector3.Lerp(transform.position, target.position, oneOverZigs * (float)i);
    41.             Vector3 offset = new Vector3(noise.Noise(timex + position.x, timex + position.y, timex + position.z),
    42.                 noise.Noise(timey + position.x, timey + position.y, timey + position.z),
    43.                 noise.Noise(timez + position.x, timez + position.y, timez + position.z));
    44.             position += (offset * scale * ((float)i * oneOverZigs));
    45.  
    46.             particles[i].position = position;
    47.             particles[i].color = Color.white;
    48.             particles[i].remainingLifetime = 1f;
    49.         }
    50.  
    51.         system.SetParticles(particles);
    52.  
    53.         if (system.particleCount >= 2)
    54.         {
    55.             if (startLight)
    56.                 startLight.transform.position = particles[0].position;
    57.             if (endLight)
    58.                 endLight.transform.position = particles[particles.Length - 1].position;
    59.         }
    60.     }
    61. }
     
  31. ViperTechnologies

    ViperTechnologies

    Joined:
    Apr 28, 2017
    Posts:
    29
    thanks @karl_jones as always you are a life saver :)
    thank you a zillion times
     
    richardkettlewell and karl_jones like this.