- Home /
Whats the best way to create a 'legacy' particle system?
I am currently working through the book "Unity 3.x Game Development Essentials". In chapter 8 they introduce particle systems. The description of how to configure the particles systems wasn't matching what I was seeing in Unity 3.5.6f4. After some Googling I realized that they are referring to the 'legacy particles system', not the Shuriken system.
I managed to create a legacy particle system by creating a particle system from the Hierarchy then applying an emitter, renderer and animator to it from the Component->Effects->Legacy Particles menu and removing the 'Particle System'. Using this method I had to re-apply a material in the renderer for it to work. As outlined in another question.
Is there a simpler way to create a legacy particle system? They way I did it seems a little clunky..
Thanks!
You didn't have to start with a Particle System... you could have just started with an empty GameObject and then added those components. That's what I generally do if I happen to need the Legacy Particle System for some reason (alas, there are still a few things that Shuriken can't do).
Answer by clunk47 · Nov 27, 2012 at 05:49 AM
This will make it really easy. FIRST, in your ASSETS folder, create a new folder and name it Editor. In the new Editor folder, create a C-Sharp Script and name it MyWindow. Now just copy and paste the following code to that script. This will create a new menu in Unity called "Custom", when you go to it select "Add > Particles > Ellipsoid Particle Emitter". Done. You still have to add a material but this makes it WAY less of a pain to use legacy particles. This just creates a new empty game object and adds all necessary components. Let me know if you have any issues. Notice the class name in the script is MyWindow. Make sure to name the script MyWindow for this reason.
///////////////////////////////////////////////////////////////////////////////////
using UnityEditor;
using UnityEngine;
class MyWindow : EditorWindow
{
[MenuItem("Custom/Add/Particles/Ellipsoid Particle Emitter")]
static void AddEllipsoidParticleEmitter()
{
GameObject epe = new GameObject("Ellipsoid Particle Emitter");
epe.AddComponent("EllipsoidParticleEmitter");
epe.AddComponent<ParticleAnimator>();
epe.AddComponent<ParticleRenderer>();
}
}
Nice answer, especially including the Editor folder, thumb Up. I have made the same thing in uJS, but an unable to attach the Default-Particle material. Do you know how to do this from an Editor / Context $$anonymous$$enu command?
http://answers.unity3d.com/questions/344911/how-to-find-and-assign-a-native-shader-to-a-render.html
http://answers.unity3d.com/questions/348041/list-of-all-default-unity-shaders.html
Thanks =]
I haven't tried this yet, but it looks great. A lot easier than what I was doing...
And I learned how to make custom menu items!
Thanks for the response.
You have to create your own material, but this will be a one-time thing. Here is an updated version of the script I posted before. In order for this script to work correctly as is, Create a new Folder in Assets folder named Resources. Create a new folder in Resources called $$anonymous$$aterials. Create another new folder in Resources called Textures. Here is a circle gradient you can use for now to test. Save this image to your new texture folder "Resources/Textures" CircleGradient.png Not that you will need the background of this image to be BLAC$$anonymous$$ to appear correctly as particles. Then you would select the texture in Unity Inspector and under options, check the box "Alpha From Grayscale". $$anonymous$$ake sure to name this texture Particle to work w/ this specific code.
Now go to your $$anonymous$$aterials folder "Resources/$$anonymous$$aterials" and create a new $$anonymous$$aterial, name it Custom-Particle. That's it. The script will do the rest. This will add the legacy particle system, assign a material, shader, and texture. Once you do all of this, it will be the only time you have to do it. From here on just go to Custom / Add / Particles / Ellipsoid Particle Emitter and BA$$anonymous$$. Enjoy! ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
using UnityEditor;
using UnityEngine;
class $$anonymous$$yWindow : EditorWindow
{
[$$anonymous$$enuItem("Custom/Add/Particles/Ellipsoid Particle Emitter")]
static void AddEllipsoidParticleEmitter()
{
GameObject epe = new GameObject("Ellipsoid Particle Emitter");
epe.AddComponent("EllipsoidParticleEmitter");
epe.AddComponent<ParticleAnimator>();
epe.AddComponent<ParticleRenderer>();
$$anonymous$$aterial material = Resources.Load ("$$anonymous$$aterials/Custom-Particle") as $$anonymous$$aterial;
Texture2D texture = Resources.Load ("Textures/Particle") as Texture2D;
Shader shader = Shader.Find("Particles/Alpha Blended Premultiply");
epe.renderer.shared$$anonymous$$aterial = material;
epe.renderer.shared$$anonymous$$aterial.mainTexture = texture;
epe.renderer.shared$$anonymous$$aterial.shader = shader;
}
}
If you take out the lines of this code that have to do with TEXTURE, you can just add the default-particle texture to your custom material in the inspector. Then it would be the same as the default material :D
Thanks alucardj, I also posted below how to do the materials, just in case someone wanted to know how to do it in C#. :)
Your answer
Follow this Question
Related Questions
Remove wireframe on particle systems 3 Answers
Change colour of particles with C# 1 Answer
Shuriken particle spin 1 Answer
How can I scale Shuriken particle system? 2 Answers
Particle System Overhead 6 Answers