1
This commit is contained in:
27
Src/Unity/Scripts/Entity/Components/VFX/EntityVFXPlayer.cs
Normal file
27
Src/Unity/Scripts/Entity/Components/VFX/EntityVFXPlayer.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
|
||||
namespace BITKit.Entities.VFX
|
||||
{
|
||||
public class EntityVFXPlayer : EntityBehavior
|
||||
{
|
||||
[SerializeReference,SubclassSelector] private IReference[] vfxReferences;
|
||||
[SerializeField] private VFXPlayer vfxPlayer;
|
||||
private readonly List<string> keyWords=new();
|
||||
public override void OnAwake()
|
||||
{
|
||||
base.OnAwake();
|
||||
keyWords.AddRange(vfxReferences.Select(x=>x.Value));
|
||||
UnityEntity.AddListener<string>(Constant.Animation.Play, Play);
|
||||
}
|
||||
|
||||
private void Play(string animationName)
|
||||
{
|
||||
if (isActiveAndEnabled is false) return;
|
||||
if (keyWords.Contains(animationName) is false) return;
|
||||
vfxPlayer.Execute();
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user