版本: Unity 6 (6000.0)
语言英语
  • C#

ParticleSystemRenderer.lengthScale

建议更改

成功!

感谢您帮助我们提高 Unity 文档的质量。虽然我们无法接受所有提交内容,但我们会阅读用户提出的每项更改建议,并在适用时进行更新。

关闭

提交失败

由于某种原因,您的更改建议无法提交。请<a>稍后再试</a>。感谢您抽出时间帮助我们提高 Unity 文档的质量。

关闭

取消

public float lengthScale;

描述

粒子在其运动方向上拉伸的程度,定义为粒子长度与其宽度的比率。

这决定了粒子在静止时基本长度。值为 1 为中性,不会造成拉伸或挤压。使用大于 1 的值使粒子始终比其宽度更长。

using UnityEngine;
using System.Collections;

[RequireComponent(typeof(ParticleSystem))] public class ExampleClass : MonoBehaviour {

private ParticleSystem ps; private ParticleSystemRenderer psr; public ParticleSystemRenderMode renderMode = ParticleSystemRenderMode.Billboard; public float cameraScale = 0.0f; public float lengthScale = 0.0f; public float velocityScale = 1.0f;

void Start() {

ps = GetComponent<ParticleSystem>(); psr = GetComponent<ParticleSystemRenderer>();

psr.mesh = Resources.GetBuiltinResource<Mesh>("Capsule.fbx");

var main = ps.main; main.startSpeed = new ParticleSystem.MinMaxCurve(0.5f, 1.5f); main.startSize = new ParticleSystem.MinMaxCurve(0.1f, 0.8f); }

void Update() { psr.renderMode = renderMode; psr.cameraVelocityScale = cameraScale; psr.lengthScale = lengthScale; psr.velocityScale = velocityScale;

if (renderMode == ParticleSystemRenderMode.Stretch) Camera.main.transform.position = new Vector3(Mathf.Sin(Time.time) * 4.0f, 0.0f, -10.0f); // move the camera so we can see the effect on stretch camera velocity }

void OnGUI() { renderMode = (ParticleSystemRenderMode)GUI.SelectionGrid(new Rect(25, 25, 900, 30), (int)renderMode, new GUIContent[] { new GUIContent("Billboard"), new GUIContent("Stretch"), new GUIContent("HorizontalBillboard"), new GUIContent("VerticalBillboard"), new GUIContent("Mesh"), new GUIContent("None") }, 6);

if (renderMode == ParticleSystemRenderMode.Stretch) {

GUI.Label(new Rect(25, 80, 100, 30), "Camera Scale"); GUI.Label(new Rect(25, 120, 100, 30), "Length Scale"); GUI.Label(new Rect(25, 160, 100, 30), "Velocity Scale");

cameraScale = GUI.HorizontalSlider(new Rect(125, 85, 100, 30), cameraScale, 0.0f, 10.0f); lengthScale = GUI.HorizontalSlider(new Rect(125, 125, 100, 30), lengthScale, 0.0f, 10.0f); velocityScale = GUI.HorizontalSlider(new Rect(125, 165, 100, 30), velocityScale, 0.0f, 10.0f); } } }