Version: 2020.3
public int influenceCount ;

描述

显式提供给影响因子列表的力场数量。

influenceFilter 设置为 ParticleSystemGameObjectFilter.List 时,只有影响因子列表中的力场才会影响粒子系统。

另请参阅:ParticleSystemForceField

using UnityEngine;

public class Example : MonoBehaviour { ParticleSystem.ExternalForcesModule externalForcesModule;

void Start() { // Create a default particle system var particleSystemGameObject = new GameObject("Particle System"); var system = particleSystemGameObject.AddComponent<ParticleSystem>();

// Create a force field to influence the particle system var forceFieldGameObject = new GameObject("Force Field"); var forceField = forceFieldGameObject.AddComponent<ParticleSystemForceField>(); forceField.endRange = 5; forceFieldGameObject.transform.position = new Vector3(0, 0, 10);

// Add the force to the particle systems external forces influencers. externalForcesModule = system.externalForces; externalForcesModule.enabled = true; externalForcesModule.influenceFilter = ParticleSystemGameObjectFilter.List; externalForcesModule.AddInfluence(forceField); }

void OnGUI() { GUILayout.Label("Particle System Influencers:"); for (int i = 0; i < externalForcesModule.influenceCount; ++i) { var influence = externalForcesModule.GetInfluence(i); GUILayout.Label(i + ": " + influence.name); } } }
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961