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

ParticleSystem.CollisionModule.maxCollisionShapes

建议修改

成功!

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

关闭

提交失败

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

关闭

取消

切换到手册
public int maxCollisionShapes;

描述

Unity 考虑用于粒子碰撞的碰撞形状的最大数量。它会忽略多余的形状。地形优先。

其他资源:ParticleSystem.collision.

using UnityEngine;
using System.Collections;

[RequireComponent(typeof(ParticleSystem))] public class ExampleClass : MonoBehaviour { private ParticleSystem ps; public bool maxToggle;

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

var main = ps.main; main.startColor = Color.red;

var shape = ps.shape; shape.shapeType = ParticleSystemShapeType.Sphere;

var collision = ps.collision; collision.enabled = true; collision.type = ParticleSystemCollisionType.World; collision.mode = ParticleSystemCollisionMode.Collision3D; collision.bounce = 0.0f;

var collider1 = GameObject.CreatePrimitive(PrimitiveType.Sphere); collider1.transform.parent = ps.transform; collider1.transform.localPosition = new Vector3(0.0f, 0.0f, 13.0f); collider1.transform.localScale = new Vector3(20.0f, 20.0f, 20.0f);

var collider2 = GameObject.CreatePrimitive(PrimitiveType.Sphere); collider2.transform.parent = ps.transform; collider2.transform.localPosition = new Vector3(0.0f, 0.0f, -13.0f); collider2.transform.localScale = new Vector3(20.0f, 20.0f, 20.0f); }

void Update() { var collision = ps.collision; collision.maxCollisionShapes = maxToggle ? 2 : 1; }

void OnGUI() { maxToggle = GUI.Toggle(new Rect(25, 40, 300, 30), maxToggle, "Toggle Max Collision Shapes (" + (maxToggle ? "2" : "1") + ")"); } }