Version: 5.6
public ParticleSystemShapeType shapeType ;

설명

Type of shape to emit particles from.

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