public class BuffSO : ScriptableObject

{ public float duration; public float tick; public int id; public bool isOverlapable; public Sprite icon; public Health target; public Coroutine cor; public virtual void ActiveBuff() { } public virtual void EndBuff() { } } public struct Buff { public BuffSO buff; float Ticker; WaitForSeconds tick; public GameObject coolUI; public void SetBuff(BuffSO buff, Health target) { this.buff = buff; buff.target = target; tick = new WaitForSeconds(buff.tick); Ticker = 0; } public IEnumerator ActiveBuff() { while(buff.duration > Ticker) { buff.ActiveBuff(); yield return tick; Ticker += buff.tick; } EndBuff();//์ด๊ฑด ์•ˆ๋จ } public void EndBuff() { buff.target.RemoveBuff(this); } } -------------------------------------------------------------------------------------------- public List<Buff> buffList; public virtual void AddBuff(BuffSO buff) { Buff selectedBuff = buffList.Find(so => so.buff.id == buff.id); if(selectedBuff.buff != null &&!selectedBuff.buff.isOverlapable) { selectedBuff.EndBuff();//์ด๊ฑด ๋จ } selectedBuff = new Buff(); selectedBuff.SetBuff(buff, this); if (_character.CharacterType == Character.CharacterTypes.Player) { selectedBuff.coolUI = GUIManager.Instance.SetBuffUI(selectedBuff); } buffList.Add(selectedBuff); selectedBuff.buff.cor = StartCoroutine(selectedBuff.ActiveBuff()); } public virtual void RemoveBuff(Buff buff) { unsafe { TypedReference tr2 = __makeref(buff); IntPtr ptr1 = **(IntPtr**)(&tr2); Debug.Log(ptr1); } StopCoroutine(buff.buff.cor); buffList.Remove(buff); Destroy(buff.coolUI);ย 

}

addbuff ์•ˆ์—์„œ ํ˜ธ์ถœํ•œ removeBuff๋Š”๋ฆฌ์ŠคํŠธ์—์„œย ์ง€์›Œ์ง€๊ณ  Buff๊ตฌ์กฐ์ฒด ์•ˆ์—์„œ ํ˜ธ์ถœํ•œ removeBuff๋Š” ์•ˆ์ง€์›Œ์ง. ๋ฉ”์„œ๋“œ๋„ ํ˜ธ์ถœ ๋˜๋Š”๊ฑฐ ๋ดค๊ณ  ์ฃผ์†Œ๊ฐ’ ๊ฐ™์€๊ฑฐ๋„ ํ™•์ธ ํ–ˆ๋Š”๋ฐ ์™œ ์•ˆ์ง€์›Œ์ง€์ง€..