GameObject Attach(GameObject obj, float delay = -1) { if (obj == null) { return(null); } RecycleObject rc = obj.GetComponent <RecycleObject>(); if (rc == null) { rc = obj.AddComponent <RecycleObject>(); } rc.releaseAfter = delay; rc.pool = this; return(obj); }
public void Release(GameObject obj, float delay = 0) { RecycleObject rc = obj.GetComponent <RecycleObject>(); if (delay <= 0) { if (rc == null) { GameObject.Destroy(obj); } else { rc.Release(); } } else { if (rc == null) { rc = obj.AddComponent <RecycleObject>(); } rc.releaseAfter = delay; } }