Version: 5.5 (switch to 5.6b)
LanguageEnglish
  • C#
  • JS

Script language

Select your preferred scripting language. All code snippets will be displayed in this language.

ParticleSystem.ShapeModule.shapeType

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Switch to Manual
public var shapeType: ParticleSystemShapeType;
public ParticleSystemShapeType shapeType;

Description

Type of shape to emit particles from.

no example available in JavaScript
using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour {

private ParticleSystem ps; public ParticleSystemShapeType shapeType = ParticleSystemShapeType.Cone; public float arc = 25.0f; public float angle = 25.0f; public float radius = 1.0f; public float length = 2.0f; public Vector3 box = new Vector3(2.0f, 2.0f, 2.0f); public ParticleSystemMeshShapeType meshShapeType; public float normalOffset = 0.0f; public float meshScale = 1.0f; public float randomizeDirection = 0.0f; public float spherizeDirection = 0.0f;

void Start() { ps = GetComponent<ParticleSystem>();

var main = ps.main; main.startSpeed = 0.1f; main.startSize = 0.1f; main.startLifetime = 1.0f;

var emission = ps.emission; emission.rateOverTime = 500.0f;

var shape = ps.shape; shape.mesh = Resources.GetBuiltinResource<Mesh>("Capsule.fbx"); }

void Update() { var shape = ps.shape; shape.shapeType = shapeType; shape.arc = arc; shape.angle = angle; shape.radius = radius; shape.length = length; shape.box = box; shape.meshShapeType = meshShapeType; shape.normalOffset = normalOffset; shape.meshScale = meshScale; shape.randomDirectionAmount = randomizeDirection; shape.sphericalDirectionAmount = spherizeDirection; }

void OnGUI() { GUIContent[] content = new GUIContent[(int)ParticleSystemShapeType.BoxEdge + 1]; for (int i = 0; i < content.Length; i++) content[i] = new GUIContent(((ParticleSystemShapeType)i).ToString()); shapeType = (ParticleSystemShapeType)GUI.SelectionGrid(new Rect(25, 25, 1000, 80), (int)shapeType, content, content.Length / 3);

if (shapeType == ParticleSystemShapeType.Sphere || shapeType == ParticleSystemShapeType.SphereShell || shapeType == ParticleSystemShapeType.Hemisphere || shapeType == ParticleSystemShapeType.HemisphereShell) { GUI.Label(new Rect(25, 120, 100, 30), "Radius"); radius = GUI.HorizontalSlider(new Rect(125, 125, 100, 30), radius, 1.0f, 5.0f);

GUI.Label(new Rect(25, 160, 100, 30), "Randomize"); randomizeDirection = GUI.HorizontalSlider(new Rect(125, 165, 100, 30), randomizeDirection, 0.0f, 1.0f); }

if (shapeType == ParticleSystemShapeType.Cone || shapeType == ParticleSystemShapeType.ConeShell || shapeType == ParticleSystemShapeType.ConeVolume || shapeType == ParticleSystemShapeType.ConeVolumeShell) { GUI.Label(new Rect(25, 120, 100, 30), "Angle"); angle = GUI.HorizontalSlider(new Rect(125, 125, 100, 30), angle, 1.0f, 90.0f);

GUI.Label(new Rect(25, 160, 100, 30), "Radius"); radius = GUI.HorizontalSlider(new Rect(125, 165, 100, 30), radius, 0.2f, 5.0f);

GUI.Label(new Rect(25, 200, 100, 30), "Randomize"); randomizeDirection = GUI.HorizontalSlider(new Rect(125, 205, 100, 30), randomizeDirection, 0.0f, 1.0f);

GUI.Label(new Rect(25, 240, 100, 30), "Spherize"); spherizeDirection = GUI.HorizontalSlider(new Rect(125, 245, 100, 30), spherizeDirection, 0.0f, 1.0f);

if (shapeType == ParticleSystemShapeType.ConeVolume || shapeType == ParticleSystemShapeType.ConeVolumeShell) { GUI.Label(new Rect(25, 280, 100, 30), "Length"); length = GUI.HorizontalSlider(new Rect(125, 285, 100, 30), length, 1.0f, 5.0f); } }

if (shapeType == ParticleSystemShapeType.Box || shapeType == ParticleSystemShapeType.BoxShell || shapeType == ParticleSystemShapeType.BoxEdge) { GUI.Label(new Rect(25, 120, 100, 30), "Box X"); box.x = GUI.HorizontalSlider(new Rect(125, 125, 100, 30), box.x, 1.0f, 5.0f);

GUI.Label(new Rect(25, 160, 100, 30), "Box Y"); box.y = GUI.HorizontalSlider(new Rect(125, 165, 100, 30), box.y, 1.0f, 5.0f);

GUI.Label(new Rect(25, 200, 100, 30), "Box Z"); box.z = GUI.HorizontalSlider(new Rect(125, 205, 100, 30), box.z, 1.0f, 5.0f);

GUI.Label(new Rect(25, 240, 100, 30), "Randomize"); randomizeDirection = GUI.HorizontalSlider(new Rect(125, 245, 100, 30), randomizeDirection, 0.0f, 1.0f);

GUI.Label(new Rect(25, 280, 100, 30), "Spherize"); spherizeDirection = GUI.HorizontalSlider(new Rect(125, 285, 100, 30), spherizeDirection, 0.0f, 1.0f); }

if (shapeType == ParticleSystemShapeType.Circle || shapeType == ParticleSystemShapeType.CircleEdge) { GUI.Label(new Rect(25, 120, 100, 30), "Arc"); arc = GUI.HorizontalSlider(new Rect(125, 125, 100, 30), arc, 1.0f, 360.0f);

GUI.Label(new Rect(25, 160, 100, 30), "Radius"); radius = GUI.HorizontalSlider(new Rect(125, 165, 100, 30), radius, 0.2f, 5.0f);

GUI.Label(new Rect(25, 200, 100, 30), "Randomize"); randomizeDirection = GUI.HorizontalSlider(new Rect(125, 205, 100, 30), randomizeDirection, 0.0f, 1.0f);

GUI.Label(new Rect(25, 240, 100, 30), "Spherize"); spherizeDirection = GUI.HorizontalSlider(new Rect(125, 245, 100, 30), spherizeDirection, 0.0f, 1.0f); }

if (shapeType == ParticleSystemShapeType.SingleSidedEdge) { GUI.Label(new Rect(25, 120, 100, 30), "Radius"); radius = GUI.HorizontalSlider(new Rect(125, 125, 100, 30), radius, 0.2f, 5.0f);

GUI.Label(new Rect(25, 160, 100, 30), "Randomize"); randomizeDirection = GUI.HorizontalSlider(new Rect(125, 165, 100, 30), randomizeDirection, 0.0f, 1.0f);

GUI.Label(new Rect(25, 200, 100, 30), "Spherize"); spherizeDirection = GUI.HorizontalSlider(new Rect(125, 205, 100, 30), spherizeDirection, 0.0f, 1.0f); }

if (shapeType == ParticleSystemShapeType.Mesh) { meshShapeType = (ParticleSystemMeshShapeType)GUI.SelectionGrid(new Rect(25, 125, 300, 20), (int)meshShapeType, new GUIContent[] { new GUIContent("Vertex"), new GUIContent("Edge"), new GUIContent("Polygon") }, 3);

GUI.Label(new Rect(25, 160, 100, 30), "Normal Offset"); normalOffset = GUI.HorizontalSlider(new Rect(125, 165, 100, 30), normalOffset, -3.0f, 3.0f);

GUI.Label(new Rect(25, 200, 100, 30), "Mesh Scale"); meshScale = GUI.HorizontalSlider(new Rect(125, 205, 100, 30), meshScale, -5.0f, 5.0f); GUI.Label(new Rect(25, 240, 100, 30), "Randomize"); randomizeDirection = GUI.HorizontalSlider(new Rect(125, 245, 100, 30), randomizeDirection, 0.0f, 1.0f);

GUI.Label(new Rect(25, 280, 100, 30), "Spherize"); spherizeDirection = GUI.HorizontalSlider(new Rect(125, 285, 100, 30), spherizeDirection, 0.0f, 1.0f); } } }