using System.Collections.Generic; public class NotePoolManager : BasePool { protected override void OnCreate(BaseNote obj) { obj.OnNoteUesd += ReturnBaseNoteToPool; } protected override void OnGet(BaseNote obj) { base.OnGet(obj); } protected override void OnRelease(BaseNote obj) { } /// /// 泛型note回收方法 /// /// public void ReturnBaseNoteToPool(BaseNote note) { //如果字典中没有该类的对象池,则创建一个 var type = note.GetType(); if (!Pools.ContainsKey(type)) Pools[type] = new Stack(); Pools[type].Push(note); note.gameObject.SetActive(false); } }