沿每个轴翻转一定百分比的粒子。
设置为介于 0 与 1 之间的值,较高值会使较高比例的粒子翻转,1 会使所有粒子翻转。
using UnityEngine; using UnityEditor; using System.Collections;
public class ExampleClass : MonoBehaviour {
private ParticleSystemRenderer psr; public Vector3 flip;
void Start() {
psr = GetComponent<ParticleSystemRenderer>();
psr.material = AssetDatabase.GetBuiltinExtraResource<Material>("Default-Diffuse.mat"); // square material so we can see the pivot more easily psr.mesh = Resources.GetBuiltinResource<Mesh>("Capsule.fbx"); }
void Update() {
psr.flip = flip; }
void OnGUI() {
GUI.Label(new Rect(25, 40, 100, 30), "X"); GUI.Label(new Rect(25, 80, 100, 30), "Y"); GUI.Label(new Rect(25, 120, 100, 30), "Z");
flip.x = GUI.HorizontalSlider(new Rect(65, 25, 100, 30), flip.x, 0.0f, 1.0f); flip.y = GUI.HorizontalSlider(new Rect(65, 65, 100, 30), flip.y, 0.0f, 1.0f); flip.z = GUI.HorizontalSlider(new Rect(65, 105, 100, 30), flip.z, 0.0f, 1.0f); } }