Version: 2022.1
言語: 日本語
public int maxCollisionShapes ;

説明

The maximum number of collision shapes Unity considers for particle collisions. It ignores excess shapes. Terrains take priority.

関連項目: 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") + ")"); } }
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961