Emit from Edge in Script

Hi there,

I’m trying to create an “area of effect” particle system that has the particles appear along the border of box shaped location.

Here is my code:

// Set area of effect ring
        ParticleSystem particle = GameObject.Find("location").AddComponent<ParticleSystem>();
        ParticleSystem.MainModule main = particle.main;
        main.startSize = (float)0.5;

        ParticleSystem.EmissionModule emission = particle.emission;
        switch (location.size_identifier) {
            case 'S':
                emission.rateOverTime = (float)25;
                break;
            case 'M':
                emission.rateOverTime = (float)50;
                break;
            case 'L':
                emission.rateOverTime = (float)100;
                break;
        }

        particle.GetComponent<ParticleSystemRenderer>().material = new Material((Material)Resources.Load("Materials/Default-Particle"));
        particle.GetComponent<ParticleSystemRenderer>().sortingOrder = 1;

        ParticleSystem.ShapeModule box = particle.shape;
        box.shapeType = ParticleSystemShapeType.Box;
        box.enabled = true;
        // TRYING TO SET THE VALUE HERE
        box.box = new Vector3((float)(location.size * 1.28), (float)(((float)location.size) * 1.28), (float)(((float)location.size) * 1.28));

Everything works fine, I just need to know how to access the “Emit from:” value within the shape module and set it to “Edge” like I can do in the Unity editor. There doesn’t seem to be a member variable for this and I’m having trouble finding any info for it online.

Old and wrong answer: From Unity 2017.1, boolean “emit from edge” is replaced by the float “thickness” for flexibility, give it zero value and it will behave the same as emitting from edge.

Edit: According to ShapeType API, defining “ParticleSystemShapeType.BoxEdge” should do the trick.