You've already forked taptap2024_GJ_chidouren
42 lines
1.0 KiB
C#
42 lines
1.0 KiB
C#
using System;
|
|
using Framework.Audio;
|
|
using Framework.Timer;
|
|
using Sirenix.Utilities;
|
|
using UnityEngine;
|
|
|
|
namespace Game.Component
|
|
{
|
|
|
|
public class PropEffect : MonoBehaviour
|
|
{
|
|
[Serializable]
|
|
public class AudioSetting
|
|
{
|
|
public string audioPath;
|
|
public float volume = 1;
|
|
}
|
|
|
|
public AudioSetting audioSetting;
|
|
public float duration;
|
|
|
|
private TimeHandler _timeHandler;
|
|
|
|
private void OnEnable ()
|
|
{
|
|
this._timeHandler?.Kill ();
|
|
if (!this.audioSetting.audioPath.IsNullOrWhitespace ())
|
|
{
|
|
AudioManager.Instance.PlaySound (this.audioSetting.audioPath , this.audioSetting.volume);
|
|
}
|
|
this._timeHandler = GameUpdateMgr.Instance.CreateTimer (this.duration , () =>
|
|
{
|
|
this.gameObject.SetActive (false);
|
|
});
|
|
}
|
|
|
|
private void OnDisable ()
|
|
{
|
|
this._timeHandler?.Kill ();
|
|
}
|
|
}
|
|
} |