Version: 2023.2
언어: 한국어
public void SetInfluence (int index, ParticleSystemForceField field);

파라미터

index Index to assign the Force Field.
field Force Field that to assign.

설명

Assigns the Force Field at the given index in the influencers list.

When influenceFilter is set to ParticleSystemGameObjectFilter.List then only Force Fields in the influencers list affect the Particle System.

using UnityEngine;

public class Example : MonoBehaviour { public ParticleSystem system; public ParticleSystemForceField field1; public ParticleSystemForceField field2;

ParticleSystem.ExternalForcesModule m_ExternalForcesModule;

void Start() { if (system == null) { Debug.LogError("Please assign a Particle System to `system`."); enabled = false; return; }

if (field1 == null || field2 == null) { Debug.LogError("Please assign a ParticleSystemForceField to `field1` and `field2`."); enabled = false; return; }

m_ExternalForcesModule = system.externalForces; m_ExternalForcesModule.enabled = true; m_ExternalForcesModule.influenceFilter = ParticleSystemGameObjectFilter.List; m_ExternalForcesModule.AddInfluence(field1); }

void OnGUI() { Debug.Assert(m_ExternalForcesModule.influenceCount == 1); var currentForceField = m_ExternalForcesModule.GetInfluence(0);

GUILayout.BeginHorizontal(); GUILayout.Label("Influence: " + currentForceField.name);

if (GUILayout.Button("Toggle")) { m_ExternalForcesModule.SetInfluence(0, currentForceField == field1 ? field2 : field1); }

GUILayout.EndHorizontal(); } }
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961