Legacy Documentation: Version 5.6 (Go to current version)
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.

#pragma strict
private var ps: ParticleSystem;
public var shapeType: ParticleSystemShapeType = ParticleSystemShapeType.Cone;
public var arc: float = 360.0f;
public var arcMode: ParticleSystemShapeMultiModeValue = ParticleSystemShapeMultiModeValue.Random;
public var arcSpread: float = 0.0f;
public var arcSpeed: float = 1.0f;
public var angle: float = 25.0f;
public var radius: float = 1.0f;
public var radiusMode: ParticleSystemShapeMultiModeValue = ParticleSystemShapeMultiModeValue.Random;
public var radiusSpread: float = 0.0f;
public var radiusSpeed: float = 1.0f;
public var length: float = 2.0f;
public var box: Vector3 = new Vector3(2.0f, 2.0f, 2.0f);
public var meshShapeType: ParticleSystemMeshShapeType;
public var normalOffset: float = 0.0f;
public var meshScale: float = 1.0f;
public var randomizeDirection: float = 0.0f;
public var spherizeDirection: float = 0.0f;
function Start() {
	ps = GetComponent.<ParticleSystem>();
	var main: var = ps.main;
	main.startSpeed = 0.1f;
	main.startSize = 0.1f;
	main.startLifetime = 1.0f;
	var emission: var = ps.emission;
	emission.rateOverTime = 500.0f;
	var shape: var = ps.shape;
	shape.mesh = Resources.GetBuiltinResource.<Mesh>("Capsule.fbx");
}
function Update() {
	var shape: var = ps.shape;
	shape.shapeType = shapeType;
	shape.arc = arc;
	shape.arcMode = arcMode;
	shape.arcSpread = arcSpread;
	shape.arcSpeed = arcSpeed;
	shape.angle = angle;
	shape.radius = radius;
	shape.radiusMode = radiusMode;
	shape.radiusSpread = radiusSpread;
	shape.radiusSpeed = radiusSpeed;
	shape.length = length;
	shape.box = box;
	shape.meshShapeType = meshShapeType;
	shape.normalOffset = normalOffset;
	shape.meshScale = meshScale;
	shape.randomDirectionAmount = randomizeDirection;
	shape.sphericalDirectionAmount = spherizeDirection;
}
function OnGUI() {
	var content: GUIContent[] = new GUIContent[intParticleSystemShapeType.BoxEdge + 1];
	for (var i: int = 0; i < content.Length; i++)
		content[i] = new GUIContent((ParticleSystemShapeTypei).ToString());
	shapeType = ParticleSystemShapeTypeGUI.SelectionGrid(new Rect(25, 25, 1000, 80), intshapeType, 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), "Arc");
		arc = GUI.HorizontalSlider(new Rect(125, 205, 100, 30), arc, 1.0f, 360.0f);
		GUI.Label(new Rect(25, 240, 100, 30), "Arc Mode");
		arcMode = ParticleSystemShapeMultiModeValueGUI.SelectionGrid(new Rect(125, 240, 360, 20), intarcMode, [new GUIContent("Random"), new GUIContent("Loop"), new GUIContent("Ping-Pong"), new GUIContent("Burst Spread")], 4);
		GUI.Label(new Rect(25, 280, 100, 30), "Arc Spread");
		arcSpread = GUI.HorizontalSlider(new Rect(125, 285, 100, 30), arcSpread, 0.0f, 1.0f);
		GUI.Label(new Rect(25, 320, 100, 30), "Arc Speed");
		arcSpeed = GUI.HorizontalSlider(new Rect(125, 325, 100, 30), arcSpeed, 0.0f, 2.0f);
		GUI.Label(new Rect(25, 360, 100, 30), "Randomize");
		randomizeDirection = GUI.HorizontalSlider(new Rect(125, 365, 100, 30), randomizeDirection, 0.0f, 1.0f);
		GUI.Label(new Rect(25, 400, 100, 30), "Spherize");
		spherizeDirection = GUI.HorizontalSlider(new Rect(125, 405, 100, 30), spherizeDirection, 0.0f, 1.0f);
		if (shapeType == ParticleSystemShapeType.ConeVolume || shapeType == ParticleSystemShapeType.ConeVolumeShell) {
			GUI.Label(new Rect(25, 440, 100, 30), "Length");
			length = GUI.HorizontalSlider(new Rect(125, 445, 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), "Arc Mode");
		arcMode = ParticleSystemShapeMultiModeValueGUI.SelectionGrid(new Rect(125, 160, 360, 20), intarcMode, [new GUIContent("Random"), new GUIContent("Loop"), new GUIContent("Ping-Pong"), new GUIContent("Burst Spread")], 4);
		GUI.Label(new Rect(25, 200, 100, 30), "Arc Spread");
		arcSpread = GUI.HorizontalSlider(new Rect(125, 205, 100, 30), arcSpread, 0.0f, 1.0f);
		GUI.Label(new Rect(25, 240, 100, 30), "Arc Speed");
		arcSpeed = GUI.HorizontalSlider(new Rect(125, 245, 100, 30), arcSpeed, 0.0f, 2.0f);
		GUI.Label(new Rect(25, 280, 100, 30), "Radius");
		radius = GUI.HorizontalSlider(new Rect(125, 285, 100, 30), radius, 0.2f, 5.0f);
		GUI.Label(new Rect(25, 320, 100, 30), "Randomize");
		randomizeDirection = GUI.HorizontalSlider(new Rect(125, 325, 100, 30), randomizeDirection, 0.0f, 1.0f);
		GUI.Label(new Rect(25, 360, 100, 30), "Spherize");
		spherizeDirection = GUI.HorizontalSlider(new Rect(125, 365, 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), "Radius Mode");
		radiusMode = ParticleSystemShapeMultiModeValueGUI.SelectionGrid(new Rect(125, 160, 360, 20), intradiusMode, [new GUIContent("Random"), new GUIContent("Loop"), new GUIContent("Ping-Pong"), new GUIContent("Burst Spread")], 4);
		GUI.Label(new Rect(25, 200, 100, 30), "Radius Spread");
		radiusSpread = GUI.HorizontalSlider(new Rect(125, 205, 100, 30), radiusSpread, 0.0f, 1.0f);
		GUI.Label(new Rect(25, 240, 100, 30), "Radius Speed");
		radiusSpeed = GUI.HorizontalSlider(new Rect(125, 245, 100, 30), radiusSpeed, 0.0f, 2.0f);
		GUI.Label(new Rect(25, 280, 100, 30), "Randomize");
		randomizeDirection = GUI.HorizontalSlider(new Rect(125, 285, 100, 30), randomizeDirection, 0.0f, 1.0f);
		GUI.Label(new Rect(25, 320, 100, 30), "Spherize");
		spherizeDirection = GUI.HorizontalSlider(new Rect(125, 325, 100, 30), spherizeDirection, 0.0f, 1.0f);
	}
	if (shapeType == ParticleSystemShapeType.Mesh) {
		meshShapeType = ParticleSystemMeshShapeTypeGUI.SelectionGrid(new Rect(25, 125, 300, 20), intmeshShapeType, [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);
	}
}
using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour { private ParticleSystem ps; public ParticleSystemShapeType shapeType = ParticleSystemShapeType.Cone; public float arc = 360.0f; public ParticleSystemShapeMultiModeValue arcMode = ParticleSystemShapeMultiModeValue.Random; public float arcSpread = 0.0f; public float arcSpeed = 1.0f; public float angle = 25.0f; public float radius = 1.0f; public ParticleSystemShapeMultiModeValue radiusMode = ParticleSystemShapeMultiModeValue.Random; public float radiusSpread = 0.0f; public float radiusSpeed = 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.arcMode = arcMode; shape.arcSpread = arcSpread; shape.arcSpeed = arcSpeed; shape.angle = angle; shape.radius = radius; shape.radiusMode = radiusMode; shape.radiusSpread = radiusSpread; shape.radiusSpeed = radiusSpeed; 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), "Arc"); arc = GUI.HorizontalSlider(new Rect(125, 205, 100, 30), arc, 1.0f, 360.0f);

GUI.Label(new Rect(25, 240, 100, 30), "Arc Mode"); arcMode = (ParticleSystemShapeMultiModeValue)GUI.SelectionGrid(new Rect(125, 240, 360, 20), (int)arcMode, new GUIContent[] { new GUIContent("Random"), new GUIContent("Loop"), new GUIContent("Ping-Pong"), new GUIContent("Burst Spread") }, 4);

GUI.Label(new Rect(25, 280, 100, 30), "Arc Spread"); arcSpread = GUI.HorizontalSlider(new Rect(125, 285, 100, 30), arcSpread, 0.0f, 1.0f);

GUI.Label(new Rect(25, 320, 100, 30), "Arc Speed"); arcSpeed = GUI.HorizontalSlider(new Rect(125, 325, 100, 30), arcSpeed, 0.0f, 2.0f);

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

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

if (shapeType == ParticleSystemShapeType.ConeVolume || shapeType == ParticleSystemShapeType.ConeVolumeShell) { GUI.Label(new Rect(25, 440, 100, 30), "Length"); length = GUI.HorizontalSlider(new Rect(125, 445, 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), "Arc Mode"); arcMode = (ParticleSystemShapeMultiModeValue)GUI.SelectionGrid(new Rect(125, 160, 360, 20), (int)arcMode, new GUIContent[] { new GUIContent("Random"), new GUIContent("Loop"), new GUIContent("Ping-Pong"), new GUIContent("Burst Spread") }, 4);

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

GUI.Label(new Rect(25, 240, 100, 30), "Arc Speed"); arcSpeed = GUI.HorizontalSlider(new Rect(125, 245, 100, 30), arcSpeed, 0.0f, 2.0f);

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

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

GUI.Label(new Rect(25, 360, 100, 30), "Spherize"); spherizeDirection = GUI.HorizontalSlider(new Rect(125, 365, 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), "Radius Mode"); radiusMode = (ParticleSystemShapeMultiModeValue)GUI.SelectionGrid(new Rect(125, 160, 360, 20), (int)radiusMode, new GUIContent[] { new GUIContent("Random"), new GUIContent("Loop"), new GUIContent("Ping-Pong"), new GUIContent("Burst Spread") }, 4);

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

GUI.Label(new Rect(25, 240, 100, 30), "Radius Speed"); radiusSpeed = GUI.HorizontalSlider(new Rect(125, 245, 100, 30), radiusSpeed, 0.0f, 2.0f);

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

GUI.Label(new Rect(25, 320, 100, 30), "Spherize"); spherizeDirection = GUI.HorizontalSlider(new Rect(125, 325, 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); } } }
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961