using System.Collections; using System.Collections.Generic; using System.Linq; using UnityEngine; public class EffectMgr : MonoBehaviourSingletonTemplate { [Header("Pool Setting")] public Transform tf_parent; Dictionary> dic_effect= new Dictionary>(); public void AllOff() { // 부모 아래에 있는 모든 Projectile 검색 var keys = dic_effect.Keys.ToList(); for (int i = 0; i < keys.Count; i++) dic_effect[keys[i]].ForEach(f=>f.SetActive(false)); } public void Show_Effect(string effectpath, Vector2 pos, float scale = 100f) { if (!effectpath.Contains("Effect/")) effectpath = $"Effect/{effectpath}"; if (!dic_effect.ContainsKey(effectpath)) dic_effect.Add(effectpath, new List()); GameObject effect = null; for (int i = 0; i < dic_effect[effectpath].Count; i++) { if (!dic_effect[effectpath][i].activeSelf) { effect = dic_effect[effectpath][i]; break; } } if (effect == null) { effect = DSUtil.Get_Clone(effectpath, tf_parent); dic_effect[effectpath].Add(effect); } effect.transform.position = pos; effect.transform.localScale = Vector3.one * scale; effect.gameObject.SetActive(true); StartCoroutine(Co_Off(effect)); } IEnumerator Co_Off(GameObject effect) { yield return new WaitForSeconds(1f); effect.SetActive(false); } }