30 lines
748 B
C#
30 lines
748 B
C#
|
|
using System.Collections.Generic;
|
|||
|
|
public class NotePoolManager : BasePool<BaseNote>
|
|||
|
|
{
|
|||
|
|
protected override void OnCreate(BaseNote obj)
|
|||
|
|
{
|
|||
|
|
obj.OnNoteUesd += ReturnBaseNoteToPool;
|
|||
|
|
}
|
|||
|
|
protected override void OnGet(BaseNote obj)
|
|||
|
|
{
|
|||
|
|
base.OnGet(obj);
|
|||
|
|
}
|
|||
|
|
protected override void OnRelease(BaseNote obj)
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
/// <summary>
|
|||
|
|
/// <20><><EFBFBD><EFBFBD>note<74><65><EFBFBD>շ<EFBFBD><D5B7><EFBFBD>
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="note"></param>
|
|||
|
|
public void ReturnBaseNoteToPool(BaseNote note)
|
|||
|
|
{
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5><EFBFBD>û<EFBFBD>и<EFBFBD><D0B8><EFBFBD><EFBFBD>Ķ<EFBFBD><C4B6><EFBFBD><EFBFBD><EFBFBD>,<2C><EFBFBD>һ<EFBFBD><D2BB>
|
|||
|
|
var type = note.GetType();
|
|||
|
|
if (!Pools.ContainsKey(type)) Pools[type] = new Stack<BaseNote>();
|
|||
|
|
Pools[type].Push(note);
|
|||
|
|
note.gameObject.SetActive(false);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|