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

ParticleSystem.LimitVelocityOverLifetimeModule.multiplyDragByParticleSize

建议更改

成功!

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

关闭

提交失败

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

关闭

取消

切换至手册
public bool multiplyDragByParticleSize;

描述

根据粒子的尺寸调整此模块对粒子施加的阻力大小。

using UnityEngine;
using System.Collections;

[RequireComponent(typeof(ParticleSystem))] public class ExampleClass : MonoBehaviour { private ParticleSystem ps; public float hSliderValueDrag = 1.0f; public bool hToggleUseSize = false; public bool hToggleUseVelocity = false;

void Start() { ps = GetComponent<ParticleSystem>();

var limitVelocityOverLifetime = ps.limitVelocityOverLifetime; limitVelocityOverLifetime.enabled = true;

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

void Update() { var limitVelocityOverLifetime = ps.limitVelocityOverLifetime; limitVelocityOverLifetime.dragMultiplier = hSliderValueDrag; limitVelocityOverLifetime.multiplyDragByParticleSize = hToggleUseSize; limitVelocityOverLifetime.multiplyDragByParticleVelocity = hToggleUseVelocity; }

void OnGUI() { GUI.Label(new Rect(25, 40, 100, 30), "Drag");

hSliderValueDrag = GUI.HorizontalSlider(new Rect(135, 45, 100, 30), hSliderValueDrag, 0.0f, 3.0f); hToggleUseSize = GUI.Toggle(new Rect(25, 85, 200, 30), hToggleUseSize, "Multiply by Size"); hToggleUseVelocity = GUI.Toggle(new Rect(25, 125, 200, 30), hToggleUseVelocity, "Multiply by Velocity"); } }