feat: spawning particles with object pooling
This commit is contained in:
parent
858e49e1d9
commit
efac0019ba
14 changed files with 235 additions and 21 deletions
|
@ -1,14 +1,19 @@
|
|||
using System;
|
||||
using Pooling;
|
||||
using Presenter;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Serialization;
|
||||
using Animation = FramedAnimator.Animation;
|
||||
using Animator = FramedAnimator.Animator;
|
||||
|
||||
namespace View.Scene {
|
||||
public class GrowParticle : MonoBehaviour {
|
||||
public class GrowParticle : MonoBehaviour, IPooledObject {
|
||||
[SerializeField] private Animator animator;
|
||||
[SerializeField] private Animation particleAnimation;
|
||||
|
||||
private void Start() {
|
||||
animator.OnAnimationEnd += _ => Destroy(gameObject);
|
||||
public void OnObjectSpawn() {
|
||||
animator.ChangeAnimation(particleAnimation);
|
||||
animator.OnAnimationEnd += _ => Pooler.Recycle(gameObject);
|
||||
animator.PlayUntil(1f);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue