Files
3d-bxqz/Assets/OpenTheWaterGate/ParticleStateController.cs
2026-05-06 17:36:41 +08:00

43 lines
992 B
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using UnityEngine;
public class ParticleStateController : MonoBehaviour
{
// 直接引用粒子效果的GameObject子物体
[SerializeField] private GameObject ParticleSystem;
private void Start()
{
// 如果未指定,尝试查找名为"Particle"的子物体
if (ParticleSystem == null)
{
ParticleSystem = transform.Find("ParticleSystem")?.gameObject;
if (ParticleSystem == null)
{
Debug.LogWarning("未找到粒子GameObject请手动指定", this);
}
}
// 初始状态设为A隐藏粒子
//SetStateA();
}
// 状态A隐藏粒子禁用粒子GameObject
public void SetStateturnON()
{
if (ParticleSystem != null)
{
ParticleSystem.SetActive(false);
}
}
// 状态B显示粒子启用粒子GameObject
public void SetStateturnOFF()
{
if (ParticleSystem != null)
{
ParticleSystem.SetActive(true);
}
}
}