Files
ft/Client/Assets/Scripts/UI/PinballUncountable/PinballUncountableExitFxCtrl.cs
2026-06-29 21:18:33 +08:00

45 lines
974 B
C#

using asap.core;
using UnityEngine;
using PinballUncountable;
using System.Threading.Tasks;
using System;
public class PinballUncountableExitFxCtrl : MonoBehaviour
{
[SerializeField] private GameObject _fx;
private float _fxDuration = 1f;
private bool _isPlaying = false;
private void Awake()
{
if (_fx != null)
_fx.SetActive(false);
_isPlaying = false;
}
private void Reset()
{
_fx = transform.GetChild(0).gameObject;
}
public async void TryPlayFx()
{
try
{
if (_isPlaying)
return;
_isPlaying = true;
if (_fx != null)
{
_fx.SetActive(false);
_fx.SetActive(true);
}
await Task.Delay(TimeSpan.FromSeconds(_fxDuration));
_isPlaying = false;
}
catch (System.Exception e)
{
Debug.LogError(e);
}
}
}