You've already forked taptap2024_GJ_chidouren
updat core
This commit is contained in:
42
Assets/Scripts/Game/Component/PropEffect.cs
Normal file
42
Assets/Scripts/Game/Component/PropEffect.cs
Normal file
@@ -0,0 +1,42 @@
|
||||
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 ();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user