Version: 2017.3 (switch to 2017.4)
LanguageEnglish
  • C#
  • JS

Script language

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

ParticleSystem.ShapeModule.shapeType

Switch to Manual
public var shapeType: ParticleSystemShapeType;

Description

Type of shape to emit particles from.

#pragma strict
private var ps: ParticleSystem;
public var shapeType: ParticleSystemShapeType = ParticleSystemShapeType.Cone;
private var shapeTypeIndex: int = 2;
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 radiusThickness: float = 1.0f;
public var radiusMode: ParticleSystemShapeMultiModeValue = ParticleSystemShapeMultiModeValue.Random;
public var radiusSpread: float = 0.0f;
public var radiusSpeed: float = 1.0f;
public var donutRadius: float = 0.2f;
public var length: float = 2.0f;
public var boxThickness: Vector3 = new Vector3(0.0f, 0.0f, 0.0f);
public var meshShapeType: ParticleSystemMeshShapeType;
public var normalOffset: float = 0.0f;
public var randomizeDirection: float = 0.0f;
public var spherizeDirection: float = 0.0f;
public var randomizePosition: float = 0.0f;
public var position: Vector3 = new Vector3(0.0f, 0.0f, 0.0f);
public var rotation: Vector3 = new Vector3(0.0f, 0.0f, 0.0f);
public var scale: Vector3 = new Vector3(1.0f, 1.0f, 1.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.radiusThickness = radiusThickness;
	shape.donutRadius = donutRadius;
	shape.length = length;
	shape.boxThickness = boxThickness;
	shape.meshShapeType = meshShapeType;
	shape.normalOffset = normalOffset;
	shape.randomDirectionAmount = randomizeDirection;
	shape.sphericalDirectionAmount = spherizeDirection;
	shape.randomPositionAmount = randomizePosition;
	shape.position = position;
	shape.rotation = rotation;
	shape.scale = scale;
}
function OnGUI() {
	var content: List.<GUIContent> = new List.<GUIContent>();
	for (var i: int = 0; i < intParticleSystemShapeType.Donut + 1; i++) {
		var currentShapeType: ParticleSystemShapeType = ParticleSystemShapeTypei;
		var obsoleteAttribute: var = Attribute.GetCustomAttribute(currentShapeType.GetType().GetField(currentShapeType.ToString()), ObsoleteAttribute, false);
		// skip the obsolete shape types
		if (obsoleteAttribute == null)
			content.Add(new GUIContent(currentShapeType.ToString(), i.ToString()));
	}
	shapeTypeIndex = GUI.SelectionGrid(new Rect(25, 25, 1000, 80), shapeTypeIndex, content.ToArray(), content.Count / 3);
	shapeType = ParticleSystemShapeTypeint.Parse(content[shapeTypeIndex].tooltip);
	var y: float = 120.0f;
	var spacing: float = 40.0f;
	if (shapeType == ParticleSystemShapeType.Sphere || shapeType == ParticleSystemShapeType.Hemisphere) {
		GUI.Label(new Rect(25, y, 140, 30), "Radius");
		radius = GUI.HorizontalSlider(new Rect(165, y + 5, 100, 30), radius, 1.0f, 5.0f);
		y += spacing;
		GUI.Label(new Rect(25, y, 140, 30), "Radius Thickness");
		radiusThickness = GUI.HorizontalSlider(new Rect(165, y + 5, 100, 30), radiusThickness, 0.0f, 1.0f);
		y += spacing;
	}
	if (shapeType == ParticleSystemShapeType.Cone || shapeType == ParticleSystemShapeType.ConeVolume) {
		GUI.Label(new Rect(25, y, 140, 30), "Angle");
		angle = GUI.HorizontalSlider(new Rect(165, y + 5, 100, 30), angle, 1.0f, 90.0f);
		y += spacing;
		GUI.Label(new Rect(25, y, 140, 30), "Radius");
		radius = GUI.HorizontalSlider(new Rect(165, y + 5, 100, 30), radius, 0.2f, 5.0f);
		y += spacing;
		GUI.Label(new Rect(25, y, 140, 30), "Radius Thickness");
		radiusThickness = GUI.HorizontalSlider(new Rect(165, y + 5, 100, 30), radiusThickness, 0.0f, 1.0f);
		y += spacing;
		GUI.Label(new Rect(25, y, 140, 30), "Arc");
		arc = GUI.HorizontalSlider(new Rect(165, y + 5, 100, 30), arc, 1.0f, 360.0f);
		y += spacing;
		GUI.Label(new Rect(25, y, 140, 30), "Arc Mode");
		arcMode = ParticleSystemShapeMultiModeValueGUI.SelectionGrid(new Rect(165, 280, 360, 20), intarcMode, [new GUIContent("Random"), new GUIContent("Loop"), new GUIContent("Ping-Pong"), new GUIContent("Burst Spread")], 4);
		y += spacing;
		GUI.Label(new Rect(25, y, 140, 30), "Arc Spread");
		arcSpread = GUI.HorizontalSlider(new Rect(165, y + 5, 100, 30), arcSpread, 0.0f, 1.0f);
		y += spacing;
		GUI.Label(new Rect(25, y, 140, 30), "Arc Speed");
		arcSpeed = GUI.HorizontalSlider(new Rect(165, y + 5, 100, 30), arcSpeed, 0.0f, 2.0f);
		y += spacing;
		if (shapeType == ParticleSystemShapeType.ConeVolume) {
			GUI.Label(new Rect(25, y, 140, 30), "Length");
			length = GUI.HorizontalSlider(new Rect(165, y + 5, 100, 30), length, 1.0f, 5.0f);
			y += spacing;
		}
	}
	if (shapeType == ParticleSystemShapeType.Box || shapeType == ParticleSystemShapeType.BoxShell || shapeType == ParticleSystemShapeType.BoxEdge) {
		if (shapeType == ParticleSystemShapeType.BoxShell || shapeType == ParticleSystemShapeType.BoxEdge) {
			GUI.Label(new Rect(25, y, 140, 30), "Box Thickness");
			boxThickness.x = GUI.HorizontalSlider(new Rect(165, y + 5, 50, 30), boxThickness.x, 0.0f, 1.0f);
			boxThickness.y = GUI.HorizontalSlider(new Rect(220, y + 5, 50, 30), boxThickness.y, 0.0f, 1.0f);
			boxThickness.z = GUI.HorizontalSlider(new Rect(275, y + 5, 50, 30), boxThickness.z, 0.0f, 1.0f);
			y += spacing;
		}
	}
	if (shapeType == ParticleSystemShapeType.Donut) {
		GUI.Label(new Rect(25, y, 140, 30), "Arc");
		arc = GUI.HorizontalSlider(new Rect(165, y + 5, 100, 30), arc, 1.0f, 360.0f);
		y += spacing;
		GUI.Label(new Rect(25, y, 140, 30), "Arc Mode");
		arcMode = ParticleSystemShapeMultiModeValueGUI.SelectionGrid(new Rect(165, y, 360, 20), intarcMode, [new GUIContent("Random"), new GUIContent("Loop"), new GUIContent("Ping-Pong"), new GUIContent("Burst Spread")], 4);
		y += spacing;
		GUI.Label(new Rect(25, y, 140, 30), "Arc Spread");
		arcSpread = GUI.HorizontalSlider(new Rect(165, y + 5, 100, 30), arcSpread, 0.0f, 1.0f);
		y += spacing;
		GUI.Label(new Rect(25, y, 140, 30), "Arc Speed");
		arcSpeed = GUI.HorizontalSlider(new Rect(165, y + 5, 100, 30), arcSpeed, 0.0f, 2.0f);
		y += spacing;
		GUI.Label(new Rect(25, y, 140, 30), "Radius");
		radius = GUI.HorizontalSlider(new Rect(165, y + 5, 100, 30), radius, 0.2f, 5.0f);
		y += spacing;
		GUI.Label(new Rect(25, y, 140, 30), "Radius Thickness");
		radiusThickness = GUI.HorizontalSlider(new Rect(165, y + 5, 100, 30), radiusThickness, 0.0f, 1.0f);
		y += spacing;
		GUI.Label(new Rect(25, y, 140, 30), "Donut Radius");
		donutRadius = GUI.HorizontalSlider(new Rect(165, y + 5, 100, 30), donutRadius, 0.0f, 5.0f);
		y += spacing;
	}
	if (shapeType == ParticleSystemShapeType.Circle) {
		GUI.Label(new Rect(25, y, 140, 30), "Arc");
		arc = GUI.HorizontalSlider(new Rect(165, y + 5, 100, 30), arc, 1.0f, 360.0f);
		y += spacing;
		GUI.Label(new Rect(25, y, 140, 30), "Arc Mode");
		arcMode = ParticleSystemShapeMultiModeValueGUI.SelectionGrid(new Rect(165, y, 360, 20), intarcMode, [new GUIContent("Random"), new GUIContent("Loop"), new GUIContent("Ping-Pong"), new GUIContent("Burst Spread")], 4);
		y += spacing;
		GUI.Label(new Rect(25, y, 140, 30), "Arc Spread");
		arcSpread = GUI.HorizontalSlider(new Rect(165, y + 5, 100, 30), arcSpread, 0.0f, 1.0f);
		y += spacing;
		GUI.Label(new Rect(25, y, 140, 30), "Arc Speed");
		arcSpeed = GUI.HorizontalSlider(new Rect(165, y + 5, 100, 30), arcSpeed, 0.0f, 2.0f);
		y += spacing;
		GUI.Label(new Rect(25, y, 140, 30), "Radius");
		radius = GUI.HorizontalSlider(new Rect(165, y + 5, 100, 30), radius, 0.2f, 5.0f);
		y += spacing;
		GUI.Label(new Rect(25, y, 140, 30), "Radius Thickness");
		radiusThickness = GUI.HorizontalSlider(new Rect(165, y + 5, 100, 30), radiusThickness, 0.0f, 1.0f);
		y += spacing;
	}
	if (shapeType == ParticleSystemShapeType.SingleSidedEdge) {
		GUI.Label(new Rect(25, y, 140, 30), "Radius");
		radius = GUI.HorizontalSlider(new Rect(165, y + 5, 100, 30), radius, 0.2f, 5.0f);
		y += spacing;
		GUI.Label(new Rect(25, y, 140, 30), "Radius Mode");
		radiusMode = ParticleSystemShapeMultiModeValueGUI.SelectionGrid(new Rect(165, y, 360, 20), intradiusMode, [new GUIContent("Random"), new GUIContent("Loop"), new GUIContent("Ping-Pong"), new GUIContent("Burst Spread")], 4);
		y += spacing;
		GUI.Label(new Rect(25, y, 140, 30), "Radius Spread");
		radiusSpread = GUI.HorizontalSlider(new Rect(165, y + 5, 100, 30), radiusSpread, 0.0f, 1.0f);
		y += spacing;
		GUI.Label(new Rect(25, y, 140, 30), "Radius Speed");
		radiusSpeed = GUI.HorizontalSlider(new Rect(165, y + 5, 100, 30), radiusSpeed, 0.0f, 2.0f);
		y += spacing;
	}
	if (shapeType == ParticleSystemShapeType.Mesh) {
		meshShapeType = ParticleSystemMeshShapeTypeGUI.SelectionGrid(new Rect(25, y + 5, 300, 20), intmeshShapeType, [new GUIContent("Vertex"), new GUIContent("Edge"), new GUIContent("Polygon")], 3);
		y += spacing;
		GUI.Label(new Rect(25, y, 140, 30), "Normal Offset");
		normalOffset = GUI.HorizontalSlider(new Rect(165, y + 5, 100, 30), normalOffset, -3.0f, 3.0f);
		y += spacing;
	}
	GUI.Label(new Rect(25, y, 140, 30), "Randomize Direction");
	randomizeDirection = GUI.HorizontalSlider(new Rect(165, y + 5, 100, 30), randomizeDirection, 0.0f, 1.0f);
	y += spacing;
	if (shapeType != ParticleSystemShapeType.Sphere) {
		GUI.Label(new Rect(25, y, 140, 30), "Spherize Direction");
		spherizeDirection = GUI.HorizontalSlider(new Rect(165, y + 5, 100, 30), spherizeDirection, 0.0f, 1.0f);
		y += spacing;
	}
	GUI.Label(new Rect(25, y, 140, 30), "Randomize Position");
	randomizePosition = GUI.HorizontalSlider(new Rect(165, y + 5, 100, 30), randomizePosition, 0.0f, 1.0f);
	y += spacing;
	GUI.Label(new Rect(25, y, 140, 30), "Position");
	position.x = GUI.HorizontalSlider(new Rect(165, y + 5, 50, 30), position.x, -2.0f, 2.0f);
	position.y = GUI.HorizontalSlider(new Rect(220, y + 5, 50, 30), position.y, -2.0f, 2.0f);
	position.z = GUI.HorizontalSlider(new Rect(275, y + 5, 50, 30), position.z, -2.0f, 2.0f);
	y += spacing;
	GUI.Label(new Rect(25, y, 140, 30), "Rotation");
	rotation.x = GUI.HorizontalSlider(new Rect(165, y + 5, 50, 30), rotation.x, 0.0f, 360.0f);
	rotation.y = GUI.HorizontalSlider(new Rect(220, y + 5, 50, 30), rotation.y, 0.0f, 360.0f);
	rotation.z = GUI.HorizontalSlider(new Rect(275, y + 5, 50, 30), rotation.z, 0.0f, 360.0f);
	y += spacing;
	GUI.Label(new Rect(25, y, 140, 30), "Scale");
	scale.x = GUI.HorizontalSlider(new Rect(165, y + 5, 50, 30), scale.x, 0.0f, 3.0f);
	scale.y = GUI.HorizontalSlider(new Rect(220, y + 5, 50, 30), scale.y, 0.0f, 3.0f);
	scale.z = GUI.HorizontalSlider(new Rect(275, y + 5, 50, 30), scale.z, 0.0f, 3.0f);
	y += spacing;
}

Did you find this page useful? Please give it a rating: