add some extra assets FX and SFX
This commit is contained in:
29
Assets/PixPlays/Components/Scripts/VfxSystem/BaseVfx.cs
Normal file
29
Assets/PixPlays/Components/Scripts/VfxSystem/BaseVfx.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
namespace PixPlays.ElementalVFX
|
||||
{
|
||||
public class BaseVfx : MonoBehaviour
|
||||
{
|
||||
[SerializeField] float _SafetyDestroy; //Destroy the object after a certan time in case user error keeps it active.
|
||||
[SerializeField] float _DestoyDelay; //Wait for effect to finish stopping before destroying the GameObject
|
||||
protected VfxData _data;
|
||||
public virtual void Play(VfxData data)
|
||||
{
|
||||
_data = data;
|
||||
if (_data.Duration > _SafetyDestroy)
|
||||
{
|
||||
_SafetyDestroy += _data.Duration;//Offset the safety destroy by the duration if bigger;
|
||||
}
|
||||
Destroy(gameObject, _SafetyDestroy);
|
||||
Invoke(nameof(Stop), _data.Duration);
|
||||
StopAllCoroutines();
|
||||
}
|
||||
|
||||
public virtual void Stop()
|
||||
{
|
||||
StopAllCoroutines();
|
||||
Destroy(gameObject, _DestoyDelay);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user