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); } } }