根据粒子的初始行进方向对齐粒子。
形状模块支持根据粒子的行进方向设置粒子的初始旋转。这可以用于使粒子呈现源自网格表面的效果(例如,油漆从表面剥落)。这适用于任何形状类型。Unity 的任何 ParticleSystem.startRotation 都基于此设置进行应用,因此可以将两者一起使用。
可以将此设置与 ParticleSystem.MainModule.startRotation 设置结合使用;Unity 将由 ParticleSystem.MainModule.startRotation 给定的旋转添加到由 ParticleSystem.ShapeModule.alignToDirection 计算的值之上。
例如:使用 ParticleSystem.ShapeModule.alignToDirection 时添加一个 90 度的 ParticleSystem.MainModule.startRotation,所有粒子都会垂直于表面,如同伸出表面的小尖刺。
using UnityEngine; using System.Collections;
[RequireComponent(typeof(ParticleSystem))] public class ExampleClass : MonoBehaviour { private ParticleSystem ps; public bool toggle = true;
void Start() { ps = GetComponent<ParticleSystem>(); }
void Update() { var shape = ps.shape; shape.alignToDirection = toggle; }
void OnGUI() { toggle = GUI.Toggle(new Rect(25, 45, 200, 30), toggle, "Align To Direction"); } }
Did you find this page useful? Please give it a rating:
Thanks for rating this page!
What kind of problem would you like to report?
Thanks for letting us know! This page has been marked for review based on your feedback.
If you have time, you can provide more information to help us fix the problem faster.
Provide more information
You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:
You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:
You've told us there is information missing from this page. Please tell us more about what's missing:
You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:
You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:
You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:
You've told us this page has a problem. Please tell us more about what's wrong:
Thank you for helping to make the Unity documentation better!
Your feedback has been submitted as a ticket for our documentation team to review.
We are not able to reply to every ticket submitted.